diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 4b14e0be..88c500a0 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -12,11 +12,13 @@ #include #include #include +#include #include "svg.h" #include "Reindexer.h" #include #include +#include namespace /* anonymous */ { template @@ -75,7 +77,30 @@ namespace CGALUtils { return false; } } - return true; + // Also make sure that there is only one shell: + boost::unordered_set visited; + visited.reserve(p.size_of_facets()); + + std::queue to_explore; + to_explore.push(p.facets_begin()); // One arbitrary facet + visited.insert(to_explore.front()); + + while (!to_explore.empty()) { + typename Polyhedron::Facet_const_handle f = to_explore.front(); + to_explore.pop(); + typename Polyhedron::Facet::Halfedge_around_facet_const_circulator he, end; + end = he = f->facet_begin(); + CGAL_For_all(he,end) { + typename Polyhedron::Facet_const_handle o = he->opposite()->facet(); + + if (!visited.count(o)) { + visited.insert(o); + to_explore.push(o); + } + } + } + + return visited.size() == p.size_of_facets(); } Geometry const * applyMinkowski(const Geometry::ChildList &children)