diff options
author | Giles Bathgate <gilesbathgate@gmail.com> | 2011-04-10 23:18:17 (GMT) |
---|---|---|
committer | Giles Bathgate <gilesbathgate@gmail.com> | 2011-04-10 23:18:17 (GMT) |
commit | 6cce430eed9910d9cf84e220ed96479dd7167d4f (patch) | |
tree | a542019b617a60636b9f0a501d59bb375fb13df7 /src/cgaladv_minkowski2.cc | |
parent | cdc4574a9c1d6be012eab8e49b55e4472a71d563 (diff) | |
parent | 0c1b1f4e2243696cbec0427c41182c5529a6c55f (diff) |
Merge branch 'master' into convex-hull
Conflicts:
src/cgaladv_minkowski2.cc
Diffstat (limited to 'src/cgaladv_minkowski2.cc')
-rw-r--r-- | src/cgaladv_minkowski2.cc | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/src/cgaladv_minkowski2.cc b/src/cgaladv_minkowski2.cc index 116139f..8d0bf62 100644 --- a/src/cgaladv_minkowski2.cc +++ b/src/cgaladv_minkowski2.cc @@ -31,7 +31,6 @@ #include "grid.h" #include "cgal.h" -#if 1 #include <CGAL/minkowski_sum_2.h> @@ -58,9 +57,9 @@ void print_polygon (const CGAL::Polygon_2<Kernel, Container>& P) template<class Kernel, class Container> void print_polygon_with_holes (const CGAL::Polygon_with_holes_2<Kernel, Container>& pwh) { if (! pwh.is_unbounded()) { - std::cout << "{ Outer boundary = "; - print_polygon (pwh.outer_boundary()); - } else + std::cout << "{ Outer boundary = "; + print_polygon (pwh.outer_boundary()); + } else std::cout << "{ Unbounded polygon." << std::endl; typename CGAL::Polygon_with_holes_2<Kernel,Container>::Hole_const_iterator hit; @@ -88,23 +87,20 @@ CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p) for (fci_t fit = E.faces_begin(), fend = E.faces_end(); fit != fend; ++fit) { - std::cout << "face " << ((E.mark(fit))? "is part of polygon" : "is not part of polygon") << std::endl; - if (!E.mark(fit)) { - continue; - } + if (!E.mark(fit)) { + continue; + } //if (fit != E.faces_begin()) { if (points.size() != 0) { PRINT("WARNING: minkowski() is not implemented for 2d objects with holes!"); - break; + break; } heafcc_t fcirc(E.halfedge(fit)), fend(fcirc); CGAL_For_all(fcirc, fend) { - //std::cout << "fcirc,fend " << std::endl; if (E.is_standard(E.target(fcirc))) { Explorer::Point ep = E.point(E.target(fcirc)); double x = to_double(ep.x()), y = to_double(ep.y()); - std::cout << "point " << ep << std::endl; grid.align(x, y); points.push_back(CGAL_ExactKernel2::Point_2(x, y)); } @@ -115,7 +111,7 @@ CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p) } static CGAL_Nef_polyhedron2 p2nef2(CGAL_Poly2 p2) { std::list<CGAL_Nef_polyhedron2::Point> points; - for (int j = 0; j < p2.size(); j++) { + for (size_t j = 0; j < p2.size(); j++) { double x = to_double(p2[j].x()); double y = to_double(p2[j].y()); CGAL_Nef_polyhedron2::Point p = CGAL_Nef_polyhedron2::Point(x, y); @@ -127,33 +123,20 @@ static CGAL_Nef_polyhedron2 p2nef2(CGAL_Poly2 p2) { CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b) { CGAL_Poly2 ap = nef2p2(a), bp = nef2p2(b); - std::cout << "ap = "; print_polygon(ap); - std::cout << "bp = "; print_polygon(bp); - - if (ap.size() == 0) { - PRINT("WARNING: minkowski() could not get any points from object 1!"); - return CGAL_Nef_polyhedron2(); - } else if (bp.size() == 0) { - PRINT("WARNING: minkowski() could not get any points from object 2!"); - return CGAL_Nef_polyhedron2(); - } else { - CGAL_Poly2h x = minkowski_sum_2(ap, bp); - std::cout << "result = "; print_polygon_with_holes(x); - - // Make a CGAL_Nef_polyhedron2 out of just the boundary for starters - return p2nef2(x.outer_boundary()); - } -} - -#else -CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2, CGAL_Nef_polyhedron2) -{ - PRINT("WARNING: minkowski() is not implemented yet for 2d objects!"); - return CGAL_Nef_polyhedron2(); + if (ap.size() == 0) { + PRINT("WARNING: minkowski() could not get any points from object 1!"); + return CGAL_Nef_polyhedron2(); + } else if (bp.size() == 0) { + PRINT("WARNING: minkowski() could not get any points from object 2!"); + return CGAL_Nef_polyhedron2(); + } else { + CGAL_Poly2h x = minkowski_sum_2(ap, bp); + + // Make a CGAL_Nef_polyhedron2 out of just the boundary for starters + return p2nef2(x.outer_boundary()); + } } #endif -#endif - |