diff --git a/src/cgaladv.cc b/src/cgaladv.cc index 45a3bdd3..6301cd3c 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -34,7 +34,7 @@ #ifdef ENABLE_CGAL extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b); extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedron2 b); -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); +extern CGAL_Nef_polyhedron2 convexhull2(std::list a); #endif enum cgaladv_type_e { @@ -184,19 +184,24 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const if (type == HULL) { + std::list polys; + bool all2d = true; foreach(AbstractNode * v, children) { if (v->modinst->tag_background) continue; N = v->render_cgal_nef_polyhedron(); if (N.dim == 3) { - + //polys.push_back(tmp.p3); + all2d=false; } if (N.dim == 2) { - N.p2 = convexhull2(N.p2); + polys.push_back(N.p2); } v->progress_report(); - break; } + + if(all2d) + N.p2 = convexhull2(polys); } cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight()); diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc index 19149543..e1e466d7 100644 --- a/src/cgaladv_convexhull2.cc +++ b/src/cgaladv_convexhull2.cc @@ -29,31 +29,27 @@ #include "cgal.h" #include -extern CGAL_Nef_polyhedron2 convexhull2(CGAL_Nef_polyhedron2 a); +extern CGAL_Nef_polyhedron2 convexhull2(std::list a); extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); -static std::list p2points(CGAL_Poly2 p2) +CGAL_Nef_polyhedron2 convexhull2(std::list a) { - std::list points; - for (int j = 0; j < p2.size(); j++) { - double x = to_double(p2[j].x()), y = to_double(p2[j].y()); - CGAL_Nef_polyhedron2::Point p = - CGAL_Nef_polyhedron2::Point(x, y); - points.push_back(p); + std::list points; + + std::list::iterator i; + for(i=a.begin(); i!=a.end(); i++) { + CGAL_Poly2 ap=nef2p2(*i); + for (int j=0;j points = p2points(ap), result; + std::list result; + CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result)); - CGAL::convex_hull_2(points.begin(), points.end(), - std::back_inserter(result)); - std::cout << result.size() << " points on the convex hull" << std::endl; - return CGAL_Nef_polyhedron2(result.begin(), - result.end(), CGAL_Nef_polyhedron2::INCLUDED); + return CGAL_Nef_polyhedron2(result.begin(),result.end(),CGAL_Nef_polyhedron2::INCLUDED); } #endif