Class ClipperOffset
Geometric offsetting refers to the process of creating parallel curves that are offset a specified distance from their primary curves.
Library users will rarely need to access this class directly since it's
generally easier to use the
inflatePaths() function for polygon offsetting.
Notes:
- When offsetting closed paths (polygons), a positive offset delta specifies how much outer polygon contours will expand and inner "hole" contours will contract. The converse occurs with negative deltas.
- You cannot offset open paths (polylines) with negative deltas because it's not possible to contract/shrink open paths.
- When offsetting, it's important not to confuse EndType.Polygon with EndType.Joined. EndType.Polygon should be used when offsetting polygons (closed paths). EndType.Joined should be used with polylines (open paths).
- Offsetting should not be performed on intersecting closed paths, as doing so will almost always produce undesirable results. Intersections must be removed before offsetting, which can be achieved through a Union clipping operation.
- It is OK to offset self-intersecting open paths (polylines), though the intersecting (overlapping) regions will be flattened in the solution polygon.
- When offsetting closed paths (polygons), the winding direction of paths in the solution will match that of the paths prior to offsetting. Polygons with hole regions should comply with NonZero filling.
- When offsetting open paths (polylines), the solutions will always have Positive orientation.
- Path order following offsetting very likely won't match path order prior to offsetting.
- While the ClipperOffset class itself won't accept paths with floating point coordinates, the InflatePaths function will accept paths with floating point coordinates.
- Redundant segments should be removed before offsetting (see
simplifyPaths()), and between offsetting operations too. These redundant segments not only slow down offsetting, but they can cause unexpected blemishes in offset solutions.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a ClipperOffset object, using default parameters.ClipperOffset(double miterLimit) ClipperOffset(double miterLimit, double arcTolerance) ClipperOffset(double miterLimit, double arcTolerance, boolean preserveCollinear) ClipperOffset(double miterLimit, double arcTolerance, boolean preserveCollinear, boolean reverseSolution) Creates a ClipperOffset object, using the supplied parameters. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidfinal voidfinal voidclear()final voidvoidexecute(double delta, PolyTree64 solutionTree) voidexecute(DeltaCallback64 deltaCallback64, Paths64 solution) final doublefinal DeltaCallback64final booleanfinal doublefinal booleanfinal booleanfinal voidsetArcTolerance(double value) final voidsetDeltaCallBack64(DeltaCallback64 callback) final voidsetMergeGroups(boolean value) final voidsetMiterLimit(double value) final voidsetPreserveCollinear(boolean value) final voidsetReverseSolution(boolean value)
-
Constructor Details
-
ClipperOffset
public ClipperOffset(double miterLimit, double arcTolerance, boolean preserveCollinear) - See Also:
-
ClipperOffset
public ClipperOffset(double miterLimit, double arcTolerance) - See Also:
-
ClipperOffset
public ClipperOffset(double miterLimit) - See Also:
-
ClipperOffset
public ClipperOffset()Creates a ClipperOffset object, using default parameters.- See Also:
-
ClipperOffset
public ClipperOffset(double miterLimit, double arcTolerance, boolean preserveCollinear, boolean reverseSolution) Creates a ClipperOffset object, using the supplied parameters.- Parameters:
miterLimit- This property sets the maximum distance in multiples of groupDelta that vertices can be offset from their original positions before squaring is applied. (Squaring truncates a miter by 'cutting it off' at 1 × groupDelta distance from the original vertex.)The default value for
miterLimitis 2 (i.e. twice groupDelta). This is also the smallest MiterLimit that's allowed. If mitering was unrestricted (ie without any squaring), then offsets at very acute angles would generate unacceptably long 'spikes'.arcTolerance- Since flattened paths can never perfectly represent arcs (see Trigonometry), this property specifies a maximum acceptable imperfection for rounded curves during offsetting.It's important to make arcTolerance a sensible fraction of the offset groupDelta (arc radius). Large tolerances relative to the offset groupDelta will produce poor arc approximations but, just as importantly, very small tolerances will slow offsetting performance without noticeably improving curve quality.
arcTolerance is only relevant when offsetting with
JoinType.Roundand / orEndType.Round(see {addPath()andaddPaths(). The default arcTolerance is 0.0, which enables automatic scaling (offset radius / 500).preserveCollinear- When adjacent edges are collinear in closed path solutions, the common vertex can safely be removed to simplify the solution without altering path shape. However, because some users prefer to retain these common vertices, this feature is optional. Nevertheless, when adjacent edges in solutions are collinear and also create a 'spike' by overlapping, the vertex creating the spike will be removed irrespective of the PreserveCollinear setting. This property is false by default.reverseSolution- reverses the solution's orientation
-
-
Method Details
-
clear
public final void clear() -
addPath
-
addPaths
-
execute
-
execute
-
execute
-
getArcTolerance
public final double getArcTolerance() -
setArcTolerance
public final void setArcTolerance(double value) -
getMergeGroups
public final boolean getMergeGroups() -
setMergeGroups
public final void setMergeGroups(boolean value) -
getMiterLimit
public final double getMiterLimit() -
setMiterLimit
public final void setMiterLimit(double value) -
getPreserveCollinear
public final boolean getPreserveCollinear() -
setPreserveCollinear
public final void setPreserveCollinear(boolean value) -
getReverseSolution
public final boolean getReverseSolution() -
setReverseSolution
public final void setReverseSolution(boolean value) -
setDeltaCallBack64
-
getDeltaCallBack64
-