Example #1
0
def test_colors():
    pf = walnut()
    axes = plantframe.compute_axes(pf.g,3, pf.points, pf.origin)
    axes[0][0].insert(0,pf.origin)
    diameters = pf.algo_diameter()

    g = pf.g
    colors =defaultdict(lambda x: (0,255,0), 
        zip(range(8), [ ((i&2**0)*255, ((i&2**1)>>1)*255, ((i&2**2)>>2)*255) for i in range(8)])) 
    def my_color(vid):
        return colors[g.order(vid)]

    scene=plantframe.build_scene(pf.g, pf.origin, axes, pf.points, diameters, 10000, option='cylinder', colors = my_color)
    return scene
Example #2
0
def test5():
    fn = r'data/test10_agraf.mtg'
    drf = r'data/agraf.drf'

    t=clock()

    g = read_mtg_file(fn)

    t1=clock(); t, dt = t1, t1-t
    print 'readmtg in ', dt 

    topdia = lambda x: g.property('TopDia').get(x)

    dressing_data = dresser.dressing_data_from_file(drf)
    pf = plantframe.PlantFrame(g, 
                               TopDiameter=topdia, 
                               DressingData = dressing_data)
    pf.propagate_constraints()

    t1=clock(); t, dt = t1, t1-t
    print 'empty plantframe in ', dt 

    diameters = pf.algo_diameter()

    t1=clock(); t, dt = t1, t1-t
    print 'diameter in ', dt 

    root = g.roots_iter(scale=g.max_scale()).next()
    axes = plantframe.compute_axes(g,root, pf.points, pf.origin)
    axes[0][0].insert(0,pf.origin)

    t1=clock(); t, dt = t1, t1-t
    print 'points in ', dt 

    scene=plantframe.build_scene(pf.g, pf.origin, axes, pf.points, diameters, 10000, option='cylinder')

    t1=clock(); t, dt = t1, t1-t
    print 'scene in ', dt 

    return scene, pf
Example #3
0
def test4():
    fn = r'data/test9_noylum2.mtg'
    drf = r'data/walnut.drf'

    t=clock()

    g = read_mtg_file(fn)

    t1=clock(); t, dt = t1, t1-t
    print 'readmtg in ', dt 

    topdia = lambda x: g.property('TopDia').get(x)

    dressing_data = dresser.dressing_data_from_file(drf)
    pf = plantframe.PlantFrame(g, 
                               TopDiameter=topdia, 
                               DressingData = dressing_data)
    pf.propagate_constraints()

    t1=clock(); t, dt = t1, t1-t
    print 'empty plantframe in ', dt 

    diameters = pf.algo_diameter()

    t1=clock(); t, dt = t1, t1-t
    print 'diameter in ', dt 

    axes = plantframe.compute_axes(g,3, pf.points, pf.origin)
    axes[0][0].insert(0,pf.origin)

    t1=clock(); t, dt = t1, t1-t
    print 'points in ', dt 

    scene=plantframe.build_scene(pf.g, pf.origin, axes, pf.points, diameters, 10000)

    t1=clock(); t, dt = t1, t1-t
    print 'scene in ', dt 
    return scene, pf