def f(dm, fn): vnum = dm.np_get_vert_coordinates(verts) enum = dm.np_get_edges(edges) linenum = dm.np_get_sorted_verts(line) meta = '\n# procs {:d}\n'+\ '# vnum {:d}\n'+\ '# enum {:d}\n'+\ '# time {:f}\n'+\ '# nearl {:f}\n'+\ '# farl {:f}\n'+\ '# stp {:f}\n'+\ '# size {:d}\n' meta = meta.format( data['procs'], vnum, enum, time()-t0, data['nearl'], data['farl'], data['stp'], data['size'] ) export( 'line', fn, verts = verts[:vnum,:], edges = edges[:enum,:], lines = [line[:linenum]], meta = meta )
def main(): from numpy.random import random from numpy import zeros from dddUtils.pointCloud import point_cloud from dddUtils.ioOBJ import export_2d as export from modules.utils import get_dens_example from modules.utils import get_dens_from_img from modules.utils import sample_from_dens from ccvt import Ccvt as ccvt fn = './data/kelp.png' n = 10000 m = 100000 print('get density') dens = get_dens_from_img(fn) # dens = get_dens_example(100) print('sample domain') domain = sample_from_dens(dens, m) print('sample dens') org_sites = sample_from_dens(dens, n) sites, inv_tesselation = ccvt(domain, org_sites, maxitt=5) export('voronoi','./res/out.2obj', sites)
def main(): from numpy.random import random from numpy import zeros from dddUtils.pointCloud import point_cloud from dddUtils.ioOBJ import export_2d as export from modules.utils import get_dens_example from modules.utils import get_dens_from_img from modules.utils import sample_from_dens from ccvt import Ccvt as ccvt fn = './data/kelp.png' n = 10000 m = 100000 print('get density') dens = get_dens_from_img(fn) # dens = get_dens_example(100) print('sample domain') domain = sample_from_dens(dens, m) print('sample dens') org_sites = sample_from_dens(dens, n) sites, inv_tesselation = ccvt(domain, org_sites, maxitt=5) export('voronoi', './res/out.2obj', sites)
def __write_svg_and_exit(*args): gtk.main_quit(*args) show(render,F) render.write_to_png('./res/on_exit.png') from dddUtils.ioOBJ import export_2d as export vertices, paths = F.get_vertices_and_paths() fn = './res/on_exit.2obj'.format(F.i) export('curves', fn, vertices, lines=paths)