diff --git a/src/detail/GeometrySet.cpp b/src/detail/GeometrySet.cpp old mode 100644 new mode 100755 index 078e7862..ffa0a76c --- a/src/detail/GeometrySet.cpp +++ b/src/detail/GeometrySet.cpp @@ -558,10 +558,10 @@ void recompose_points( const typename GeometrySet::PointCollection& points, // compare less than struct ComparePoints { bool operator()( const CGAL::Point_2& lhs, const CGAL::Point_2& rhs ) const { - return lhs.x() == rhs.x() ? lhs.y() < rhs.y() : lhs.x() < rhs.x(); + return lhs.x() < rhs.x() || lhs.y() < rhs.y(); } bool operator()( const CGAL::Point_3& lhs, const CGAL::Point_3& rhs ) const { - return lhs.x() == rhs.x() ? (lhs.y() == rhs.y() ? lhs.z() < rhs.z() : lhs.y() < rhs.y()) : lhs.x() < rhs.x(); + return lhs.x() < rhs.x() || lhs.y() < rhs.y() || lhs.z() < rhs.z(); } }; @@ -922,37 +922,78 @@ void GeometrySet::collectPoints( const PrimitiveHandle& pa ) } template -void _filter_covered( IT ibegin, IT iend, GeometrySet& output ) +void _filter_covered(IT ibegin, IT iend, GeometrySet& output) { - for ( IT it = ibegin; it != iend; ++it ) { - GeometrySet v1; - v1.addPrimitive( it->primitive() ); - bool v1_covered = false; - - for ( IT it2 = it; it2 != iend; ++it2 ) { - if ( it == it2 ) { - continue; + for (IT it = ibegin; it != iend; ++it) + { + GeometrySet v1; + v1.addPrimitive(it->primitive()); + std::auto_ptr g1 = v1.recompose(); + + bool v1_covered = false; + for (IT it2 = it; it2 != iend; ++it2) + { + if (it == it2) + { + continue; + } + + GeometrySet v2; + v2.addPrimitive(it2->primitive()); + + bool b = false; + if (g1->is3D()) + { + std::auto_ptr g2 = v2.recompose(); + if (g2->is3D()) + { + b = algorithm::covers3D(*g2,*g1); } - - GeometrySet v2; - v2.addPrimitive( it2->primitive() ); - - if ( algorithm::covers( v2, v1 ) ) { - v1_covered = true; - break; + else + { + b = algorithm::covers(v2,v1); } - } - - // if its not covered by another primitive - if ( !v1_covered ) { - // and not covered by another already inserted primitive - bool b = algorithm::covers( output, v1 ); - - if ( !b ) { - output.addPrimitive( it->primitive(), it->flags() ); + } + else + { + b = algorithm::covers(v2,v1); + } + + if (b) + { + v1_covered = true; + break; + } + } + + // If its not covered by another primitive... + if (!v1_covered) + { + // ...and not covered by another already inserted primitive... + bool b; + if (g1->is3D()) + { + std::auto_ptr goutput = output.recompose(); + if (goutput->is3D()) + { + b = algorithm::covers3D(*goutput,*g1); } - } - } + else + { + b = algorithm::covers(output,v1); + } + } + else + { + b = algorithm::covers(output,v1); + } + + if (!b) + { + output.addPrimitive(it->primitive(), it->flags()); + } + } + } } template <>