new Clipper()
An interface to the ClipperLib polygon clipping library.
Classes
Members
-
:ClipperLib.PolyFillType
defaultFill <static>
-
Stores a default fill type to use, initially
ClipperLib.PolyFillType.pftNonZero.Type
- ClipperLib.PolyFillType
Methods
-
copyClipPathToPolyMesh(mesh, path [, Z]) <static>
-
Adds a clipper path in the XY plane as an outline to the given mesh.
Parameters:
Name Type Argument Description meshPD.PolyMesh The mesh to add the path to.
pathArray The 2D Clipper path or paths to add.
Znumber <optional>
The height of the path ijn the Z axis, defaults to zero.
-
createPathFromPointsByAxis(vertices [, axis] [, clipPath]) <static>
-
Converts a polyline contour to a 2D
ClipperLib.Patharray.As ClipperLib works with 2D {X,Y} objects, the 3D polyline contour must be translated into a 2D cartesian plane. This method uses the given cartesian axis. If no axis is given, the X and Y components of the 3D points are used.
Parameters:
Name Type Argument Description verticesArray.<PD.Point> An array of 3D points.
axisPD.AXIS <optional>
An optional axis to project 2D points onto, defaults to Z axis.
clipPathArray.<PD.ClipPt2D> <optional>
An optional path to receive the 2D clip points.
Returns:
Returns the given path array filled with {X,Y} ClipperLib points, of a newly created array.
- Type
- Array
-
createPathFromVectorArraysByAxis(vertices [, axis] [, clipPath]) <static>
-
Converts a contour of [x,y,z] vector arrays to a 2D
ClipperLib.Patharray.As ClipperLib works with 2D {X,Y} objects, the 3D polyline must be translated into a 2D cartesian plane. This method uses the given cartesian axis. If no axis is given, the X and Y components of the 3D [x,y,z] vector arrays are used.
Parameters:
Name Type Argument Description verticesArray.<Array.<number>> An array of 3D [x,y,z] vector arrays.
axisPD.AXIS <optional>
An optional axis to project 2D points onto, defaults to Z axis.
clipPathArray.<PD.ClipPt2D> <optional>
An optional path to receive the 2D clip points.
Returns:
Returns the given path array filled with {X,Y} ClipperLib points, of a newly created array.
- Type
- Array
-
createPathWithOrientation(vertices [, axis] [, clipPath]) <static>
-
Converts an array of points to a 2D
ClipperLib.Pathand returns the orientation.This method uses the signed area to determine the orientation of the path.
Parameters:
Name Type Argument Description verticesArray.<PD.Point> An array of 3D
PD.Pointobjects.axisPD.AXIS <optional>
The cartesian axis to use when converting, defaults to the Z axis.
clipPathArray.<PD.ClipPt2D> <optional>
The array to receive the clipper points.
Returns:
Returns the orientation of the clipper path.
- Type
- boolean
-
dispose() <static>
-
Releases the shared polygon clipper and offsetter so they can be garbage collected.
Only call this method if you are sure your application has finished using polygon clipping and offsetting for some time. It is safe to reuse the same clipper object any number of times, so you should avoid disposing and recreating the the clipper over and over again. If you call the
startClip()method after calling this method, a new clipper will be generated and cached. -
intersectShapes(clipShape, subjShape, fill) <static>
-
Computes the intersection of two shapes.
Parameters:
Name Type Description clipShapePD.Clipper.Shape | Array The clip shape or array.
subjShapePD.Clipper.Shape | Array The subject shape or array.
fillClipperLib.PolyFillType The fill type to use, defaults to
PD.Clipper.defaultFill.Returns:
Returns resulting the intersection paths.
- Type
- Array
-
reusePathContour(clippath, contour) <static>
-
Converts a polyline contour and attempts to reuse a 2D
ClipperLib.Path.As ClipperLib works with 2D {X,Y} objects, the 3D polyline contour must be translated into a 2D cartesian plane. This method uses the given cartesian axis. If no axis is given, the X and Y components of the 3D points are used.
Parameters:
Name Type Description clippathArray The reusable previously generated ClipperLib Path.
contourArray The contour as an array of 3D points.
Returns:
Returns an array of one or more ClipperLib paths, each containing {X,Y} Clipper points.
- Type
- Array
-
startClip() <static>
-
Resets and retrieves the shared polygon clipping tool.
This method is typically the first method called when performing polygon clipping operations. It creates a shared
ClipperLib.Clipperinstance that can be used to add, subtract or intersect multiple 2D polygons. Only a single instance is ever created and is cleared and reused in all subsequent calls.Returns:
Returns the polygon clipping calculator.
- Type
- ClipperLib.Clipper
-
startOffset( [miterLimit] [, arcTolerance]) <static>
-
Resets and retrieves the shared polygon offset tool.
This method is typically the first method called when performing polygon offset operations. It creates a shared
ClipperLib.ClipperOffsetinstance that can be used to offset/inset multiple 2D polygons. Only a single instance is ever created and is cleared and reused in all subsequent calls.Parameters:
Name Type Argument Description miterLimitnumber <optional>
Sets the limit for paths where JoinType is jtMiter, defaults to 2,
arcTolerancenumber <optional>
Sets the rounding increment for paths where JoinType is jtRound or when EndType is etOpenRound, defaults to 1.
Returns:
Returns the polygon offset calculator.
- Type
- ClipperLib.ClipperOffset
-
subtractShapes(clipShape, subjShape, fill) <static>
-
Subtracts the clip shape from the subject shape.
Parameters:
Name Type Description clipShapePD.Clipper.Shape | Array The clip shape or array.
subjShapePD.Clipper.Shape | Array The subject shape or array.
fillClipperLib.PolyFillType The fill type to use, defaults to
PD.Clipper.defaultFill.Returns:
Returns resulting the intersection paths.
- Type
- Array
-
toPolygonContoursByAxis(paths, shell [, axis] [, W]) <static>
-
Converts a 2D ClipperLib path to 3D contours suitable for polylines/facets.
As ClipperLib works with 2D {X,Y} objects, each 2D point must be projected into 3D from the 2D cartesian plane. This method uses a straight cartesian projection in the given axis at the given offset. If no axis is given, the Z-axis (XY plane) is used.
Parameters:
Name Type Argument Description pathsArray | PolyTree An array of ClipperLib paths, or a single path.
shellPD.Shell The shell to reuse 3D vertices from.
axisPD.AXIS <optional>
An optional axis in which to project 2D point, defaults to Z-axis.
Wnumber <optional>
An optional position of the path in the given axis, defaults to zero.
Returns:
Returns an array of one or more closed contours, each containing three or more
THREE.Vector3points.- Type
- Array
-
toPolygonContoursByPlaneNormal(path, plane [, shell]) <static>
-
Converts a 2D ClipperLib path to 3D contours suitable for polylines/facets.
As ClipperLib works with 2D {X,Y} objects, each 2D point must be projected from the 2D XY plane onto the given plane. This method uses a quaternion to rotate from the Z-axis to the plane normal.
This means that, unless the plane is normal to one of the three cartesian axis, its shape in plan view or elevation will be skewed by the angle of the plane. To project onto a plane whilst maintaining its shape in one of the cartesian axis, use the
toPolygonContoursByPlaneAxis()method instead.Parameters:
Name Type Argument Description pathArray An array of two or more ClipperPath points.
planeTHREE.Plane The plane to project the ClipperPath points back onto.
shellPD.Shell <optional>
An optional shell to reuse vertices and facets from.
Returns:
Returns an array of one or more closed contours, each containing three or more
THREE.Vector3points.- Type
- Array
-
toPolygonContoursXY(path, shell [, Z]) <static>
-
Converts a 2D ClipperLib path to 3D contours suitable for polylines/facets.
As ClipperLib works with 2D {X,Y} objects, each 2D point must be projected into 3D from the 2D cartesian plane. This method uses a straight cartesian projection in the given axis at the given offset. If no axis is given, the Z-axis (XY plane) is used.
Parameters:
Name Type Argument Description pathArray An array of two or more ClipperPath points.
shellPD.Shell The shell to reuse 3D vertices from.
Znumber <optional>
An optional position of the path in the Z axis, defaults to zero.
Returns:
Returns an array of one or more closed contours, each containing three or more
THREE.Vector3points.- Type
- Array
-
toPolygonsByPlaneAxis(paths, plane, axis [, shell]) <static>
-
Converts a 2D ClipperLib path to 3D contours suitable for polylines/facets.
As ClipperLib works with 2D {X,Y} objects, each 2D point must be projected into 3D from the 2D XY plane. This method uses the plane equation specified to determine the most suitable cartesian axis to use. You can optionally specify the axis in which to project the points onto the plane, but using the plane equation itself is usually best.
In order to maintain axial positions and dimensions, each point is projected onto the plane along the selected axis rather than using the plane's normal. This is so that, for example, a circular arc created in plan view but projected onto a sloped plane still remains a circular arc when viewed in plane. Similarly, an arched window drawn in elevation should remain an arched window when viewed from the same elevation.
To project directly onto a plane, use the
toPolygonContoursByPlaneNormal()method instead.Parameters:
Name Type Argument Description pathsArray | PolyTree An array of ClipperLib paths, or a single path.
planeTHREE.Plane The plane to project 3D points back onto.
axisPD.AXIS The axis to use, default is to compute from plane.
shellPD.Shell <optional>
An optional shell to reuse vertices and facets from.
Returns:
Returns an array of one or more polygons.
- Type
- Array
-
unionShapes(shapes, fill) <static>
-
Unions a set of shapes together.
Parameters:
Name Type Description shapesArray.<PD.Clipper.Shape> An array of shapes to union together.
fillClipperLib.PolyFillType The fill type to use, defaults to
PD.Clipper.defaultFill.Returns:
Returns resulting the unioned paths.
- Type
- Array