コード例 #1
0
def main():

  from differentialMesh import DifferentialMesh
  from iutils.render import Animate
  from modules.helpers import darts


  DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS)

  DM.new_faces_in_ngon(MID,MID, H, 3, 0)
  DM.set_edge_intensity(1, 1)

  sources = [(x,y) for x,y in darts(NUM_SOURCES, MID, MID, 0.40, 3*NEARL)]
  DM.initialize_sources(sources, NEARL)

  def wrap(render):

    res = steps(DM)
    show(render, DM, sources)

    return res

  render = Animate(SIZE, BACK, FRONT, wrap)
  render.set_line_width(LINEWIDTH)
  render.start()
コード例 #2
0
def main():

    from differentialMesh import DifferentialMesh
    from iutils.render import Animate
    from modules.helpers import darts

    DM = DifferentialMesh(NMAX, 2 * FARL, NEARL, FARL, PROCS)

    DM.new_faces_in_ngon(MID, MID, H, 3, 0)
    DM.set_edge_intensity(1, 1)

    sources = [(x, y)
               for x, y in darts(NUM_SOURCES, MID, MID, 0.40, 3 * NEARL)]
    DM.initialize_sources(sources, NEARL)

    def wrap(render):

        res = steps(DM)
        show(render, DM, sources)

        return res

    render = Animate(SIZE, BACK, FRONT, wrap)
    render.set_line_width(LINEWIDTH)
    render.start()
コード例 #3
0
def main():

  from time import time
  from render.render import Render
  from differentialMesh import DifferentialMesh
  from modules.helpers import darts
  from modules.helpers import print_stats
  from numpy import array


  DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS)

  DM.new_faces_in_ngon(MID,MID, H, 7, 0)
  DM.set_edge_intensity(1, 1)

  sources = [(x,y) for x,y in darts(NUM_SOURCES, MID, MID, 0.43, 0.002)]
  DM.initialize_sources(sources, NEARL)

  render = Render(SIZE, BACK, FRONT)


  for i in xrange(1000000):

    t1 = time()
    for _ in xrange(STEPS_ITT):

      DM.find_nearby_sources()

      henum = DM.get_henum()

      surface_edges = array(
        [DM.is_surface_edge(e)>0 and r<DM.get_edge_intensity(e)
        for e,r in enumerate(random(size=henum))],
        'bool').nonzero()[0]

      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

      DM.new_triangles_from_surface_edges(
        surface_edges,
        len(surface_edges),
        H,
        dx,
        dy,
        MINIMUM_LENGTH,
        MAXIMUM_LENGTH,
        1
      )

      DM.optimize_position(
        ATTRACT_STP,
        REJECT_STP,
        TRIANGLE_STP,
        ALPHA,
        DIMINISH,
        -1
      )

      henum = DM.get_henum()

      DM.optimize_edges(
        SPLIT_LIMIT,
        FLIP_LIMIT
      )

      if DM.safe_vertex_positions(3*H)<0:

        show_circles(render, DM, sources)
        print('vertices reached the boundary. stopping.')
        return

    show_circles(render, DM, sources)

    t2 = time()
    print_stats(i*STEPS_ITT, t2-t1, DM)
コード例 #4
0
def main():

  from time import time
  from iutils.render import Render
  from differentialMesh import DifferentialMesh
  from modules.helpers import darts
  from modules.helpers import print_stats
  from numpy import array


  DM = DifferentialMesh(NMAX, 2*FARL, NEARL, FARL, PROCS)

  DM.new_faces_in_ngon(MID,MID, H, 7, 0)
  DM.set_edge_intensity(1, 1)

  sources = [(x,y) for x,y in darts(NUM_SOURCES, MID, MID, 0.43, 0.002)]
  DM.initialize_sources(sources, NEARL)

  render = Render(SIZE, BACK, FRONT)


  for i in range(1000000):

    t1 = time()
    for _ in range(STEPS_ITT):

      DM.find_nearby_sources()

      henum = DM.get_henum()

      surface_edges = array(
        [DM.is_surface_edge(e)>0 and r<DM.get_edge_intensity(e)
        for e,r in enumerate(random(size=henum))],
        'bool').nonzero()[0]

      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

      DM.new_triangles_from_surface_edges(
        surface_edges,
        len(surface_edges),
        H,
        dx,
        dy,
        MINIMUM_LENGTH,
        MAXIMUM_LENGTH,
        1
      )

      DM.optimize_position(
        ATTRACT_STP,
        REJECT_STP,
        TRIANGLE_STP,
        ALPHA,
        DIMINISH,
        -1
      )

      henum = DM.get_henum()

      DM.optimize_edges(
        SPLIT_LIMIT,
        FLIP_LIMIT
      )

      if DM.safe_vertex_positions(3*H)<0:

        show_circles(render, DM, sources)
        print('vertices reached the boundary. stopping.')
        return

    show_circles(render, DM, sources)

    t2 = time()
    print_stats(i*STEPS_ITT, t2-t1, DM)