|Did you know ...||Search Documentation:|
|Packs (add-ons) for SWI-Prolog|
|Title:||Generic polygon clipper|
|Rating:||Not rated. Create the first rating!|
|Author:||Roy Ratcliffe <email@example.com>|
|Maintainer:||Roy Ratcliffe <firstname.lastname@example.org>|
|Packager:||Roy Ratcliffe <email@example.com>|
No reviews. Create the first review!.
Alan Murta of Manchester University, United Kingdom, wrote a very useful [generic two-dimensional polygon clipper][gpc]. Cheers Alan. Nice work. This is a Prolog wrapper for his GPC tool.
1 ?- [library(gpc/demos)]. true. 2 ?- britain_arrows(xor). true.
Implements polygons as mutable BLOBs. Tempting to make a purely functional interface with no side effects. However, the underlying implementation maintains mutable polygon entities. Decision is to include pure functional predicates (side-effect free) using arity.
Mutability makes some assumptions about threading. Polygons are not thread safe. Provide suitable atomic locking, e.g. using [mutexes][threadsync], if you want to synchronise access to the same polygon across multiple threads.
The underlying interface uses a flag to indicate the difference
in-between external or internal contours. The Prolog implementation here uses
external and hole functors with a single list argument comprising
There are no modifications, except to substitute standard memory allocation requests for Prolog allocations. The GPC sources do not permit a redefinition. Consequently, it now also includes the SWI-Prolog header.
The GPC code also uses
fscanf() while ignoring the return value. In other
words, it ignores errors and could fail by seeing random stack-based values that
do not represent true scanned values. Worked around this by quieting the warning
unused-result) but also by avoiding use of the
Note that you can easily attach the pack, build and run it directly from a local repo clone using the following queries. These work on Windows, Mac and Linux. Change `~/Documents/GitHub` to wherever you have cloned the repo; the parent folder, not the repo folder itself.
?- expand_file_name('~/Documents/GitHub', [Packs]), attach_packs(Packs). ?- pack_rebuild(gpc). ?- [library(gpc)]. ?- load_test_files(). ?- run_tests.
Pack contains 28 files holding a total of 143K bytes.