def timeVoronoiSegs(Nmax, segtype=1):
    far = 1
    vd = ovd.VoronoiDiagram(far, int( math.floor( math.sqrt(2)*math.sqrt(Nmax) ) ) )
    vd.reset_vertex_count()
    print "waiting for ",Nmax," random segments..",
    sys.stdout.flush()
    t_before = time.time() 
    segs=[]
    if segtype==1:
        segs = ovdgenerators.randomSegments(far,Nmax,seed=1)
    elif segtype==2:
        segs = ovdgenerators.randomSegments2(far,Nmax,seed=1)
    t_after = time.time()
    print ".done in {0:.3f} seconds".format( (t_after - t_before) ) 
    #print " first seg is ", segs[0]
    id_list = []
    t_before = time.time() 
    for s in segs:
        segid=[]
        segid.append( vd.addVertexSite( s[0] ) )
        segid.append( vd.addVertexSite( s[1] ) )
        id_list.append( segid )
    t_after = time.time()
    point_site_time = (t_after - t_before)
    
    # insert linesegs
    t_before = time.time() 
    for s in id_list:
        vd.addLineSite( s[0], s[1] )
    t_after = time.time()
    line_site_time = (t_after - t_before)
    return [point_site_time , line_site_time]
Exemple #2
0
def timeVoronoiSegs(Nmax, segtype=1):
    far = 1
    vd = ovd.VoronoiDiagram(far,
                            int(math.floor(math.sqrt(2) * math.sqrt(Nmax))))
    vd.reset_vertex_count()
    print "waiting for ", Nmax, " random segments..",
    sys.stdout.flush()
    t_before = time.time()
    segs = []
    if segtype == 1:
        segs = gens.randomSegments(far, Nmax, seed=1)
    elif segtype == 2:
        segs = gens.randomSegments2(far, Nmax, seed=1)
    t_after = time.time()
    print ".done in {0:.3f} seconds".format((t_after - t_before))
    #print " first seg is ", segs[0]
    id_list = []
    t_before = time.time()
    for s in segs:
        segid = []
        segid.append(vd.addVertexSite(s[0]))
        segid.append(vd.addVertexSite(s[1]))
        id_list.append(segid)
    t_after = time.time()
    point_site_time = (t_after - t_before)

    # insert linesegs
    t_before = time.time()
    for s in id_list:
        vd.addLineSite(s[0], s[1])
    t_after = time.time()
    line_site_time = (t_after - t_before)
    return [point_site_time, line_site_time]
import openvoronoi as ovd
import time
import math
import sys
import pickle
import gzip
import ovdgenerators as gens

if __name__ == "__main__":  
    print ovd.version()
    
    far = 1
    Nmax = int(math.pow(2,10)) # number of line-segments to generate
    
    print "waiting for ",Nmax," segments..",
    sys.stdout.flush()
    t_before = time.time()
    segs = gens.randomSegments(far,Nmax)
    t_after = time.time()
    print ".done in {0:.3f} s.".format( t_after-t_before )
    
    filename = "randomsegments_{0}.pickle.gz".format(Nmax)
    pstring = pickle.dumps( segs,  2 ) # 2 is binary format
    f = gzip.open(filename, 'wb')
    f.write(pstring)
    f.close()
    print "PYTHON All DONE."
Exemple #4
0
    # Nmax = 256
    # Nmax = 512
    # Nmax = 1024
    # Nmax = 2048
    # Nmax = 4096
    # Nmax = 8192
    # Nmax = 16384
    # Nmax = 32768
    # 1024, 1.247sec, 398 SPLIT verts

    linesegs = 1  # switch to turn on/off line-segments

    print("waiting for %s segments.." % Nmax)
    sys.stdout.flush()
    t_before = time.time()
    segs = gens.randomSegments(
        far, Nmax)  # uncomment this to generate segments on the fly
    """
    filename = "../src/test/data/randomsegments_{0}.pickle.gz".format(Nmax) # or use this to load pre-computed segments
    # (produced with lineseg_dataset_generator.py)
    f = gzip.open(filename, 'rb')
    pstring = f.read()
    segs = pickle.loads( pstring )
    f.close()
    """
    """
    print "waiting for ",Nmax," segments..",
    sys.stdout.flush()
    t_before = time.time()
    segs = gens.randomSegments2(1,Nmax,1)
    """
Exemple #5
0
import openvoronoi as ovd
import time
import math
import sys
import pickle
import gzip
import ovdgenerators as gens

if __name__ == "__main__":
    print(ovd.version())

    far = 1
    Nmax = int(math.pow(2, 10))  # number of line-segments to generate

    print("waiting for %s segments.." % Nmax)
    sys.stdout.flush()
    t_before = time.time()
    segs = gens.randomSegments(far, Nmax)
    t_after = time.time()
    print(".done in {0:.3f} s.".format(t_after - t_before))

    filename = "randomsegments_{0}.pickle.gz".format(Nmax)
    pstring = pickle.dumps(segs, 2)  # 2 is binary format
    f = gzip.open(filename, 'wb')
    f.write(pstring)
    f.close()
    print("PYTHON All DONE.")
Exemple #6
0
 # Nmax = 256
 # Nmax = 512
 # Nmax = 1024
 # Nmax = 2048
 # Nmax = 4096
 # Nmax = 8192
 # Nmax = 16384
 # Nmax = 32768
 # 1024, 1.247sec, 398 SPLIT verts
 
 linesegs = 1 # switch to turn on/off line-segments
 
 print "waiting for ",Nmax," segments..",
 sys.stdout.flush()
 t_before = time.time()
 segs = gens.randomSegments(far,Nmax) # uncomment this to generate segments on the fly 
 
 """
 filename = "../src/test/data/randomsegments_{0}.pickle.gz".format(Nmax) # or use this to load pre-computed segments 
 # (produced with lineseg_dataset_generator.py)
 f = gzip.open(filename, 'rb')
 pstring = f.read()
 segs = pickle.loads( pstring )
 f.close()
 """
 
 """    
 print "waiting for ",Nmax," segments..",
 sys.stdout.flush()
 t_before = time.time()
 segs = gens.randomSegments2(1,Nmax,1)