NAME Math::Geometry::Planar::GPC::Polygon - OO wrapper to gpc library Status Successfully used in minor production use under perl 5.6.1 and 5.8.3. Your mileage may vary (see NO WARRANTY.) AUTHOR Eric L. Wilhelm ewilhelm at sbcglobal dot net http://pages.sbcglobal.net/mycroft/ Copyright Copyright 2004 Eric L. Wilhelm License This module and its C source code (functions.c) are freely redistributable under the GNU general public license (GPL). See http://www.gnu.org for details. The General Polygon Clipping library (gpc.c and gpc.h) is also distributed under the GPL license. A copy of these files has been included with this distribution strictly for convenience purposes. See gpc.c for details. Note that the C library is authored by Alan Murta. You may want to check the GPC home page for a more current version: http://www.cs.man.ac.uk/aig/staff/alan/software/ Portability This module successfully compiles on i386 and solaris architectures according to the cpan testers results. Hopefully, versions after 0.03 will work on WIN32. I don't have any non-linux machines, so feel free to send patches. NO WARRANTY This code comes with ABSOLUTELY NO WARRANTY of any kind. Changes 0.01 - First public release. 0.02 - Added API documentation. 0.03 - Fix to allocation error. Possibly Fixed WIN32 compile problem? Constructors new Traditional constructor, returns a blessed reference to the underlying C struct. use Math::Geometry::Planar::GPC::Polygon; my $gpc = Math::Geometry::Planar::GPC::Polygon->new(); new_gpc An optionally imported constructor, for those of you who don't like to type so much. use Math::Geometry::Planar::GPC::Polygon qw(new_gpc); my $gpc = new_gpc(); Bound Functions These are the functions provide by the Inline-C code. See functions.c in the source package for intimate details. from_file Loads a from a file into your gpc object. See the GPC library documentation for details. $gpc->from_file($filename, $want_hole); to_file Writes to a file. $gpc->to_file($filename, $want_hole); clip_to Clips the $gpc object to the $othergpc object. $action may be any of the following: INTERSECT DIFFERENCE UNION $gpc->clip_to($othergpc, $action); Be wary. This interface may need to change. add_polygon Adds a polygon to the gpc object. @points is a list of array references which describe the point of the polygon. $hole is 1 or 0 (0 to not add a hole.) $gpc->add_polygon(\@points, $hole); get_polygons Gets the polygons from the gpc object. I'm not sure how to tell you if they are holes or not. @pgons will be a list of refs to lists of refs. @pgons = $gpc->get_polygons(); Helper Functions Pure-perl implementation from here down. as_string $gpc->as_string();