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
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
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
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
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