Skip to content
Surf Wiki
Save to docs
general/graphics-libraries

From Surf Wiki (app.surf) — the open knowledge base

General Polygon Clipper

Graphics software library

General Polygon Clipper

Graphics software library

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. 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

Since August 2020 GPC is no longer officially distributed by the author.

In December 2021 a copy of the GPC code (v2.33) was placed on GitHub under the MIT License by Paint.NET author Rick Brewster.

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:

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

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

References

  1. "GeneralPolygonClipper".
Info: Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about General Polygon Clipper — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report