CGAL::Polygon_mesh_processing:


Re: CGAL::Polygon_mesh_processing:

As of today, there is no guarantee that the output of the algorithm will
be free from selfintersection. The algorithm returns a mesh with a valid graph topology but since points are rounded from an exact rational representation to a floating point one, it might happen that some selfintersections are created during the rounding. The first thing to do it to make sure that if you write the mesh, you use the highest precision (to avoid another rounding) using std::setprecision(17) in your stream. An option to increase the precision of the rounding is to use an exact vertex point map, and call CGAL::exact() on each vertex point before doing the rounding (it will increase the precision but you are still left without guarantees). We are currently working to avoid the rounding issue but nothing is ready to be distributed for now. Sebastien. On 1/23/20 5:10 PM, slidertom wrote: > 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://cgaldiscuss.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://cgaldiscuss.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, nonself > intersecting surface. > > Maybe I'm doing something wrong? > > Tomas > > > >  > Sent from: http://cgaldiscuss.949826.n4.nabble.com/ >  You are currently subscribed to cgaldiscuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgaldiscuss 
Hi,
thank you for the std::setprecision(17) note. I've updated output file: mesh1.off <http://cgaldiscuss.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://cgaldiscuss.949826.n4.nabble.com/  You are currently subscribed to cgaldiscuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgaldiscuss 
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://cgaldiscuss.949826.n4.nabble.com/  You are currently subscribed to cgaldiscuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgaldiscuss 
For the clipping there is a double rounding issue:
It first cut the extended bbox of the mesh with the plane (first rounding) and then do the operation (second rounding). Sebastien. On 1/24/20 4:37 PM, slidertom wrote: > 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://cgaldiscuss.949826.n4.nabble.com/ >  You are currently subscribed to cgaldiscuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgaldiscuss 
Free forum by Nabble  Edit this page 