def f(dm, fn): vnum = dm.np_get_vert_coordinates(verts) print(vnum) # enum = dm.np_get_edges(edges) linenum = dm.np_get_sorted_verts(line) print(linenum) 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, 0, 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 f(dm, fn): vnum = dm.np_get_vert_coordinates(verts) print(vnum) # enum = dm.np_get_edges(edges) linenum = dm.np_get_sorted_verts(line) print(linenum) 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, 0, 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 export(name, f): from numpy import array from iutils.ioOBJ import export_2d as export vertices = f.xy[:f.num, :] lines = [array(l, 'int') for l in f.get_fractures_inds()] print(name) export('fractures', name, vertices, lines=lines)
def e(): vnum = dm.np_get_vertices(np_verts) tnum = dm.np_get_triangles_vertices(np_tris) dm.np_get_triangles_intensity(np_int) move_scale(np_verts[:vnum, :], s=1000) export( 'thing_mesh', fn.name(), verts=np_verts[:vnum, :], tris=np_tris[:tnum, :] )
def main(): from sand import Sand from fn import Fn from iutils.ioOBJ import export_2d as export sand = Sand(SIZE) sand.set_rgba(FRONT) fn = Fn(prefix='./res/') vertices, lines = make_creatures(sand) name = fn.name() sand.write_to_png(name + '.png', GAMMA) export('scribbles', name + '.2obj', verts=vertices, lines=lines)
def main(): from modules.fracture import Fracture from iutils.render import Animate from numpy.random import random from iutils.random import darts_rect from time import time from fn import Fn fn = Fn(prefix='./res/') start = time() initial_sources = darts_rect(SOURCES, 0.5, 0.5, 1.0 - 2.0 * EDGE, 1.0 - 2.0 * EDGE, FRAC_STP) F = Fracture(FRAC_DOT, FRAC_DST, FRAC_STP, initial_sources=initial_sources, zone_leap=ZONE_LEAP, nmax=NMAX) for _ in range(20): F.blow(1, EDGE + random((1, 2)) * (1.0 - 2.0 * EDGE)) def wrap(render): print('itt', F.itt, 'num', F.num, 'fnum', F.fnum, 'anum', F.anum, 'time', time() - start) res = F.step() n = F.frac_front(factor=SPAWN_FACTOR, angle=SPAWN_ANGLE, dbg=DBG) if n > 0: print('new fracs: {:d}'.format(n)) if not F.itt % DRAW_ITT: show(render, F) return res render = Animate(SIZE, BACK, FRONT, wrap) render.set_line_width(LINEWIDTH) render.start() name = fn.name() render.write_to_png(name + '.png') export(name + '.2obj', F)