Шаблон:Refimprove
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 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.
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
Developers may use GPC for any purpose without paid licensing restrictions.
Features of GPC
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
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: