CGAL::Polygon_mesh_processing::clip returns self itersecting mesh

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CGAL::Polygon_mesh_processing::clip returns self itersecting mesh

slidertom
Hello,
I use
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Surface_mesh;
from file:
mesh1.off <http://cgal-discuss.949826.n4.nabble.com/file/t376129/mesh1.off>  
mesh1.off is clipped with plane:
K::Point_3 plane_pt(0., 2., 0.);
K::Vector_3 plane_norm(-0.09, 0.09, 0.);
CGAL::Plane_3<K> plane(plane_pt, plane_norm);
CGAL::Polygon_mesh_processing::clip(mesh, plane,
CGAL::Polygon_mesh_processing::parameters::clip_volume(true).use_compact_clipper(true));
result is:
mesh2.off <http://cgal-discuss.949826.n4.nabble.com/file/t376129/mesh2.off>  
and
CGAL::Polygon_mesh_processing::does_self_intersect(mesh);
-> returns true.

I can not understand, why do I get self intersecting mesh.
If mesh2.off is exported to the polygon soup and converted back into the
Surface_mesh -> does_self_intersect returns false in this case -> situation
is fixed.

Expectation: Polygon_mesh_processing::clip should returned closed, non-self
intersecting surface.

Maybe I'm doing something wrong?

Tomas



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: CGAL::Polygon_mesh_processing::clip returns self itersecting mesh

Sebastien Loriot (GeometryFactory)
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: CGAL::Polygon_mesh_processing::clip returns self itersecting mesh

slidertom
Hi,
thank you for the  std::setprecision(17) note.
I've updated output file:
mesh1.off <http://cgal-discuss.949826.n4.nabble.com/file/t376129/mesh1.off>  
and created minimal sample:
static void TestMeshClip() {
   Surface_mesh mesh;
   std::fstream inputOffFile("mesh1.off");
   inputOffFile >> mesh;

   ASSERT(CGAL::is_closed(mesh));
   ASSERT(!CGAL::Polygon_mesh_processing::does_self_intersect(mesh));

   //K::Point_3 plane_pt(0., 2., 0.);
   //K::Vector_3 plane_norm(-0.09, 0.09, 0.); // 45 degree cut
   K::Point_3 plane_pt(0., 0.19999999999999987, 0.);
   K::Vector_3 plane_norm(-0.089999999999999858, 0.089999999999999858, 0.);
// 45 degree cut
   CGAL::Plane_3<K> plane(plane_pt, plane_norm);
   VERIFY(CGAL::Polygon_mesh_processing::clip(mesh, plane,
           
CGAL::Polygon_mesh_processing::parameters::clip_volume(true).use_compact_clipper(true)));

   if ( CGAL::Polygon_mesh_processing::does_self_intersect(mesh) ) {
       ASSERT(FALSE); // mesh can not be self intersecting!
   }
}

If I use ->
K::Point_3 plane_pt(0., 2., 0.);
K::Vector_3 plane_norm(-0.09, 0.09, 0.); // 45 degree cut
-> this case: does_self_intersect => false
 
If I use:
K::Point_3 plane_pt(0., 0.19999999999999987, 0.);
K::Vector_3 plane_norm(-0.089999999999999858, 0.089999999999999858, 0.); //
45 degree cut
-> this case: does_self_intersect => true

this is almost... :) the same.  Maybe some preconditions exists for the
plane construction?





--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: CGAL::Polygon_mesh_processing::clip returns self itersecting mesh

slidertom
I miss typed:
//K::Point_3 plane_pt(0., 2., 0.);  
it must be:
//K::Point_3 plane_pt(0., 0.2, 0.);
as:
  K::Point_3 plane_pt(0., 0.19999999999999987, 0.);

Just realized, this is probably "edge/rounding" issue:
(0., 2., 0.) generates plane which touch edge
and
(0., 0.19999999999999987, 0.) generates plane which is inside mesh.

CGAL does very precise calculations and result is self intersecting mesh.



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: CGAL::Polygon_mesh_processing::clip returns self itersecting mesh

Sebastien Loriot (GeometryFactory)
CONTENTS DELETED
The author has deleted this message.