def main(): from differentialMesh import DifferentialMesh from render.render import Render from time import time from modules.helpers import print_stats from numpy.random import randint, random from numpy import unique DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS) DM.new_faces_in_ngon(MID, MID, H, 6, 0.0) render = Render(SIZE, BACK, FRONT) render.set_line_width(LINEWIDTH) tsum = 0 for i in xrange(10000): t1 = time() for _ in xrange(STEPS_ITT): DM.optimize_position( ATTRACT_SCALE, REJECT_SCALE, TRIANGLE_SCALE, ALPHA, DIMINISH, -1 ) henum = DM.get_henum() edges = unique(randint(henum,size=(henum))) en = len(edges) rnd = 1-2*random(size=en*2) make_island = random(size=en)>0.85 for i,(he,isl) in enumerate(zip(edges,make_island)): if DM.is_surface_edge(he)>0: the = pi*rnd[2*i] rad = rnd[2*i+1]*0.5 dx = cos(the)*rad*H dy = sin(the)*rad*H if not isl: DM.new_triangle_from_surface_edge( he, H, dx*rad*H, dy*rad*H, minimum_length=MINIMUM_LENGTH, maximum_length=MAXIMUM_LENGTH, merge_ragged_edge=1 ) else: DM.throw_seed_triangle( he, H, dx*rad*H, dy*rad*H, NEARL*0.5, the ) DM.optimize_edges( SPLIT_LIMIT, FLIP_LIMIT ) tsum += time() - t1 print_stats(render.num_img, tsum, DM) show(render, DM) tsum = 0
def main(): from differentialMesh import DifferentialMesh from render.render import Render from time import time from modules.helpers import print_stats from numpy import array # from modules.utils import get_exporter # exporter = get_exporter(NMAX) DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS) DM.new_faces_in_ngon(MID, MID, H, 6, 0.0) render = Render(SIZE, BACK, FRONT) render.set_line_width(LINEWIDTH) # st = named_sub_timers() tsum = 0 for i in xrange(10000000): t1 = time() for _ in xrange(STEPS_ITT): # st.start() DM.optimize_position( ATTRACT_STP, REJECT_STP, TRIANGLE_STP, ALPHA, DIMINISH, -1 ) # st.t('opt') henum = DM.get_henum() # st.t('rnd') surface_edges = array( [DM.is_surface_edge(e)>0 for e in range(henum)], 'bool').nonzero()[0] # st.t('surf') rnd = random(size=len(surface_edges)*2) the = (1.-2*rnd[::2])*pi rad = rnd[1::2]*0.5*H dx = cos(the)*rad dy = sin(the)*rad # st.t('rnd2') DM.new_triangles_from_surface_edges( surface_edges, len(surface_edges), H, dx, dy, MINIMUM_LENGTH, MAXIMUM_LENGTH, 1 ) # st.t('tri') # st.start() DM.optimize_edges( SPLIT_LIMIT, FLIP_LIMIT ) # st.t('opte') tsum += time() - t1 print_stats(i*STEPS_ITT, tsum, DM) ## export png show(render, DM) ## export obj # exporter( # DM, # { # 'procs': PROCS, # 'nearl': NEARL, # 'farl': FARL, # 'prefix': PREFIX, # 'reject_stp': 0, # 'attract_stp': 0, # 'triangle_stp': 0, # 'size': SIZE # }, # i*STEPS_ITT # ) tsum = 0
def main(): from differentialMesh import DifferentialMesh from render.render import Render from time import time from modules.helpers import print_stats from numpy.random import randint, random from numpy import unique DM = DifferentialMesh(NMAX, 2 * FARL, NEARL, FARL, PROCS) DM.new_faces_in_ngon(MID, MID, H, 6, 0.0) render = Render(SIZE, BACK, FRONT) render.set_line_width(LINEWIDTH) tsum = 0 for i in xrange(10000): t1 = time() for _ in xrange(STEPS_ITT): DM.optimize_position(ATTRACT_STP, REJECT_STP, TRIANGLE_STP, ALPHA, DIMINISH, -1) henum = DM.get_henum() edges = unique(randint(henum, size=(henum))) en = len(edges) rnd = 1 - 2 * random(size=en * 2) make_island = random(size=en) > 0.85 for i, (he, isl) in enumerate(zip(edges, make_island)): if DM.is_surface_edge(he) > 0: the = pi * rnd[2 * i] rad = rnd[2 * i + 1] * 0.5 dx = cos(the) * rad * H dy = sin(the) * rad * H if not isl: DM.new_triangle_from_surface_edge( he, H, dx * rad * H, dy * rad * H, minimum_length=MINIMUM_LENGTH, maximum_length=MAXIMUM_LENGTH, merge_ragged_edge=1) else: DM.throw_seed_triangle(he, H, dx * rad * H, dy * rad * H, NEARL * 0.5, the) DM.optimize_edges(SPLIT_LIMIT, FLIP_LIMIT) tsum += time() - t1 print_stats(render.num_img, tsum, DM) show(render, DM) tsum = 0
def main(): from differentialMesh import DifferentialMesh from render.render import Render from time import time from modules.helpers import print_stats from numpy import array # from modules.utils import get_exporter # exporter = get_exporter(NMAX) DM = DifferentialMesh(NMAX, 2 * FARL, NEARL, FARL, PROCS) DM.new_faces_in_ngon(MID, MID, H, 6, 0.0) render = Render(SIZE, BACK, FRONT) render.set_line_width(LINEWIDTH) # st = named_sub_timers() tsum = 0 for i in xrange(10000000): t1 = time() for _ in xrange(STEPS_ITT): # st.start() DM.optimize_position(ATTRACT_STP, REJECT_STP, TRIANGLE_STP, ALPHA, DIMINISH, -1) # st.t('opt') henum = DM.get_henum() # st.t('rnd') surface_edges = array( [DM.is_surface_edge(e) > 0 for e in range(henum)], 'bool').nonzero()[0] # st.t('surf') rnd = random(size=len(surface_edges) * 2) the = (1. - 2 * rnd[::2]) * pi rad = rnd[1::2] * 0.5 * H dx = cos(the) * rad dy = sin(the) * rad # st.t('rnd2') DM.new_triangles_from_surface_edges(surface_edges, len(surface_edges), H, dx, dy, MINIMUM_LENGTH, MAXIMUM_LENGTH, 1) # st.t('tri') # st.start() DM.optimize_edges(SPLIT_LIMIT, FLIP_LIMIT) # st.t('opte') tsum += time() - t1 print_stats(i * STEPS_ITT, tsum, DM) ## export png show(render, DM) ## export obj # exporter( # DM, # { # 'procs': PROCS, # 'nearl': NEARL, # 'farl': FARL, # 'prefix': PREFIX, # 'reject_stp': 0, # 'attract_stp': 0, # 'triangle_stp': 0, # 'size': SIZE # }, # i*STEPS_ITT # ) tsum = 0