def rpg_vd(Npts, seed, debug): far = 1 vd = ovd.VoronoiDiagram(1, 120) vd.reset_vertex_count() poly = rpg.rpg(Npts, seed) pts = [] for p in poly: ocl_pt = ovd.Point(p[0], p[1]) pts.append(ocl_pt) id_list = [] for p in pts: id_list.append(vd.addVertexSite(p)) for n in range(len(id_list)): n_nxt = n + 1 if n == (len(id_list) - 1): n_nxt = 0 # point 0 is the endpoint of the last segment vd.addLineSite(id_list[n], id_list[n_nxt]) print(" all segs inserted.") is_valid = vd.check() print(" vd-check: %s" % is_valid) return is_valid
def timeRPG(N): t_before = time.time() polygon = rpg.rpg(N) t_after = time.time() times = [] times.append(t_after - t_before) return times
def rpg_vd(Npts, seed, debug): far = 1 vd = ovd.VoronoiDiagram(far,120) vd.reset_vertex_count() poly = rpg.rpg(Npts, seed) pts=[] for p in poly: ocl_pt = ovd.Point( p[0], p[1] ) pts.append( ocl_pt ) print ocl_pt times=[] id_list = [] m=0 t_before = time.time() for p in pts: #print " adding vertex ",m id_list.append( vd.addVertexSite( p ) ) m=m+1 """ print "polygon is: " for idx in id_list: print idx," ", print "." """ t_after = time.time() times.append( t_after-t_before ) #print " pts inserted in ", times[0], " s" #print " vd-check: ",vd.check() if (debug): vd.debug_on() t_before = time.time() for n in range(len(id_list)): n_nxt = n+1 if n==(len(id_list)-1): n_nxt=0 # point 0 is the endpoint of the last segment #print " adding line-site ", id_list[n]," - ", id_list[n_nxt] vd.addLineSite( id_list[n], id_list[n_nxt]) t_after = time.time() times.append( t_after-t_before ) print " segs inserted in ", times[1], " s" is_valid = vd.check() print " vd-check: ", is_valid return [is_valid, vd, times]
#w2if.SetInput(myscreen.renWin) #lwr = vtk.vtkPNGWriter() #lwr.SetInput( w2if.GetOutput() ) myscreen.render() camPos = 100 zmult = 0.1 # position the camera 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) N = 1024 #N=128 drawText(myscreen, N) t_before = time.time() polygon = rpg.rpg(N, abs(int(1000 * random.random()))) t_after = time.time() calctime = t_after - t_before print "RPG done in ", calctime, " s, polygon has ", N, " vertices" drawPolygon(myscreen, polygon) print "PYTHON All DONE." #writeFrame( w2if, lwr, N ) myscreen.render() myscreen.iren.Start()
import randompolygon as rpg print "This is randompolygon version ", rpg.version() #N = 2000 N=100 poly = rpg.rpg(N) print "generated random polygon with",N,"vertices" print "The vertices are:" n=0 for p in poly: print n," ",p n=n+1
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) linesegs = 1 # switch to turn on/off line-segments Npts = 500 poly = rpg.rpg(Npts, 0) # N=3 working seeds: 25-43 45 n_problem = Npts # go all the way to the end # n_problem=2 n_step = 10 pts = [] for p in poly: pts.append(ovd.Point(p[0], p[1])) times = [] id_list = [] m = 0 t_before = time.time() for p in pts:
w2if.SetInput(myscreen.renWin) #lwr = vtk.vtkPNGWriter() #lwr.SetInput( w2if.GetOutput() ) myscreen.render() camPos = 1 zmult = 4 # position the camera 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) #N=8192 N = 128 drawText(myscreen, N) t_before = time.time() polygon = rpg.rpg(N) t_after = time.time() calctime = t_after - t_before print "RPG done in ", calctime, " s, polygon has ", N, " vertices" drawPolygon(myscreen, polygon) print "PYTHON All DONE." #writeFrame( w2if, lwr, N ) myscreen.render() myscreen.iren.Start()