GPC General Polygon Clipper Library

From Wikipedia, the free encyclopedia

The University of Manchester GPC library is a software library providing an API 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. The current GPC release is version 2.32.

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 Licencing Manager at the University of Manchester is Toby Howard.

The core GPC library is written in C. The library has also been ported to work with several other languages (see Ports and Language bindings).

Contents

[edit] 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.

[edit] 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:

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

[edit] Ports and Language bindings

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

[edit] Licencing arrangements

The GPC code (and associated language ports and bindings, and demo software) is completely free for downloading and 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, 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.

[edit] External Links

  • The GPC homepage - includes GPC library and Windows/Linux demo program downloads, licencing and contact details.

The following links cover polygon clipping in general: