Exemplo n.º 1
0
  def __make_sources(self, xx=0.5, yy=0.5, rad=None, domain='rect'):

    from scipy.spatial import cKDTree as kdt
    from scipy.spatial import Delaunay as triag
    from dddUtils.random import darts
    from dddUtils.random import darts_rect

    if rad is None:
      rad = self.init_rad

    if domain=='circ':
      sources = darts(
        self.init_num,
        xx,
        yy,
        self.init_rad,
        self.source_dst
      )
    elif domain=='rect':
      sources = darts_rect(
        self.init_num,
        xx,
        yy,
        2*rad,
        2*rad,
        self.source_dst
      )
    else:
      raise ValueError('domain must be "rect" or "circ".')
    tree = kdt(sources)
    self.sources = sources
    self.tree = tree
    self.tri = triag(
      self.sources,
      incremental=False,
      qhull_options='QJ Qc'
    )
    self.num_sources = len(self.sources)

    return len(sources)
Exemplo n.º 2
0
def main():

  from modules.leaf import LeafClosed as Leaf
  from render.render import Animate
  from numpy.random import random
  from numpy import array

  colors = {
    'back': [1,1,1,1],
    'front': [0,0,0,0.3],
    'vein': [0,0,0,0.9],
    'edge': [0,0,0,0.6],
    'cyan': [0,0.6,0.6,0.3],
    'red': [0.7,0.0,0.0,0.8],
    'blue': [0.0,0.0,0.7,0.8],
    'light': [0,0,0,0.2],
  }

  threads = 256

  render_steps = 10
  export_steps = 10

  size = 512*2
  one = 1.0/size

  node_rad = 1*one

  area_rad = 15*node_rad
  stp = node_rad*2
  kill_rad = 2*stp
  sources_dst = 2*kill_rad

  init_num_sources = 3

  # init_num_sources = 4
  # init_veins = 0.2+0.6*random((init_num_sources,2))
  init_veins = array([[0.5, 0.5]])

  init_num_sources = 100000

  # from dddUtils.random import darts
  # init_sources = darts(init_num_sources, 0.5, 0.5, 0.45, sources_rad)
  from dddUtils.random import darts_rect
  init_sources = darts_rect(init_num_sources, 0.5, 0.5, 0.95, 0.95, sources_dst)

  L = Leaf(
    size,
    stp,
    init_sources,
    init_veins,
    area_rad,
    kill_rad,
    threads = threads
  )
  print('nz', L.nz)
  print('dens', L.sv_leap)

  wrap = get_wrap(
    L,
    colors,
    node_rad=node_rad,
    export_steps=export_steps,
    render_steps=render_steps
  )

  render = Animate(size, colors['back'], colors['front'], wrap)
  render.set_line_width(L.one*2)
  render.start()