General Polygon Clipper

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

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 at the University of Manchester by Alan Murta. As of August 2009 the current 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.

GPC is free for non-commercial use, and its author encourages the free use of GPC to support research, teaching and academic applications. To use GPC in support of commercial applications, a Licence from the University of Manchester is required. The Licensing Manager at the University of Manchester is Toby Howard.

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:

Example of GPC Difference

This example shows intersection between the two sets:

Example of GPC Intersection

This example shows union between the two sets:

Example of GPC Union

This example shows exclusive-or between the two sets:

Example of GPC Exclusive-or

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 (Action Script 3, Borland Delphi, C#, GNU Octave, Haxe, Haskell, Java, Lua, Pascal, Perl, Python, VB.Net). All of these ports and bindings are freely available.

Licensing arrangements[edit]

GPC code—along with its associated language ports, bindings, and example software—are distributed as being free to download and intended for time-unlimited evaluation by any individual or company. Following evaluation, arrangements for using GPC for a project depend on whether the project is non-commercial, or commercial basis, as follows:

  • Non-commercial use: GPC may be used free of charge, without a licence, in any application which is strictly non-commercial (examples: hobbyist, academic research or teaching).
  • Commercial use: To use GPC in support of for-profit commercial activity (example: product research & development), users must obtain an official GPC Commercial Use Licence from the University of Manchester.

External links[edit]