Exemplo n.º 1
0
def cvxHull(shape_list_or_scene, color=Green):
    """create a convex hull enveloppe

    :param Scene scene: a scene with shapes to process
    :param color color: a PGL Material to place on the convex hull
    :return: a PGL shape 

    ::

        scene = Scene()
        scene += shapes
        hull = cvxhull(scene, color=Material(0,255,0))
        scene += hull
        Viewer.display(hull)

    .. figure:: convex.png
        :width: 50%

        Example of convex hull enveloppe (of the leaves) added on top of a tree generated with pruning.lpy

    """

    group = pgl.Group([sh.geometry for sh in shape_list_or_scene])
    tglSet = pgl.fit('convexhull', group)
    hull = pgl.Shape(tglSet, color)
    return hull
Exemplo n.º 2
0
def oneScHullScene(scgroup,pointsbyshape):#aka hullscene
  """cree les cvxHull des groupes de scgroup"""
  sc = pgl.Scene()
  m = color(20,150,20, trans=True)
  for ids in scgroup:
    pts = ptUnion(pointsbyshape,ids)
    sc += pgl.Shape(pgl.fit('convexhull',pgl.Polyline(pts)),m)
  return sc
Exemplo n.º 3
0
def computeBoundingShape(scene, shape='bellipsoid'):
    """
  Compute a bounding volume for the given `scene`.
  The `shape` of this volume can be one of these keyword 
  Note that the `pgl.fit` could deliver different shapes by using
  one of the following keyword instead of 'ellipsoid':
  EXTRUDEDHULL ; ASYMMETRICHULL ; EXTRUSION ; SPHERE ; ASPHERE ; BSPHERE
  CYLINDER ; ACYLINDER ; BCYLINDER ; ELLIPSOID ; BELLIPSOID2 ; AELLIPSOID
  BELLIPSOID ; AALIGNEDBOX ; BALIGNEDBOX ; BOX ; ABOX ; BBOX ; CONVEXHULL
  """

    gr = fruti.pgl.Group([sh.geometry for sh in scene])
    tglset = pgl.fit(shape, gr)
    #hull = pgl.Shape( tglSet, __Green )
    return tglset
Exemplo n.º 4
0
def ptsHull( ptsList, id = 0 ):
  m = color( 20,150,20,trans=True )
  shape = pgl.Shape(pgl.fit('convexhull',pgl.Polyline(ptsList)),m)
  shape.id = id
  return shape
Exemplo n.º 5
0
def cvxHull( scene ):
  #work with scene or shape list
  group = pgl.Group( [ sh.geometry for sh in scene ] )
  tglSet = pgl.fit( 'convexhull', group )
  hull = pgl.Shape( tglSet, __Green )
  return hull