pointvertices = [ [0.0, 0.0, 0.0], [0.2, 0.0, 0.0], [0.3, 0.5, 0.0], [0.2, 0.5, 0.0], [0.0, 0.5, 0.1], [-1.5, -0.5, 0.0], ] pointvertices2 = [ [0.0, 0.3, 0.0], [0.2, 0.3, 0.0], [0.3, 0.8, 0.0], [0.2, 0.8, 0.0], [0.0, 0.8, 0.1], [-1.5, -0.8, 0.0], ] pointvertices3 = [ [0.5, 0.3, 0.0], [-1.5, -0.8, 0.0], ] polylines = Polylines() polylines.draw(pointvertices, 'aa10&1') polylines.draw(pointvertices2, 'bb2210&1') polylines.draw(pointvertices3, '5b2310&1') polylines.print_attrs() xm.write_obj_to_xml(polylines, 'test_polylines.xml')
[[0.0, 0.0, 0.0], [0.2, 0.0, 0.0]], # 0 [[0.3, 0.0, 0.0], [0.9, 0.0, 0.0]], # 1 [[0.5, 0.0, 0.1], [1.9, 0.0, 0.0]], # 2 ] polygons = [ np.array([[0.0, 0.0, 0.0], [0.2, 0.0, 0.0], [0.2, 0.0, 0.1], [0.3, 0.3, 0.3]]), # 0 np.array([[0.3, 0.0, 0.0], [0.9, 0.0, 0.0]]), # 1 np.array([[0.5, 0.0, 0.1], [1.9, 0.0, 0.0], [0.2, 0.2, 0.2]]), # 2 ] ids_sumo = ['aa10', 'bb22', 'cc333'] # lines.add_rows(3) lines.add_rows(3, vertices=vertices, polygons=polygons, ids_sumo=ids_sumo) lines.print_attrs() xm.write_obj_to_xml(lines, 'test_lines.xml') # save/load save_obj(lines, 'test_lines.obj') del lines print '\nreload' + 60 * '.' lines = load_obj('test_lines.obj') lines.print_attrs() print 'direct access vertex=\n', lines.vertices.value print 'direct access polygons=\n', lines.polygons.value print 'id for index bb22=', lines.ids_sumo.get_id_from_index('bb22') print 'ids for index bb22,cc333=', lines.ids_sumo.get_ids_from_indices( ['bb22', 'cc333']) lines.del_row(2) lines.print_attrs()
[[0.0, 0.0, 0.0], [0.2, 0.0, 0.0]], # 0 [[0.3, 0.0, 0.0], [0.9, 0.0, 0.0]], # 1 [[0.5, 0.0, 0.1], [1.9, 0.0, 0.0]], # 2 ] polygons = [ np.array([[0.0, 0.0, 0.0], [0.2, 0.0, 0.0], [ 0.2, 0.0, 0.1], [0.3, 0.3, 0.3]]), # 0 np.array([[0.3, 0.0, 0.0], [0.9, 0.0, 0.0]]), # 1 np.array([[0.5, 0.0, 0.1], [1.9, 0.0, 0.0], [0.2, 0.2, 0.2]]), # 2 ] ids_sumo = ['aa10', 'bb22', 'cc333'] # lines.add_rows(3) lines.add_rows(3, vertices=vertices, polygons=polygons, ids_sumo=ids_sumo) lines.print_attrs() xm.write_obj_to_xml(lines, 'test_lines.xml') # save/load save_obj(lines, 'test_lines.obj') del lines print '\nreload' + 60 * '.' lines = load_obj('test_lines.obj') lines.print_attrs() print 'direct access vertex=\n', lines.vertices.value print 'direct access polygons=\n', lines.polygons.value print 'id for index bb22=', lines.ids_sumo.get_id_from_index('bb22') print 'ids for index bb22,cc333=', lines.ids_sumo.get_ids_from_indices(['bb22', 'cc333']) lines.del_row(2) lines.print_attrs() print 'id for index bb22=', lines.ids_sumo.get_id_from_index('cc333')