Exemple #1
0
    def mesh(self, leaf_key, L_shape, Lw_shape, length, s_base, s_top, incline=1, flipx = False):
        """ Compute mesh for a leaf element.
            - shape is a x,y,s,r tuple descriibing leaf shape
            - L_shape is the length of the scaled shape
            - Lw_shape is the width of the scaled shape
            - length is the total visible length to be meshed
            - s_base and s_top are relative proportion (on length) of the element to represent
        """
        shape = self.get_leaf(leaf_key)

        shape = incline_leaf(shape, incline)
        if flipx:
            shape = (-shape[0],)+shape[1:] # to position leaves along tiller emitted
        leaf_mesh = fitting.mesh4(shape, L_shape, length, s_base, s_top, Lw_shape, twist=self.twist)
        if leaf_mesh:
            pts, ind = leaf_mesh
            if len(ind) < 1:
                #raise  AdelError('ERROR less than 1 triangles') # mesh4 filters triangle < 1e-6
                mesh = None
            else:
                mesh = fitting.plantgl_shape(pts, ind)
        else:
            if length > 0:
                print 'ERROR No mesh', s_base, s_top, length
                pass
            mesh = None

        return mesh
Exemple #2
0
def leaf_to_mesh_new(leaf, lmax, l, rmax, twist=False, nb_twist=1.,
    nb_waves=8):
    pts, ind = fitting._mesh(leaf, lmax, l, rmax, 
                            functor=fitting.leaf_to_mesh_new, 
                            twist=twist, nb_twist=nb_twist, nb_waves=nb_waves)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
    def mesh(self, leaf_key, L_shape, Lw_shape, length, s_base, s_top, incline=1, flipx = False):
        """ Compute mesh for a leaf element.
            - shape is a x,y,s,r tuple descriibing leaf shape
            - L_shape is the length of the scaled shape
            - Lw_shape is the width of the scaled shape
            - length is the total visible length to be meshed
            - s_base and s_top are relative proportion (on length) of the element to represent
        """
        shape = self.get_leaf(leaf_key)

        shape = incline_leaf(shape, incline)
        if flipx:
            shape = (-shape[0],)+shape[1:] # to position leaves along tiller emitted
        leaf_mesh = fitting.mesh4(shape, L_shape, length, s_base, s_top, Lw_shape, twist=self.twist)
        if leaf_mesh:
            pts, ind = leaf_mesh
            if len(ind) < 1:
                #raise  AdelError('ERROR less than 1 triangles') # mesh4 filters triangle < 1e-6
                mesh = None
            else:
                mesh = fitting.plantgl_shape(pts, ind)
        else:
            if length > 0:
                print 'ERROR No mesh', s_base, s_top, length
                pass
            mesh = None

        return mesh
Exemple #4
0
def leaf_to_mesh_cicloid_twist(leaf,
                               lmax,
                               l,
                               rmax,
                               twist=True,
                               nb_twist=2,
                               nb_waves=8):
    pts, ind = fitting.mesh3(leaf, lmax, l, rmax)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
Exemple #5
0
def test7(leaf=leaf, scene=None):

    if scene is None:
        scene = pgl.Scene()
        Viewer.display(scene)

    x, y, s, r = leaf
    spline_leaf, leaf_surface = fitting.fit_leaf(x, y, s, r)
    pts, ind = fitting.mesh(spline_leaf, 30, 7, 7, 1)
    fitting.write_smf('leaf_full.smf', pts, ind)
    Viewer.display(fitting.plantgl_shape(pts, ind))
Exemple #6
0
def leaf_to_mesh_new(leaf,
                     lmax,
                     l,
                     rmax,
                     twist=False,
                     nb_twist=1.,
                     nb_waves=8):
    pts, ind = fitting._mesh(leaf,
                             lmax,
                             l,
                             rmax,
                             functor=fitting.leaf_to_mesh_new,
                             twist=twist,
                             nb_twist=nb_twist,
                             nb_waves=nb_waves)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
Exemple #7
0
def test8(leaf=leaf, scene=None):
    global translation, zt
    if scene is None:
        scene = pgl.Scene()
        Viewer.display(scene)

    x, y, s, r = leaf
    leaf_new, leaf_surface = fitting.fit2(x, y, s, r)

    pts, ind = fitting.mesh2(leaf_new, 7, 7, 1)
    #pts2, ind2 = fitting.qslim(13, pts, ind)
    #mesh = fitting.plantgl_shape(pts2, ind2)

    #sc=pgl.SurfComputer(pgl.Discretizer())
    #mesh.apply(sc)
    #scale_z = leaf_surface*7 / (sc.surface)
    #mesh_final = mesh.transform(pgl.Scaling((1,1,scale_z)))
    #mesh_final = mesh
    scene += pgl.Translated(translation, fitting.plantgl_shape(pts, ind))
    #scene += pgl.Translated(translation+(0,yt/3.,0), mesh_final)

    Viewer.update()
Exemple #8
0
def leaf_to_mesh(leaf, lmax, l, rmax, antisens):
    pts, ind = fitting.mesh3(leaf, lmax, l, rmax, antisens)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
Exemple #9
0
def leaf_element(leaf, lmax, l, s_base, s_top, rmax):
    pts, ind = fitting.mesh4(leaf, lmax, l, s_base, s_top, rmax)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
Exemple #10
0
def leaf_to_mesh(leaf, lmax, l, rmax, antisens):
    pts, ind = fitting.mesh3(leaf, lmax, l, rmax, antisens)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
Exemple #11
0
def leaf_element(leaf, lmax, l, s_base, s_top,  rmax):
    pts, ind = fitting.mesh4(leaf, lmax, l, s_base, s_top, rmax)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh
Exemple #12
0
def leaf_to_mesh_cicloid_twist(leaf, lmax, l, rmax, 
                               twist=True, nb_twist=2, nb_waves=8):
    pts, ind = fitting.mesh3(leaf, lmax, l, rmax)
    mesh = fitting.plantgl_shape(pts, ind)
    return mesh