@@ -558,10 +558,10 @@ void recompose_points( const typename GeometrySet<Dim>::PointCollection& points,
558
558
// compare less than
559
559
struct ComparePoints {
560
560
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 ();
562
562
}
563
563
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 ();
565
565
}
566
566
};
567
567
@@ -922,37 +922,78 @@ void GeometrySet<Dim>::collectPoints( const PrimitiveHandle<Dim>& pa )
922
922
}
923
923
924
924
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)
926
926
{
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);
935
951
}
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);
943
955
}
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);
953
980
}
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
+ }
956
997
}
957
998
958
999
template <>
0 commit comments