def draw_vd(vd, times): #w=2500 #h=1500 #w=1920 #h=1080 w = 1024 h = 1024 myscreen = ovdvtk.VTKScreen(width=w, height=h) ovdvtk.drawOCLtext(myscreen, rev_text=ovd.version()) w2if = vtk.vtkWindowToImageFilter() w2if.SetInput(myscreen.renWin) lwr = vtk.vtkPNGWriter() lwr.SetInput(w2if.GetOutput()) #w2if.Modified() #lwr.SetFileName("tux1.png") scale = 1 myscreen.render() far = 1 camPos = far zmult = 3 # camPos/float(1000) myscreen.camera.SetPosition(0, -camPos / float(1000), zmult * camPos) myscreen.camera.SetClippingRange(-(zmult + 1) * camPos, (zmult + 1) * camPos) myscreen.camera.SetFocalPoint(0.0, 0, 0) # for vtk visualization vod = ovdvtk.VD(myscreen, vd, float(scale), textscale=0.01, vertexradius=0.003) vod.drawFarCircle() vod.textScale = 0.02 vod.vertexRadius = 0.0031 vod.drawVertices = 0 vod.drawVertexIndex = 0 vod.drawGenerators = 0 vod.offsetEdges = 0 vd.setEdgeOffset(0.05) #times=[] #times.append( 1 ) #times.append( 1 ) vod.setVDText2(times) vod.setAll() myscreen.render() #w2if.Modified() #lwr.SetFileName("{0}.png".format(Nmax)) #lwr.Write() myscreen.iren.Start()
def drawFrame(N=2, nframe=1): myscreen = ovdvtk.VTKScreen(width=1920, height=1080) ovdvtk.drawOCLtext(myscreen) w2if = vtk.vtkWindowToImageFilter() w2if.SetInput(myscreen.renWin) lwr = vtk.vtkPNGWriter() lwr.SetInputConnection(w2if.GetOutputPort()) # lwr.SetFileName(filename) random.seed(42) scale = 1 far = 1 camPos = far zmult = 4 myscreen.camera.SetPosition(0, -camPos / float(1000), zmult * camPos) myscreen.camera.SetClippingRange(-(zmult + 1) * camPos, (zmult + 1) * camPos) myscreen.camera.SetFocalPoint(0.0, 0, 0) vd = ovd.VoronoiDiagram(far, 120) print(ovd.version()) # for vtk visualization vod = ovdvtk.VD(myscreen, vd, float(scale), textscale=0.01, vertexradius=0.003) vod.drawFarCircle() Nmax = N # random points plist = randomGenerators(far, Nmax) t_before = time.time() n = 0 id_list = [] for p in plist: print("%s adding %s" % (n, p)) id_list.append(vd.addVertexSite(p)) n = n + 1 id1 = id_list[0] id2 = id_list[1] print("add segment %s to %s" % (id1, id2)) vd.addLineSite(id1, id2) t_after = time.time() calctime = t_after - t_before print(" VD done in %s s, %s s per generator" % (calctime, calctime / Nmax)) vod.setAll() myscreen.render() # writeFrame( w2if, lwr, nframe ) # myscreen.iren.Start() print("PYTHON All DONE.")
segs2 = translate(segs2, xt * dx, -0.05 * dx) segs2 = modify_segments(segs2) segs3 = translate(segs3, xt * dx, -0.15 * dx) segs3 = modify_segments(segs3) segs4 = translate(segs4, xt * dx, -0.22 * dx) segs4 = modify_segments(segs4) segs5 = translate(segs5, xt * dx, -0.32 * dx) segs5 = modify_segments(segs5) vd = ovd.VoronoiDiagram(far, 400) print(ovd.version()) vod = ovdvtk.VD(myscreen, vd, float(1), textscale=0.01, vertexradius=0.003) vod.drawFarCircle() # vod.textScale = 0.000002 vod.textScale = 0.00005 vod.vertexRadius = 0.0011 vod.drawVertices = 0 vod.drawVertexIndex = 0 vod.drawGenerators = 0 vod.offsetEdges = 0 vod.drawNullEdges = 1 vd.setEdgeOffset(0.00005) # create an outer box # boxsegs= [ [ [0.8,-0.8],[0.8,0.8], [-0.8,0.8], [-0.8,-0.8] ] ] b = 0.6 boxsegs = [[[-b, -b], [-b, b], [b, b], [b, -b]]]
t_after = time.time() #print "( VD2 OFFSET in ", 1e3*(t_after-t_before)," milliseconds. )" print "( VD2 OFFSET in %.3f s. )" % (1e3*(t_after-t_before)) drawOffsets2(myscreen, ofs2) """ myscreen.render() # myscreen.iren.Start() # now create the VD for pocketing vd3 = ovd.VoronoiDiagram(1, 120) times = insert_offset_loop(vd3, ofs) # print "( VD3 done in ", 1e3*(sum(times))," milliseconds. )" print "( VD3 done in %.3f s. )" % (sum(times)) vod3 = ovdvtk.VD(myscreen, vd3, float(scale), textscale=0.01, vertexradius=0.003) vod3.textScale = 0.0002 vod3.vertexRadius = 0.0031 vod3.drawVertices = 0 vod3.drawVertexIndex = 1 vod3.drawGenerators = 0 vod3.offsetEdges = 0 vod3.setVDText2(times) pi = ovd.PolygonInterior(False) vd3.filter_graph(pi) ma = ovd.MedialAxis()
scale = 1 myscreen.render() random.seed(44) far = 1 camPos = far zmult = 5 myscreen.camera.SetPosition(camPos / float(1000), camPos / float(1000), zmult * camPos) myscreen.camera.SetClippingRange(-(zmult + 1) * camPos, (zmult + 1) * camPos) myscreen.camera.SetFocalPoint(0.0, 0, 0) vd = ovd.VoronoiDiagram(far, 120) print ovd.version() vod = ovdvtk.VD(myscreen, vd, float(scale)) vod.drawVertices = 0 vod.drawVertexIndex = 0 vod.vertexRadius = 0.0031 drawFarCircle(myscreen, vd.getFarRadius(), ovdvtk.orange) Nmax = 500 plist = randomGenerators(far, Nmax) # plist = regularGridGenerators(far, Nmax) # plist = circleGenerators(far, Nmax) # plist = randomGenerators(far, Nmax) + regularGridGenerators(far, Nmax) + circleGenerators(far, Nmax) # plist = [ovd.Point(0,0)]
scale = 1 myscreen.render() random.seed(42) far = 1 camPos = far zmult = 5 myscreen.camera.SetPosition(camPos / float(1000), camPos / float(1000), zmult * camPos) myscreen.camera.SetClippingRange(-(zmult + 1) * camPos, (zmult + 1) * camPos) myscreen.camera.SetFocalPoint(0.0, 0, 0) vd = ovd.VoronoiDiagram(far, 1200) vod = ovdvtk.VD(myscreen, vd, scale) # vod.setAll(vd) drawFarCircle(myscreen, scale * vd.getFarRadius(), ovdvtk.orange) Nmax = 10 # plist = randomGenerators(far, Nmax) # plist = regularGridGenerators(far, Nmax) # plist = circleGenerators(far, Nmax) plist = randomGenerators(far, Nmax) + regularGridGenerators( far, Nmax) + circleGenerators(far, Nmax) plist = [ ovd.Point(0.622289, 0.522162), ovd.Point(0.81234, 0),