def test1(): fn = r'data/test12_wij10.mtg' drf = r'data/wij10.drf' length = lambda x: g.property('longueur').get(x) botdia = lambda x: g.property('diabase').get(x) topdia = lambda x: g.property('diasom').get(x) g = read_mtg_file(fn) dressing_data = dresser.dressing_data_from_file(drf) pf = plantframe.PlantFrame(g, Length=length, TopDiameter=topdia, BottomDiameter=botdia, DressingData = dressing_data) # axes are linear and diameter are defined on axes. assert len(pf.top_diameter) == 16 assert len(pf.bottom_diameter) == 16 for v in g.vertices(scale=3): assert pf.is_linear(g, v) diameters = pf.algo_diameter() assert len(diameters) == g.nb_vertices(scale=4) length = pf.algo_length() return pf
def read_mtg(fn='walnut.mtg', drf='walnut.drf'): g = read_mtg_file(fn) 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() diameters = pf.algo_diameter() toppositions = pf.points def botdiameter(g, topdiameter): botdiam = {} for vid, topdiam in topdiameter.iteritems(): if g.edge_type(vid) == '<': botdiam[vid] = topdiameter[g.parent(vid)] else: botdiam[vid] = topdiam return botdiam g.properties()['topdiameter'] = diameters g.properties()['bottomdiameter'] = botdiameter(g, diameters) g.properties()['tipposition'] = dict([ (k, Vector3(v)) for k, v in toppositions.iteritems() ]) g = flatten(g) return g
def read_mtg(fn='walnut.mtg', drf='walnut.drf'): fileName = ('/').join(os.path.abspath(__file__).split('/')[:-1]) fn = str(fileName) + "/" + fn drf = str(fileName) + "/" + drf g = read_mtg_file(fn) 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() diameters = pf.algo_diameter() toppositions = pf.points g.properties()['TopDiameter'] = diameters g.properties()['TopPosition'] = dict([ (k, Vector3(v)) for k, v in toppositions.iteritems() ]) g = flatten(g) return g
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 = next(g.roots_iter(scale=g.max_scale())) 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
def walnut(): fn = r'data/test9_noylum2.mtg' drf = r'data/walnut.drf' g = read_mtg_file(fn) 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() return pf
def __test2(): fn = r'data/hetre.mtg' g = read_mtg_file(fn) param = dresser.DressingData() et = g.property('edge_type') split_axe = lambda v: et.get(v) == '+' pf = plantframe.PlantFrame(g, Axe=split_axe, DressingData=param) diameters = pf.algo_diameter() length = pf.algo_length() return pf
def test3(): fn = r'data/test12_wij10.mtg' drf = r'data/wij10.drf' g = read_mtg_file(fn) dressing_data = dresser.dressing_data_from_file(drf) et = g.property('edge_type') split_axe = lambda v: et.get(v) == '+' pf = plantframe.PlantFrame(g, Axe=split_axe, DressingData=dressing_data) diameters = pf.algo_diameter() length = pf.algo_length() return pf
def read_mtg(fn = 'walnut.mtg' ,drf = 'walnut.drf'): g = read_mtg_file(fn) 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() diameters = pf.algo_diameter() toppositions = pf.points g.properties()['TopDiameter']=diameters g.properties()['TopPosition']= dict([ (k,Vector3(v)) for k,v in toppositions.items()]) g = flatten(g) return g
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
def create_scene(g): xmin = 999999 xmax = -999999 ymin = 999999 ymax = -999999 zmin = 999999 zmax = -999999 for vid in g.vertices(scale=3): xmin = min(xmin, g.node(vid).XX) xmax = max(xmax, g.node(vid).XX) ymin = min(ymin, g.node(vid).YY) ymax = max(ymax, g.node(vid).YY) zmin = min(zmin, g.node(vid).ZZ) zmax = max(zmax, g.node(vid).ZZ) unit = 10 dressing_data = plantframe.DressingData(DiameterUnit=unit) pf = plantframe.PlantFrame(g, TopDiameter='TopDia', DressingData=dressing_data) scn = pf.plot(gc=True) return (scn)