Skip to content

Commit

Permalink
Issue Oslandia#200: Pass geometry to covers() or covers3D() in _filte…
Browse files Browse the repository at this point in the history
…r_covered() depending on its coordinate dimension.
  • Loading branch information
danielcumberbatch committed Oct 30, 2019
1 parent d5f162d commit 0716a81
Showing 1 changed file with 70 additions and 29 deletions.
99 changes: 70 additions & 29 deletions src/detail/GeometrySet.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,10 @@ void recompose_points( const typename GeometrySet<Dim>::PointCollection& points,
// compare less than
struct ComparePoints {
bool operator()( const CGAL::Point_2<Kernel>& lhs, const CGAL::Point_2<Kernel>& 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<Kernel>& lhs, const CGAL::Point_3<Kernel>& 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();
}
};

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

template <int Dim, class IT>
void _filter_covered( IT ibegin, IT iend, GeometrySet<Dim>& output )
void _filter_covered(IT ibegin, IT iend, GeometrySet<Dim>& output)
{
for ( IT it = ibegin; it != iend; ++it ) {
GeometrySet<Dim> 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<Dim> v1;
v1.addPrimitive(it->primitive());
std::auto_ptr<SFCGAL::Geometry> g1 = v1.recompose();

bool v1_covered = false;
for (IT it2 = it; it2 != iend; ++it2)
{
if (it == it2)
{
continue;
}

GeometrySet<Dim> v2;
v2.addPrimitive(it2->primitive());

bool b = false;
if (g1->is3D())
{
std::auto_ptr<SFCGAL::Geometry> g2 = v2.recompose();
if (g2->is3D())
{
b = algorithm::covers3D(*g2,*g1);
}

GeometrySet<Dim> 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<SFCGAL::Geometry> 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 <>
Expand Down

0 comments on commit 0716a81

Please sign in to comment.