+ Overloaded MinkowskiSum function to accommodate multi-contour paths.
+
+
+
+
+
Modified:
+
+ Documentation updated.
+
+
+
+
+
+
+
+
v6.1.2 (15 December 2013)
+
+
+
+
Bugfix:
+
+Fixed broken C++ header file.
+
+
+
+
+
Modified:
+
+Minor improvement to joining polygons.
+
+
+
+
+
+
+
+
v6.1.1 (13 December 2013)
+
+
+
+
Bugfix:
+
+Fixed a couple of bugs affecting open paths that could raise unhandled exceptions.
+
+
+
+
+
+
+
+
v6.1.0 (2 December 2013)
+
+
+
+
Deleted:
+
Previously deprecated code has been removed.
+
+
+
+
Modified:
+
+The OffsetPaths function is now deprecated as it has been replaced by the ClipperOffset class which is much more flexible.
+
+
+
+
+
Bugfix:
+
+Several minor bugs have been fixed including occasionally an incorrect nesting within the PolyTree structure.
+
+
+
+
+
+
+
+
v6.0.0 (30 October 2013)
+
+
+
Ver 6 is a MAJOR update that adds support for open path clipping.
+
+
+
+
+
+
Added:
+
+Open path (polyline) clipping. A new 'Curves' demo application showcases this (see the 'Curves' directory).
+
+
+
+
+
+
+
+
Update:
+
+Major improvement in the merging of shared/collinear edges in clip solutions (see Execute).
+
+
+
+
+
+
+
+
Added:
+
+The IntPoint
+structure now has an optional 'Z' member. (See the precompiler directive
+ use_xyz.)
+
+
+
+
+
+
+
+
Added:
+
+Users can now force Clipper to use 32bit integers (via the precompiler
+directive use_int32)
+instead of using 64bit integers. Using 32bit integers improves clipping
+performance by about 20-30%. (This has required the introduction of a
+new cInt
+integer type.) The trade-off to this speed up in performance is a very
+restricted vertex coordinate range of ± 46340.
+
+
+
+
+
+
+
+
Modified:
+
+To accommodate open paths, the Polygon and Polygons structures have been renamed Path and Paths
+respectively. The AddPolygon and AddPolygons methods of the ClipperBase class have been renamed AddPath and AddPaths respectively. Several other functions have been similarly renamed.
+
+
+
+
+
+
+
+
Modified:
+
+The PolyNode Class has a new IsOpen property (to support open paths).
+
+
+
+
+
+
+
+
Modified:
+
+The Clipper class has a new ZFillFunction
+property.
+
+
+Version 6 is a major upgrade from previous versions and quite a number of changes have been made to exposed structures and functions. To minimize inconvenience to existing library users, some code has been retained and some added
+to maintain backward compatibility. However, because this code will be
+removed in a future update, it has been marked as deprecated and a
+precompiler directive use_deprecated
+has been defined.
+
+
+New OffsetPolyLines function. (Replaced with OffsetPaths function in
+ver 6.)
+
+
+
+
+
Changed:
+
+The behaviour of the 'miter' JoinType has
+been changed so that when squaring occurs, it's no longer extended up
+to the miter limit but is squared off at exactly 'delta' units. (This
+improves the look of mitering with larger limits at acute angles.)
+
+
+
+
+
Update:
+
+Minor code refactoring and optimisations.
+
+
+
+
+
+
+
v5.1.5 (5 May 2013)
+
+
+
+
Update:
+
+ForceSimple property added to the Clipper Class. (Renamed
+StrictlySimple in ver 6.)
+
+
+
+
+
Update:
+
+Further improvements to this documentation.
+
+
+
+
+
Update:
+
+Minor code optimisations and trivial bug fixes.
+
+
+The MiterLimit parameter in the OffsetPolygons
+function has been renamed Limit and can now also be used to
+limit the number of vertices used to construct arcs when JoinType is
+set to jtRound.
+
+
+
+
+
+
+
v5.1.0 (17 February 2013)
+
+
+
+
Update:
+
+ExPolygons has been replaced with the PolyTree / PolyNode
+classes to more fully represent the parent-child relationships of the
+polygons returned by Clipper's Execute
+method.
+
+
+Significant fixes in and tidy of the internal Int128 class (which is
+used only when polygon coordinate values are greater than ±0x3FFFFFFF
+(~1.07e9)).
+
+
+
+
+
Update:
+
+The Area function
+has been updated with a faster algorithm.
+
+
+
+
+
Update:
+
+Documentation updates. The newish but undocumented 'CheckInputs'
+parameter of the OffsetPolygons
+function has been renamed 'AutoFix' and documented too. The comments on
+ rounding have also been improved
+(ie clearer and expanded).
+
+
+
+
+
+
+
v4.10.0 (25 December 2012)
+
+
+
+
Bugfix:
+
+Orientation bugs should now be resolved (finally!).
+
+
+
+
+
Bugfix:
+
+Bug in Int128 class.
+
+
+
+
+
+
+
v4.9.8 (2 December 2012)
+
+
+
+
Bugfix:
+
+Further fixes to rare Orientation bug.
+
+
+
+
+
+
+
v4.9.7 (29 November 2012)
+
+
+
+
Bugfix:
+
+Bug that very rarely returned a wrong polygon orientation.
+
+
+
+
+
Bugfix:
+
+Obscure bug affecting OffsetPolygons when using jtRound for the
+JoinType parameter and when polygons also contain very large coordinate
+values.
+
+
+
+
+
+
+
v4.9.6 (9 November 2012)
+
+
+
+
Bugfix:
+
+Another obscure bug related to joining intersections.
+
+
+
+
+
+
+
v4.9.4 (2 November 2012)
+
+
+
+
Bugfix:
+
+Bugs in Int128 class occasionally causing wrong orientations.
+
+
+
+
+
Bugfix:
+
+Further fixes related to joining intersections.
+
+
+
+
+
+
+
v4.9.0 (9 October 2012)
+
+
+
+
Bugfix:
+
+Obscure bug related to joining intersections.
+
+
+
+
+
+
+
v4.8.9 (25 September 2012)
+
+
+
+
Bugfix:
+
+Obscure bug related to precision of intersections.
+
+
+
+
+
+
+
v4.8.8 (30 August 2012)
+
+
+
+
Bugfix:
+
+Fixed bug in OffsetPolygons function introduced in version 4.8.5.
+
+
+
+
+
+
+
v4.8.7 (24 August 2012)
+
+
+
+
Bugfix:
+
+ReversePolygon function in C++ translation was broken.
+
+
+Support for Positive and Negativepolygon fill types (in addition to the EvenOdd and NonZero fill types).
+
+
+
+
+
Bugfix:
+
+The OffsetPolygons
+function was generating the occasional artefact when 'shrinking'
+polygons.
+
+
+
+
+
+
+
v4.5.5 (6 October 2011)
+
+
+
+
Bugfix:
+
+Fixed an obscure bug in Clipper's JoinCommonEdges method.
+
+
+
+
+
Update:
+
+Replaced IsClockwise function with Orientation
+function. The orientation issues affecting OffsetPolygons should
+finally be resolved.
+
+
+
+
+
Change:
+
+The Area function
+once again returns the signed area.
+
+
+
+
+
+
+
v4.4.0 (6 August 2011)
+
+
+
+
BugFix:
+
+A number of minor bugfixes that mostly affected the new ExPolygons
+structure.
+
+
+
+
+
+
+
v4.3.0 (17 June 2011)
+
+
+
+
Added:
+
+ExPolygons structure that explicitly associates 'hole' polygons with
+their 'outer' container polygons.
+
+
+
+
+
Added:
+
+ Execute
+method now overloaded so the solution parameter can be either Polygons or
+ExPolygons.
+
+
+
+
+
Bug fix:
+
+Fixed a rare bug in the orientation of solution polygons.
+
+
+
+
+
+
+
v4.2.4 (26 April 2011)
+
+
+
+
Update:
+
+Input polygon coordinates can now contain the full range of signed
+64bit integers (ie +/-9,223,372,036,854,775,807). This means that
+floating point values can be converted to and from Clipper's 64bit
+vertex structure (IntPoint)
+and still retain a precision of up to 18 decimal places. However, since
+the large-integer math that supports this expanded range imposes a
+small cost on performance (~15%), a new property UseFullCoordinateRange
+has been added to the Clipper class to allow users the choice of
+whether or not to use this expanded coordinate range. If this property
+is disabled, coordinate values are restricted to +/-1,500,000,000. (By
+default, this property is enabled.)
+
+
+
+
+
+
+
v4.0 (4 April 2011)
+
+
+
+
Major update:
+
+Clipper is a major rewrite of earlier versions. The biggest change is
+that floating point values are no longer used, except for the storing
+of edge slope values. The main benefit of this is the issue of
+numerical robustness has been addressed. Due to other major code
+improvements Clipper v4 is approximately 40% faster than Clipper v3.
+
+
+
+
+
Changes:
+
+The AddPolyPolygon method has been renamed to AddPolygons, and the
+IgnoreOrientation property has been removed. The clipper_misc library
+has been merged back into the clipper library.
+
+
+
+
+
+
+
v2.8 (20 November 2010)
+
+
+
+
Updated:
+
+Output polygons which previously shared a common edge are now merged.
+
+
+
+
+
Added:
+
+Added support module for Cairo Graphics Library (with accompanying
+demo).
+
+
+
+
+
Added:
+
+Added C# and C++ demos.
+
+
+
+
+
+
+
v2.522 (15 October 2010)
+
+
+
+
Added:
+
+Added C# translation (thanks to Olivier Lejeune) and a link to Ruby
+bindings (thanks to Mike Owens).
+
+
+
+
+
+
+
v2.0 (31 July 2010)
+
+
+
+
Major update:
+
+Clipper now processes polygons using both the Even-Odd (alternate) and
+Non-Zero (winding) filling rules.
+
+
+
+
+
+
+
v1.4c (16 June 2010)
+
+
+
+
Additions:
+
+Added Delphi and C++ units to support the AGG graphics library
+
+
The precompiler directive 'use_deprecated' allows users to update the Clipper library without being forced to make immediate changes to code that accesses the library. Depricated code will be removed in a future update. (Enabled by default.)
Deprecated types and functions:
All deprecated code has been removed from version 6.2.0.
+
Why does Clipper use integer coordinates, not floats?
+
+
This has been done to preserve numerical robustness. Early versions of the library did use floating point coordinates, but it became apparent that floating point imprecision was always going to cause occasional errors.
+
+
+
How do I use floating point coordinates with Clipper?
+
+
It's a simple task to multiply your floating point coordinates by a scaling factor (that's typically a power of 10 depending on the desired precision). Then with the solution paths, divide the returned coordinates by this same scaling factor. Clipper accepts integer coordinates as large as ±4.6e18, so it can accommodate very large scaling.
Some polygons in the solution share a common edge. Is this a bug?
+
+
No, though this should happen rarely as of version 6. (See Clipper.Execute for more about this.)
+
+
+
I have lots of polygons that I want to 'union'. Can I do this in one operation?
+
+
Yes. Just add all the polygons as subject polygons to the Clipper object. (You don't have to assign both subject and clip polygons.)
+
+
+
The polygons produced by ClipperOffset have tiny artefacts? Could this be a bug?
+
+
Make sure the input polygons don't self-intersect. Tiny self-intersections can sometimes be produced by previous clipping operations. These can be cleaned up using the CleanPolygon and CleanPolygons functions. Also, make sure the supplied polygons don't overlap. If they do, offset these separately. Finally, the precision of the input coordinates may be a problem. Because the Clipper Library only operates on integer coordinates, you may need to scale your coordinates (eg by a factor of 10) to improve precision.
+
+
+
Is there an easy way to reverse polygon orientations?
My drawings contain lots of beziers, ellipses and arcs. How can I perform clipping operations on these?
+
+
You'll have to convert them to 'flattened' paths. For an example of how this can be done (and even reconstructed back into beziers, arcs etc), see the CurvesDemo application included in this library.
The Clipper Library (including Delphi, C++ & C# source code, other accompanying code, examples and documentation), hereafter called "the Software", has been released under the following license, terms and conditions:
Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the Software covered by this license to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
+
+
+
The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
+
+
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
By using an integer type for polygon coordinates, the Clipper Library has been able to avoid problems of numerical robustness that can cause havoc with geometric computations. Problems associated with integer rounding and their possible solutions are discussed below.
It's important to stress at the outset that rounding causes vertices to move fractions of a unit away from their 'true' positions. Nevertheless, the resulting imprecision can be very effectively managed by appropriate scaling.
The Clipper Library supports scaling to very high degrees of precision by accepting integer coordinate values in the range ±0x3FFFFFFFFFFFFFFF (± 4.6e+18).
Another complication of using a discrete numbers (as opposed to real numbers) is that very occasionally tiny self-intersection artefacts arise. In the unscaled image on the left (where one unit equals one pixel), the area of intersection of two polygons has been highlighted in bright green.
+
+
+
A 30X 'close up' of the lower points of intersection of these same two polygons shows the presence of a tiny self-intersecting artefact. The three 'black dots' highlight the actual points of intersection (with their fractional coordinates displayed). The 'red dots' show where these points of intersection are located once rounding is applied. With a little care you can see that rounding reverses the orientation of these vertices and causes a tiny self-intersecting artefact.
Although these tiny self-intersections are uncommon, if it's deemed necessary, they are best removed with CleanPolygons. (Setting Clipper's StrictlySimple property to true would also address this self-intersection but the tiny (sub-unit) polygon 'artefact' with incorrect orientation would still appear in the solution.)
+
+
+
In this final example, the single polygon on the left also has a tiny self-intersection. However, the clipping algorithm sees this vertex (88,50) as simply 'touching' rather than intersecting the right edge of the polygon (though only by a fraction of a unit). Since this intersection won't normally be detected, the clipping solution (eg following a union operation) will still contain this tiny self-intersection. Setting Clipper's StrictlySimple property to true avoids this uncommon problem.
Clipping: commonly refers to the process of cutting away from a set of 2-dimensional geometric shapes those parts that are outside a rectangular 'clipping' window. This can be achieved by intersecting subject paths (lines and polygons) with a clipping rectangle. In a more general sense, the clipping window need not be rectangular but can be any type of polygon, even multiple polygons. Also, while clipping typically refers to an intersection operation, in this documentation it will refer to any one of the four boolean operations (intersection, union, difference and exclusive-or).
+
+
Path: is an ordered sequence of vertices defining a single geometric contour that's either a line (an open path) or a polygon (a closed path).
+
+
Line: or polyline is an open path containing 2 or more vertices.
+
+
Polygon: commonly refers to a two-dimensional region bounded by an outer non-intersecting closed contour. That region may also contain a number of 'holes'. In this documentation however, polygon will simply refer to a closed path.
+
+
Contour: synonymous with path.
+
+
Hole: is a closed region within a polygon that's not part of the polygon. A 'hole polygon' is a closed path that forms the outer boundaries of a hole.
+
+
Polygon Filling Rule: the filling rule, together with a list of closed paths, defines those regions (bounded by paths) that are inside (ie regions 'brush filled' in a graphical display) and those which are outside (ie 'holes').
+
+
+
+
+
Distribution package contents:
The ZIP package contains the Clipper library's source code, a Windows CHM help file, HTML help, and a number of compiled demo applications (with full source code). The library was initially written in Delphi Pascal (and compiles with Delphi version 7 or above) but now contains C++, C# and Python translations too. The library's source code in each language is about 5000 lines. The Delphi code contains reasonably extensive comments, but comments are fewer in the C++ and C# code. The included sample applications show how Clipper can be used with the different languages using a number of graphics display libraries including - AGG, Cairo, OpenGL, Graphics32, GDI+ and SVG.
The Library is based on but significantly extends Bala Vatti's polygon clipping algorithm as described in "A generic solution to polygon clipping", Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63.
The paper titled "Polygon Offsetting by Computing Winding Numbers" by Chen & McMains (Paper no. DETC2005-85513, ASME 2005. Pages 565-575) contains helpful discussion on the complexities of polygon offsetting together with some solutions.