Skip to content

Commit 0716a81

Browse files
Issue Oslandia#200: Pass geometry to covers() or covers3D() in _filter_covered() depending on its coordinate dimension.
1 parent d5f162d commit 0716a81

File tree

1 file changed

+70
-29
lines changed

1 file changed

+70
-29
lines changed

src/detail/GeometrySet.cpp

100644100755
+70-29
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,10 @@ void recompose_points( const typename GeometrySet<Dim>::PointCollection& points,
558558
// compare less than
559559
struct ComparePoints {
560560
bool operator()( const CGAL::Point_2<Kernel>& lhs, const CGAL::Point_2<Kernel>& rhs ) const {
561-
return lhs.x() == rhs.x() ? lhs.y() < rhs.y() : lhs.x() < rhs.x();
561+
return lhs.x() < rhs.x() || lhs.y() < rhs.y();
562562
}
563563
bool operator()( const CGAL::Point_3<Kernel>& lhs, const CGAL::Point_3<Kernel>& rhs ) const {
564-
return lhs.x() == rhs.x() ? (lhs.y() == rhs.y() ? lhs.z() < rhs.z() : lhs.y() < rhs.y()) : lhs.x() < rhs.x();
564+
return lhs.x() < rhs.x() || lhs.y() < rhs.y() || lhs.z() < rhs.z();
565565
}
566566
};
567567

@@ -922,37 +922,78 @@ void GeometrySet<Dim>::collectPoints( const PrimitiveHandle<Dim>& pa )
922922
}
923923

924924
template <int Dim, class IT>
925-
void _filter_covered( IT ibegin, IT iend, GeometrySet<Dim>& output )
925+
void _filter_covered(IT ibegin, IT iend, GeometrySet<Dim>& output)
926926
{
927-
for ( IT it = ibegin; it != iend; ++it ) {
928-
GeometrySet<Dim> v1;
929-
v1.addPrimitive( it->primitive() );
930-
bool v1_covered = false;
931-
932-
for ( IT it2 = it; it2 != iend; ++it2 ) {
933-
if ( it == it2 ) {
934-
continue;
927+
for (IT it = ibegin; it != iend; ++it)
928+
{
929+
GeometrySet<Dim> v1;
930+
v1.addPrimitive(it->primitive());
931+
std::auto_ptr<SFCGAL::Geometry> g1 = v1.recompose();
932+
933+
bool v1_covered = false;
934+
for (IT it2 = it; it2 != iend; ++it2)
935+
{
936+
if (it == it2)
937+
{
938+
continue;
939+
}
940+
941+
GeometrySet<Dim> v2;
942+
v2.addPrimitive(it2->primitive());
943+
944+
bool b = false;
945+
if (g1->is3D())
946+
{
947+
std::auto_ptr<SFCGAL::Geometry> g2 = v2.recompose();
948+
if (g2->is3D())
949+
{
950+
b = algorithm::covers3D(*g2,*g1);
935951
}
936-
937-
GeometrySet<Dim> v2;
938-
v2.addPrimitive( it2->primitive() );
939-
940-
if ( algorithm::covers( v2, v1 ) ) {
941-
v1_covered = true;
942-
break;
952+
else
953+
{
954+
b = algorithm::covers(v2,v1);
943955
}
944-
}
945-
946-
// if its not covered by another primitive
947-
if ( !v1_covered ) {
948-
// and not covered by another already inserted primitive
949-
bool b = algorithm::covers( output, v1 );
950-
951-
if ( !b ) {
952-
output.addPrimitive( it->primitive(), it->flags() );
956+
}
957+
else
958+
{
959+
b = algorithm::covers(v2,v1);
960+
}
961+
962+
if (b)
963+
{
964+
v1_covered = true;
965+
break;
966+
}
967+
}
968+
969+
// If its not covered by another primitive...
970+
if (!v1_covered)
971+
{
972+
// ...and not covered by another already inserted primitive...
973+
bool b;
974+
if (g1->is3D())
975+
{
976+
std::auto_ptr<SFCGAL::Geometry> goutput = output.recompose();
977+
if (goutput->is3D())
978+
{
979+
b = algorithm::covers3D(*goutput,*g1);
953980
}
954-
}
955-
}
981+
else
982+
{
983+
b = algorithm::covers(output,v1);
984+
}
985+
}
986+
else
987+
{
988+
b = algorithm::covers(output,v1);
989+
}
990+
991+
if (!b)
992+
{
993+
output.addPrimitive(it->primitive(), it->flags());
994+
}
995+
}
996+
}
956997
}
957998

958999
template <>

0 commit comments

Comments
 (0)