def get_paths_from_file(fn, spatial_sort=True, spatial_concat=False, spatial_concat_eps=1.e-9): from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_2d as sort from modules.ddd import spatial_concat_2d as concat data = load(fn) vertices = data['vertices'] lines = data['lines'] print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) paths = [row_stack(vertices[l, :]) for l in lines] paths = sort(paths) if spatial_sort else paths paths = concat(paths, spatial_concat_eps) if spatial_concat else paths return paths
def get_edges_from_file(fn, spatial_sort=True, spatial_concat=False, spatial_concat_eps=1.0e-9): from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_2d as sort from modules.ddd import spatial_concat_2d as concat data = load(fn) vertices = data['vertices'] print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) edges = data['edges'] paths = [row_stack(p) for p in vertices[edges, :]] paths = sort(paths) if spatial_sort else paths paths = concat(paths, spatial_concat_eps) if spatial_concat else paths print('edges: ', len(paths)) return paths
def get_paths_from_file( fn, spatial_sort=True, spatial_concat=False, spatial_concat_eps=1.e-9 ): from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_2d as sort from modules.ddd import spatial_concat_2d as concat data = load(fn) vertices = data['vertices'] lines = data['lines'] print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) paths = [row_stack(vertices[l, :]) for l in lines] paths = sort(paths) if spatial_sort else paths paths = concat(paths, spatial_concat_eps) if spatial_concat else paths return paths
def get_edges_from_file( fn, spatial_sort=True, spatial_concat=False, spatial_concat_eps=1.0e-9 ): from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_2d as sort from modules.ddd import spatial_concat_2d as concat data = load(fn) vertices = data['vertices'] print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) edges = data['edges'] paths = [row_stack(p) for p in vertices[edges, :]] paths = sort(paths) if spatial_sort else paths paths = concat(paths, spatial_concat_eps) if spatial_concat else paths print('edges: ', len(paths)) return paths
def get_paths_from_n_files( pattern, skip=0, steps=1, stride=1, spatial_sort=True, spatial_concat=False, spatial_concat_eps=1.e-9 ): from glob import glob from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_2d as sort from modules.ddd import spatial_concat_2d as concat vertices = [] lines = [] vnum = 0 files = sorted(glob(pattern)) for fn in files[skip:steps:stride]: print(fn) data = load(fn) v = data['vertices'] l = data['lines'] vn = len(v) vertices.append(v) lines.append(array(l, 'int')+vnum) vnum += vn vertices = row_stack(vertices) print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) paths = [row_stack(vertices[li, :]) for li in lines] paths = sort(paths) if spatial_sort else paths paths = concat(paths, spatial_concat_eps) if spatial_concat else paths return paths
def get_paths_from_n_files(pattern, skip=0, steps=1, stride=1, spatial_sort=True, spatial_concat=False, spatial_concat_eps=1.e-9): from glob import glob from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_2d as sort from modules.ddd import spatial_concat_2d as concat vertices = [] lines = [] vnum = 0 files = sorted(glob(pattern)) for fn in files[skip:steps:stride]: print(fn) data = load(fn) v = data['vertices'] l = data['lines'] vn = len(v) vertices.append(v) lines.append(array(l, 'int') + vnum) vnum += vn vertices = row_stack(vertices) print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) paths = [row_stack(vertices[li, :]) for li in lines] paths = sort(paths) if spatial_sort else paths paths = concat(paths, spatial_concat_eps) if spatial_concat else paths return paths
def get_dots_from_file( fn, spatial_sort=True, ): from modules.ioOBJ import load_2d as load from modules.ddd import spatial_sort_dots_2d as sort data = load(fn) vertices = data['vertices'] print('orig size:') print_values(*get_bounding_box(vertices)) fit(vertices) print('scaled size:') print_values(*get_bounding_box(vertices)) vertices = sort(vertices) if spatial_sort else vertices print('dots: ', len(vertices)) return vertices