OffsetPolygons

Del.» function OffsetPolygons(const polys: TPolygons; const delta: double; JoinType: TJoinType = jtSquare; Limit: double = 0.0; AutoFix: boolean = true): TPolygons;

C++ » void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, double delta, JoinType jointype = jtSquare, double limit = 0.0, bool autoFix = true);

C#  » public static Polygons OffsetPolygons(Polygons polys, double delta, JoinType jointype = JoinType.jtSquare, double limit = 0.0, bool autoFix = true);


This function offsets the 'polys' polygons parameter by the 'delta' amount. Positive delta values expand outer polygons and contract inner 'hole' polygons. Negative deltas do the reverse.

(C++ only: The in_polys and out_polys parameters can reference the same object.)

Edge joins may be one of three jointypes - jtMiter, jtSquare or jtRound. (See the image below for examples.)



Just as with the OffsetPolyLines function, the meaning and use of the limit parameter depends on joinType:



The polygons passed to OffsetPolygons must not be self-intersecting and need to be oriented such that outer polygons have a true orientation and hole polygons have a false orientation. If the orientations of input polygons are incorrect, the function will return unexpected results. Likewise, 'duplicate vertices' (ie consecutive vertices with identical coordinates, including start and end vertices) cause problems with the offset algorithm.

The autoFix parameter when true will force the function to check for and fix incorrect polygon orientations and remove duplicate vertices. However, if orientations are known to be correct and there's no likelihood of duplicate vertices, then it's advisable to set autoFix to false since 'auto-fixing' is computationally expensive.

Offsetting self-intersecting polygons can be achieved by first calling SimplyPolygons.


See Also

Overview, OffsetPolyLines, Orientation, SimplifyPolygons, JoinType, Polygon