Platforms to show: All Mac Windows Linux Cross-Platform

Back to ClipperEngineMBS class.

ClipperEngineMBS.AddPath(path as ClipperPathMBS, PolyType as ClipperMBS.PolyType, Closed as Boolean) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Any number of subject and clip paths can be added to a clipping task, either individually via the AddPath() method, or as groups via the AddPaths() method, or even using both methods.

'Subject' paths may be either open (lines) or closed (polygons) or even a mixture of both, but 'clipping' paths must always be closed. Clipper allows polygons to clip both lines and other polygons, but doesn't allow lines to clip either lines or polygons.

With closed paths, orientation should conform with the filling rule that will be passed via Clippper's Execute method.

Path Coordinate range:
Path coordinates must be between ± &h3FFFFFFFFFFFFFFF (± 4.6e+18), otherwise a range error will be thrown when attempting to add the path to the Clipper object. If coordinates can be kept between ± 0x3FFFFFFF (± 1.0e+9), a modest increase in performance (approx. 15-20%) over the larger range can be achieved by avoiding large integer math.

Return Value:
The function will return false if the path is invalid for clipping. A path is invalid for clipping when:

  • it has less than 2 vertices
  • it has 2 vertices but is not an open path
  • the vertices are all co-linear and it is not an open path

Returns true on success.

See also:

ClipperEngineMBS.AddPath(path as ClipperPathMBS, PolyType as Integer, Closed as Boolean) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Any number of subject and clip paths can be added to a clipping task, either individually via the AddPath() method, or as groups via the AddPaths() method, or even using both methods.

See also:

ClipperEngineMBS.AddPaths(paths as ClipperPathsMBS, PolyType as ClipperMBS.PolyType, Closed as Boolean) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Any number of subject and clip paths can be added to a clipping task, either individually via the AddPath() method, or as groups via the AddPaths() method, or even using both methods.

'Subject' paths may be either open (lines) or closed (polygons) or even a mixture of both, but 'clipping' paths must always be closed. Clipper allows polygons to clip both lines and other polygons, but doesn't allow lines to clip either lines or polygons.

With closed paths, orientation should conform with the filling rule that will be passed via Clippper's Execute method.

Path Coordinate range:
Path coordinates must be between ± &h3FFFFFFFFFFFFFFF (± 4.6e+18), otherwise a range error will be thrown when attempting to add the path to the Clipper object. If coordinates can be kept between ± 0x3FFFFFFF (± 1.0e+9), a modest increase in performance (approx. 15-20%) over the larger range can be achieved by avoiding large integer math.


Return Value:
The function will return false if the path is invalid for clipping. A path is invalid for clipping when:

  • it has less than 2 vertices
  • it has 2 vertices but is not an open path
  • the vertices are all co-linear and it is not an open path

Returns true on success.

See also:

ClipperEngineMBS.AddPaths(paths as ClipperPathsMBS, PolyType as Integer, Closed as Boolean) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Any number of subject and clip paths can be added to a clipping task, either individually via the AddPath() method, or as groups via the AddPaths() method, or even using both methods.

See also:

ClipperEngineMBS.Clear

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The Clear method removes any existing subject and clip polygons allowing the Clipper object to be reused for clipping operations on different polygon sets.

ClipperEngineMBS.Constructor(initOptions as integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The Clipper constructor creates an instance of the Clipper class.

One or more InitOptions may be passed as a parameter to set the corresponding properties. (These properties can still be set or reset after construction.)

Options:

ReverseSolution1
StrictlySimple2
PreserveCollinear4

ClipperEngineMBS.Execute(clipType as Integer, byref solution as ClipperPathsMBS, fillType as Integer) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Executes the clipper engine.

Once subject and clip paths have been assigned (via AddPath and/or AddPaths), Execute can then perform the clipping operation (intersection, union, difference or XOR) specified by the clipType parameter.

The solution parameter can be either a Paths or PolyTree. The Paths is simpler than the PolyTree. Because of this it is quicker to populate and hence clipping performance is a little better (it's roughly 10% faster). However, the PolyTree class provides more information about the returned paths which may be important to users. Firstly, the PolyTree class preserves nested parent-child polygon relationships (ie outer polygons owning/containing holes and holes owning/containing other outer polygons etc). Also, only the PolyTree class can differentiate between open and closed paths since each PolyNode has an IsOpen property. (The Path structure has no member indicating whether it's open or closed.) For this reason, when open paths are passed to a Clipper object, the user must use a PolyTree object as the solution parameter, otherwise an exception will be raised.

When a PolyTree object is used in a clipping operation on open paths, two ancilliary functions have been provided to quickly separate out open and closed paths from the solution - ClipperMBS.OpenPathsFromPolyTree and ClipperMBS.ClosedPathsFromPolyTree. PolyTreeToPaths is also available to convert path data to a Paths structure (irrespective of whether they're open or closed).

There are several things to note about the solution paths returned:

  • they aren't in any specific order
  • they should never overlap or be self-intersecting (but see notes on rounding)
  • holes will be oriented opposite outer polygons
  • the solution fill type can be considered either EvenOdd or NonZero since it will comply with either filling rule
  • polygons may rarely share a common edge (though this is now very rare as of version 6)

The subjFillType and clipFillType parameters define the polygon fill rule to be applied to the polygons (ie closed paths) in the subject and clip paths respectively. (It's usual though obviously not essential that both sets of polygons use the same fill rule.)

Execute can be called multiple times without reassigning subject and clip polygons (ie when different clipping operations are required on the same polygon sets).

See also:

ClipperEngineMBS.GetBounds(byref left as integer, byref top as integer, byref right as integer, byref bottom as integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Clipper MBS Tools Plugin 18.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
This method returns the axis-aligned bounding rectangle of all polygons that have been added to the Clipper object.

This call is more efficient than querying all bounds properties.

The items on this page are in the following plugins: MBS Tools Plugin.


The biggest plugin in space...