General Polygon Clipper
This article needs additional citations for verification. (December 2021) |
The General Polygon Clipper (GPC) is a software library providing for computing the results of clipping operations on sets of polygons. It generalises the computer graphics clipping problem of intersecting polygons with polygons. The first release of GPC was designed and implemented in 1997 by Alan Murta. As of August 2009[update] the final GPC release was version 2.32. The core GPC library is written in the C programming language but the library has also been ported to work with several other languages.
Availability
[edit]Since August 2020, GPC is no longer officially distributed by the author.
In December 2021 a copy of the GPC code (v2.32) was placed on GitHub under the MIT License by Paint.NET author Rick Brewster.[1]
Licensing
[edit]Developers may use GPC for any purpose without paid licensing restrictions.
Features of GPC
[edit]The following summarises the features and operations on polygons supported by GPC.
GPC can compute the following clip operations: difference, intersection, exclusive-or and union.
Polygons may comprise multiple disjoint contours. Contour vertices may be specified as clockwise or anticlockwise. Contours may be convex, concave or self-intersecting. Contours may be nested. In other words, polygons may have holes.
The clip operation output from GPC is a set of polygon contours or tristrips. Holes and external contours are differentiated in GPC's output. Coincident edges and degenerate regions are handled correctly.
Examples of GPC operations on sets of polygons
[edit]The following four images show examples of GPC computing operations between two polygon sets. The first polygon set comprises outlines of the United Kingdom and Ireland. The second polygon set comprises the four large inward-pointing arrows. In each example, the areas resulting from the GPC operation between the two sets of polygons are rendered in colour.
This example shows difference between the two sets:
This example shows intersection between the two sets:
This example shows union between the two sets:
This example shows exclusive-or between the two sets:
Ports and language bindings
[edit]The core GPC code is written in C, but the GPC user community has contributed a number of ports and bindings (or wrappers) for various other languages (ActionScript 3, Borland Delphi, C#, GNU Octave, Haxe, Haskell, Java, Lua, Pascal, Perl, Python, VB.Net). All of these ports and bindings are freely available.
References
[edit]- ^ "GeneralPolygonClipper". GeneralPolygonClipper on GitHub. Retrieved 22 December 2021.