4.66667

4.7 | 9 ratings Rate this file 253 downloads (last 30 days) File Size: 39.66 KB File ID: #8818

Polygon Clipper

by Sebastian Hölz

 

25 Oct 2005 (Updated 04 Oct 2006)

Code covered by BSD License  

Given two arbitrary polygons, the routine calculates the resulting polygon ...

Download Now | Watch this File

File Information
Description

The Polygon Clipper (based on the gpc-library) is used to performe algebraic operations on two polygons.

Given two arbitrary polygons (which may self intersect, may contain holes, may be constructed of several contours) the Polygon Clipper is used to calculate the resulting polygon for the operations diff, union, AND, XOR.

All polygons are specified as structures as described in the example.m-file.

Credit for the gpc-library goes to Alan Murta (s. ReadMe.txt).

Acknowledgements
This submission has inspired the following:
Polygon_Intersection
MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements The supplied dll should work under Windows, however if the c-files need to be recompiled for other OS, an appropriate c-compiler is needed.
Zip File Content  
Other Files gpc.c,
gpc.h,
gpc_mexfile.c,
gpc_mexfile.h,
PolygonClip.dll,
ReadMe.txt,
PolygonClip_example.m,
PolygonClipper_Example.png
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (12)
12 Jan 2006 Pancho Blu

Just what I needed. I have been racking my brains for days to get to a point where my program starts to work, but this one is much better and faster!. Thanks a lot.

03 May 2006 Murray Thomson

Worked first time. Very easy to use. Did exactly what I needed. (And not an easy thing to program for yourself, as I found out the hard way!)

27 Jul 2006 Emily Hinz

An extremely useful and easy to use set of routines. Thank you!

03 Aug 2006 je che

Took a lot of work to run on my linux machine. The problem is that the
gpc_mexfile sources use '//' to begin the comments, and this is not part
of the C standard. This probably means the programs were written on a
Windows machine, which uses Microsoft Visual C++ to compile C code.
'//' is the comment prefix in standard C++. Microsoft appears to
believe that C++ is a perfect superset of C, which isn't true.

I removed all the lines beginning with // from those two source files
and the mex command in the readme gave worked fine.

Also, it won't run unless I had the older gcc-3.3 package installed.

Also, the zip file ships with Example.m which doesn't work. PolyClipper_example.m does work. Looks like a great function, though, if these things get tidied up.

01 Feb 2007 Jaeyoung Jung

This polygon clipper works very well and easy to use, also has good quality!!

12 Apr 2007 Gerald Dalley

Worked well the first time and is reasonably fast. Thanks! It compiled fine for me on 64-bit Linux using Matlab 7.2.

23 Apr 2007 moho atc

yes yes

02 May 2007 Ramtin S

Good work. Have not seen any problems with it so far

02 Dec 2008 Stanley

Very good.

20 Jul 2009 Terrance Nearey

Just a quick note...Mac OSX 10.5 Matlab Release 2008a
 Compiled and ran example first time using exactly
the instructions from ReadMe.txt
(cut and pasted them to matlab command window)
Compiler used gcc version 4.0.1 (Apple Inc. build 5465)
(default on my system)
Thanks for terse and sufficient instructions.

13 Oct 2009 Dominic

For me the installation also worked flawlessly under 64bit Linux - as the code itself - great work!

27 Oct 2009 Sam Cape

I'm having problems getting this to work on xp pro 64 bit. Any suggestions?

Please login to add a comment or rating.
Updates
01 Nov 2005

Memory hole fixed in the mexfile (gpc_mexfile.c), which could lead to segmentation violation.

02 Nov 2005

Catching error with empty hole field (xyz.hole=[];), minor changes.

18 Aug 2006

Changes according to suggestions of je che (3.8.2006)
- Removed file "Example.m", which somehow slipped into the zip-file.
- Changed comment style in "gpc_mexfile.*"

04 Oct 2006

In the version from August 2006 I accidently deleted one line from the mexfile, which created a serious memory leak. This has been fixed in this version and anyone using the older version is advised to update.

Tag Activity for this File
Tag Applied By Date/Time
linear algebra Sebastian Hölz 22 Oct 2008 08:04:24
polygon Sebastian Hölz 22 Oct 2008 08:04:24
difference Sebastian Hölz 22 Oct 2008 08:04:24
union Sebastian Hölz 22 Oct 2008 08:04:24
xor Sebastian Hölz 22 Oct 2008 08:04:24
and Sebastian Hölz 22 Oct 2008 08:04:24
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com