pyg4ometry.pycgal

Submodules

Classes

Functions

do_intersect(csg1, csg2)

intersecting_meshes(csgList)

Package Contents

class pyg4ometry.pycgal.CSG
sm
classmethod fromPolygons(polygons, **kwargs)
toVerticesAndPolygons()
clone()
rotate(axisIn, angleDeg)
translate(disp)
scale(*args)
getNumberVertices()
getNumberPolys()
vertexCount()
polygonCount()
intersect(csg2)
union(csg2)
subtract(csg2)
inverse()
coplanarIntersection(csg)

Compute the coplanar surfaces between self and csg

classmethod cube(center=[0, 0, 0], radius=[1, 1, 1])

Construct an axis-aligned solid cuboid. Optional parameters are center and radius, which default to [0, 0, 0] and [1, 1, 1]. The radius can be specified using a single number or a list of three numbers, one for each axis.

Example code:

cube = CSG.cube(
  center=[0, 0, 0],
  radius=1
)
volume()
area()
minEdgeLength()
maxEdgeLength()
isNull()
isClosed()
isTriangleMesh()
isOutwardOriented()
doesSelfIntersect()
info()
loadOff(fileName)
writeOff(fileName)
pyg4ometry.pycgal.do_intersect(csg1, csg2)
pyg4ometry.pycgal.intersecting_meshes(csgList)
class pyg4ometry.pycgal.PolygonProcessing
classmethod windingNumber(pgon)

return the winding number of pgon :param pgon: list of points [[x1,y1], [x2,y2], … ] :type pgon: List[List[x1,y1], …] returns: Integer winding number

classmethod reversePolygon(pgon)

return reversed polygon :param pgon: list of points [[x1,y1], [x2,y2], … ] :type pgon: List[List[x1,y1], …] returns: List[List[x1,y1], …]

classmethod makePolygonFromList(pgon, type='')

Convert list of points [[x1,y1], [x2,y2], … ] to cgal Polygon_2

Parameters:
  • pgon (List[List[x,y], ..]) – list of points [[x1,y1], [x2,y2], … ]

  • type – Class of polygon (Polygon_2_EPICK, Polygon_2_EPECK, Partition_traits_2_Polygon_2_EPECK)

  • type – str

returns: Polygon_2

classmethod makeListFromPolygon(pgon)

Convert 2D polygon to list of points [[x1,y1], [x2,y2], … ]

Parameters:

pgon (Polygon_2_EPECK or Polygon_2_EPICK) – cgal Polygon_2 input

returns: [[x1,y1], [x2,y2], …]

classmethod decomposePolygon2d(pgon)

Decompose general 2D polygon (pgon) to convex 2D polygons

Parameters:

pgon (List(List[2])) – list of pgon points (which are lists) [[x1,y1], [x2,y2], …]

returns: List of polgons [pgon1, pgon2, …]

classmethod decomposePolygon2dWithHoles(pgonOuter, pgonHoles)

Decompose general 2D polygon with holes (pgon) to convex 2D polygons

Parameters:
  • pgonOuter – list of pgon points (which are lists) [[x1,y1], [x2,y2], …]

  • pgonHoles – List of polgons [pgon1, pgon2, …]

returns: List of polgons [pgon1, pgon2, …]

classmethod triangulatePolygon2d(pgon)

Triangulate general 2D polygon

Parameters:

pgonOuter – list of pgon points (which are lists) [[x1,y1], [x2,y2], …]

returns: List of triangles [ [[x1,y1], [x2,y2], [x3,y3]], [[x1,y1], [x2,y2], [x3,y3]], …]

class pyg4ometry.pycgal.PolyhedronProcessing
classmethod surfaceMesh_to_Polyhedron(sm)
classmethod nefPolyhedron_to_convexPolyhedra(np)
classmethod polyhedron_to_numpyArrayPlanes(p)