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.")
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 n, " adding ", p id_list.append(vd.addVertexSite(p)) n = n + 1 id1 = id_list[0] id2 = id_list[1] print "add segment ", id1, " to ", id2 vd.addLineSite(id1, id2) t_after = time.time() calctime = t_after - t_before print " VD done in ", calctime, " s, ", calctime / Nmax, " s per generator" vod.setAll() myscreen.render() # writeFrame( w2if, lwr, nframe ) # myscreen.iren.Start() print "PYTHON All DONE."
# 10 err fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf" ); s3 = ttt.ttt(text, wr) segs = wr.get_segments() return segs if __name__ == "__main__": # w=2500 # h=1500 w = 1600 h = 1024 # 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.SetInputConnection(w2if.GetOutputPort()) # w2if.Modified() # lwr.SetFileName("tux1.png") scale = 1 far = 1 camPos = far zmult = 3 myscreen.camera.SetPosition(0, -camPos / float(1000), zmult * camPos) myscreen.camera.SetClippingRange(-(zmult + 1) * camPos, (zmult + 1) * camPos)
import gzip def drawCircle(myscreen, c, r, circlecolor): ca = ovdvtk.Circle(center=(c.x,c.y,0) , radius=r, color=circlecolor, resolution=50 ) myscreen.addActor(ca) if __name__ == "__main__": #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() random.seed(42) far = 1 camPos = far zmult = 3 # camPos/float(1000)
segs_mod.append(seg) #drawSegment(myscreen, seg) return segs_mod if __name__ == "__main__": #w=2500 # screen resolution for big screens #h=1500 #w=1920 #h=1080 w = 1024 h = 1024 myscreen = ovdvtk.VTKScreen(width=w, height=h) # a VTK window for drawing ovdvtk.drawOCLtext( myscreen, rev_text=ovd.version()) # the OpenVoronoi text, revision, and date 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) vd = ovd.VoronoiDiagram(far, 120)
import time import vtk import math import offset2vtk if __name__ == "__main__": #w=2500 # screen resolution for big screens #h=1500 #w=1920 #h=1080 w=1024 h=1024 myscreen = ovdvtk.VTKScreen(width=w, height=h) # a VTK window for drawing ovdvtk.drawOCLtext(myscreen, rev_text=ovd.version() ) # the OpenVoronoi text, revision, and date 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) vd = ovd.VoronoiDiagram(far,120) print ovd.version()
# POINTS ON A CIRCLE dalfa = float(2 * math.pi) / float(Nmax - 1) plist = [] radius = 0.81234 * float(far) for n in range(Nmax): x = float(radius) * math.cos(float(n) * float(dalfa)) y = float(radius) * math.sin(float(n) * float(dalfa)) plist.append(ovd.Point(x, y)) if shuffle: random.shuffle(plist) return plist if __name__ == "__main__": myscreen = ovdvtk.VTKScreen() ovdvtk.drawOCLtext(myscreen) w2if = vtk.vtkWindowToImageFilter() w2if.SetInput(myscreen.renWin) lwr = vtk.vtkPNGWriter() lwr.SetInputConnection(w2if.GetOutputPort()) # w2if.Modified() # lwr.SetFileName("tux1.png") scale = 1 myscreen.render() random.seed(42) far = 1 camPos = far zmult = 5
#dgamma= 10*2*math.pi/npts #alfa=0 #ofs=10 plist = [] radius = 0.81234 * float(far) for n in range(Nmax): x = float(radius) * math.cos(float(n) * float(dalfa)) y = float(radius) * math.sin(float(n) * float(dalfa)) plist.append(ovd.Point(x, y)) #random.shuffle(plist) return plist if __name__ == "__main__": myscreen = ovdvtk.VTKScreen() ovdvtk.drawOCLtext(myscreen) w2if = vtk.vtkWindowToImageFilter() w2if.SetInput(myscreen.renWin) lwr = vtk.vtkPNGWriter() lwr.SetInput(w2if.GetOutput()) #w2if.Modified() #lwr.SetFileName("tux1.png") scale = 1 myscreen.render() random.seed(44) far = 1 camPos = far zmult = 5