标签:
Michael Leonov 1998
http://www.angusj.com/delphi/clipper.php#screenshots
http://www.complex-a5.ru/polyboolean/comp.html
http://www.angusj.com/delphi/clipper.php#screenshots
When writing my BS degree work I tested the following software libraries for speed and robustness of performing polygon Boolean operations:
Library name | Principal author | Language |
---|---|---|
Boolean (v.1.34) | Klaas Holwerda | C++ |
Boolean Operations On Polygons (v. 2.0) (BOPS) | Matej Gombosi | C++ |
CGAL (r. 1.1) | Joint project of 7 sites | C++ |
Clippoly (pl. 7) | Klamer Schutte | C++ |
Constructive Planar Geometry (CPG) | Dave Eberly | C++ |
GPC (v.2.22) | Alan Murta | C |
LEDA (v.R-3.6.1) | Max-Planck-Institut fuer Informatik | C++ |
PolyBoolean v0.0 | Michael Leonov, Alexey Nikitin | C++ |
Library | AND | SUB | OR | XOR | HOLES | KH I | SI | DV | KH O |
---|---|---|---|---|---|---|---|---|---|
Boolean | + | + | + | + | + | + | - | + | + |
BOPS | + | - | + | - | + | - | - | - | + |
CGAL | + | + | + | - | - | - | - | - | - |
Clippoly | + | + | - | - | - | - | - | - | - |
CPG | + | + | + | + | + | - | - | + | - |
GPC | + | + | + | + | + | + | + | + | - |
LEDA | + | + | + | + | + | - | - | + | - |
PolyBoolean | + | + | + | + | + | + | - | + | - |
First 4 columns denote supported Boolean operations. HOLES means that a library can handle polygons with holes. KH I means that a library can handle polygons with ‘keyholed‘ edges, which are sometimes used to describe a polygon with holes by means of single contour. SI means that a library allows self-intersecting polygons at its input. DV means that a library supports polygons with vertices of high degree, i.e. self-touching polygons. KH O means that a library‘s output can contain keyholed edges (I think this is the library‘s disadvantage).
For testing I used PC with CPU Pentium II (233 MHz) and 96Mb RAM running Windows NT Workstation 4.0 SP4. All source code was compiled with Microsoft Visual C++ 6.0 using the same alignment (8 bytes) and optimization options. Sample polygons were extracted from True Type Font contours using different levels of Bezier curves polygonal approximation. The test program was executed 5 times for every Boolean operation. The results are summarized in the table below (N denotes the total number of vertices in input polygons, all timings are measured in seconds, best times for each N are bold):
Library | N=3885 | N=7076 | N=20190 | N=69839 | N=174239 |
---|---|---|---|---|---|
Boolean | 1.084 | 1.773 | 5.923 | 23.219 | 65.927 |
Clippoly | 15.482 | 51.965 | 487.942 | ... | ... |
GPC | 0.160 | 0.381 | 8.570 | 64.463 | 133.670 |
LEDA | 0.806 | 1.422 | 3.801 | 16.636 | ... |
PolyBoolean | 0.158 | 0.255 | 0.721 | 3.532 | 16.011 |
For N=69839, 174239 Clippoly caused stack overflow due to the O(N) recursion depth. For N=174239 LEDA caused memory overflow (despite the presence of the extra 100 Mb of virtual memory) due to the extensive use of the rational ariphmetic.
Like Clippoly, CGAL and CPG have quadratic running time. BOPS produced incorrect results on test polygons so I did not include its timings.
Most of the programs listed above are not strictly robust and use floating point arithmetic with some tolerance values. CGAL, CPG and LEDA use exact rational arithmetic to achieve robustness. In this case, required memory size grows exponentially with a number of cascaded operations, and this seems not to be satisfactory for practical applications. PolyBoolean uses John Hobby‘s rounding cell technique to avoid extraneous intersections and is therefore completely robust. Boolean also rounds the intersection points to the integer grid, then repeats until no new intersection points are found.
Algorithm used in Boolean is described in [Holwerda 98]. Some additional information can be found in [Preparata and Shamos 85] (a must-have Computational Geometry book).
Algorithm used in BOPS is described in [Zalik, Gombosi and Podgorelec 98].
Algorithm used in CGAL is not documented.
Algorithm used in Clippoly is described in [Schutte 94] and [Schutte 95].
Algorithm used in CPG is described in [Eberly 98].
GPC uses a modified version of [Vatti 92]. Implementation details are discussed in [Murta 98]. Alan Murta is currently working on a paper describing GPC.
Polygon Boolean algorithm used in LEDA is not documented by itself. The segment intersection part is described in [Mehlhorn and Naher 94].
Polygon Boolean algorithm used in PolyBoolean is described in [Leonov and Nikitin 97]. Additional algorithmic and implementation issues are discussed in [Leonov 98]. The segment intersection part is based on [Bentley and Ottmann 79] and [Hobby 99].
All tested libraries are very good for educational purposes and for studying different approaches to the polygon Boolean operations. PolyBoolean, Boolean and GPC are probably the fastest publicly available libraries. The correct rounding of intersection points is performed only in PolyBoolean and Boolean. Of course, all these opinions are only mine, and I don‘t attempt to make strong assertions about usefulness of these programs. Click here to get the polygons I used for testing. Soon I will make the source code of the test program (with all necessary modifications of the tested libraries) publicly available.
[算法]Comparison of the different algorithms for Polygon Boolean operations
标签:
原文地址:http://www.cnblogs.com/yhlx125/p/4542687.html