t_before = time.time()    
    print "threads=",bdc1.getThreads()
    bdc1.run()
    t_after = time.time()
    calctime = t_after-t_before
    print " done in ", calctime," s"
    
    clpoints = bdc1.getCLPoints()

    print len(clpoints), " cl points evaluated"
    
    print "rendering...",
    
    # draw the CL-points
    camvtk.drawCLPointCloud(myscreen, clpoints)
        
    print "done"
        
    myscreen.camera.SetPosition(3, 23, 15)
    myscreen.camera.SetFocalPoint(4, 5, 0)
    
    
    w2if = vtk.vtkWindowToImageFilter()
    w2if.SetInput(myscreen.renWin)
    lwr = vtk.vtkPNGWriter()
    lwr.SetInput( w2if.GetOutput() )
    w2if.Modified()
    lwr.SetFileName("tux1.png")
    #lwr.Write()
    
    path = ocl.Path()  # create an empty path object
    # add Line objects to the path in this loop
    for n in range(0, Ny):
        y = ymin + n * dy
        p1 = ocl.Point(0, y, 0)  # start-point of line
        p2 = ocl.Point(9, y, 0)  # end-point of line
        l = ocl.Line(p1, p2)  # line-object
        path.append(l)  # add the line to the path

    print(" set the path for pdf ")
    pdc.setPath(path)

    print(" run the calculation ")
    t_before = time.time()
    pdc.run()  # run drop-cutter on the path
    t_after = time.time()
    print("run took ", t_after - t_before, " s")

    print("get the results ")
    clp = pdc.getCLPoints()  # get the cl-points from pdf

    print(" render the CL-points")
    camvtk.drawCLPointCloud(myscreen, clp)
    #myscreen.addActor( camvtk.PointCloud(pointlist=clp, collist=ccp)  )
    myscreen.camera.SetPosition(3, 23, 15)
    myscreen.camera.SetFocalPoint(5, 5, 0)
    myscreen.render()
    print(" All done.")
    myscreen.iren.Start()
    t_before = time.time()
    bdc.run()  # run the actual drop-cutter
    dc_calls = bdc.getCalls()
    t_after = time.time()
    calctime = t_after - t_before
    print " BDC done in ", calctime, " s", dc_calls, " dc-calls"
    dropcutter_time = calctime
    clpoints = bdc.getCLPoints()

    #print len(clpoints), " cl points evaluated"

    print "rendering raw CL-points."

    # draw the CL-points
    camvtk.drawCLPointCloud(myscreen, clpoints)

    # filter
    print "filtering. before filter we have", len(clpoints), "cl-points"
    t_before = time.time()
    f = ocl.LineCLFilter()
    f.setTolerance(0.001)
    for p in clpoints:
        f.addCLPoint(p)
    f.run()
    t_after = time.time()
    calctime = t_after - t_before
    print " done in ", calctime, " s"

    clp2 = f.getCLPoints()
    print "after filtering we have", len(clp2), "cl-points"
Exemplo n.º 4
0
    print "filtering. before filter we have", len(aclp_lifted), "cl-points"
    t_before = time.time()
    f = ocl.LineCLFilter()
    f.setTolerance(0.001)
    for p in aclp_lifted:
        p2 = ocl.CLPoint(p.x, p.y, p.z)
        f.addCLPoint(p2)

    f.run()
    t_after = time.time()
    calctime = t_after - t_before
    print " done in ", calctime, " s"

    cl_filtered = f.getCLPoints()
    aclp_lifted2 = []
    for p in cl_filtered:
        p2 = ocl.Point(p.x, p.y, p.z) + ocl.Point(0, 0, 1)
        aclp_lifted2.append(p2)

    print " render the CL-points"
    camvtk.drawCLPointCloud(myscreen, clp)
    camvtk.drawCLPointCloud(myscreen, aclp_lifted)
    camvtk.drawCLPointCloud(myscreen, aclp_lifted2)
    #myscreen.addActor( camvtk.PointCloud(pointlist=clp, collist=ccp)  )
    myscreen.camera.SetPosition(3, 23, 15)
    myscreen.camera.SetFocalPoint(5, 5, 0)
    myscreen.render()
    print " All done."
    myscreen.iren.Start()
Exemplo n.º 5
0
        #cutter.edgeDrop(cl,t)
        #cutter.facetDrop(cl,t)
        #c2.vertexDrop(cl2,t)
        cutter.dropCutter(cl, t)
        c2.dropCutter(cl2, t)
        n = n + 1
        if (n % int(len(clpoints) / 10)) == 0:
            print n / int(len(clpoints) / 10), " ",

    print "done."

    print "rendering..."
    print " len(clpoints)=", len(clpoints)
    print " len(ccl2pts)=", len(cl2pts)
    print "rendering clpoints...",
    camvtk.drawCLPointCloud(myscreen, clpoints)
    print "done."
    cl2ptsofs = []
    for p in cl2pts:
        p.z = p.z + offset
        cl2ptsofs.append(p)
    print "rendering offset clpoints...",
    camvtk.drawCLPointCloud(myscreen, cl2ptsofs)
    print "done."
    origo = camvtk.Sphere(center=(0, 0, 0), radius=0.1, color=camvtk.blue)
    origo.SetOpacity(0.2)
    myscreen.addActor(origo)

    myscreen.camera.SetPosition(0.5, 3, 2)
    myscreen.camera.SetFocalPoint(0.5, 0.5, 0)
    myscreen.render()
    print "filtering. before filter we have", len(aclp_lifted),"cl-points"
    t_before = time.time()
    f = ocl.LineCLFilter()
    f.setTolerance(0.001)
    for p in aclp_lifted:
        p2 = ocl.CLPoint(p.x,p.y,p.z)
        f.addCLPoint(p2)
        
    f.run()
    t_after = time.time()
    calctime = t_after-t_before
    print " done in ", calctime," s"
    
    cl_filtered = f.getCLPoints()
    aclp_lifted2=[]
    for p in cl_filtered:
        p2 = ocl.Point(p.x,p.y,p.z) + ocl.Point(0,0,1)
        aclp_lifted2.append(p2)
    
    
    print " render the CL-points"
    camvtk.drawCLPointCloud(myscreen, clp)
    camvtk.drawCLPointCloud(myscreen, aclp_lifted)
    camvtk.drawCLPointCloud(myscreen, aclp_lifted2)
    #myscreen.addActor( camvtk.PointCloud(pointlist=clp, collist=ccp)  )
    myscreen.camera.SetPosition(3, 23, 15)
    myscreen.camera.SetFocalPoint(5, 5, 0)
    myscreen.render()
    print " All done."
    myscreen.iren.Start()