CGAL::Polygon_mesh_processing:


Re: CGAL::Polygon_mesh_processing:

Your three meshes are selfintersecting. I try calling our
nondocumented function CGAL::Polygon_mesh_processing::remove_self_intersections() from CGAL/Polygon_mesh_processing/repair.h and at first sight it gives good repaired models. Sebastien. On 4/27/20 3:22 PM, stiklaz wrote: > Hello, > > i have mesh mesh_to_cut.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_to_cut.off> > and i want to cut two ends from it cut_end_1.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/cut_end_1.off> and > cut_end_2.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/cut_end_2.off> . > > so i am using > CGAL::Polygon_mesh_processing::corefine_and_compute_difference(..). > > when i cut single end: > CGAL::Polygon_mesh_processing::corefine_and_compute_difference(*mesh_to_cut, > *cut_end_1, *result); > or > CGAL::Polygon_mesh_processing::corefine_and_compute_difference(*mesh_to_cut, > *cut_end_2, *result); > > i get correct result mesh with single cut end. > > If i try to cut second end using result mesh from firs call: > CGAL::Polygon_mesh_processing::corefine_and_compute_difference(*mesh_to_cut, > *cut_end_1, *mesh_to_cut_2nd_end); > > mesh_to_cut_2nd_end.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_to_cut_2nd_end.off> > > CGAL::Polygon_mesh_processing::corefine_and_compute_difference(*mesh_to_cut_2nd_end, > *cut_end_2, *result); > > i get empty result shape and return false ( tm1_minus_tm2_is_valid() == > false ) > > I can not understand, what causes this failure. After first cut mesh end for > second cut is not even touched but somehow it is distorted and not valid for > second cut. > > Maybe I'm doing something wrong? > > > > >  > 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 
Sebastien Loriot (GeometryFactory) wrote
> Your three meshes are selfintersecting. I try calling our > nondocumented function > CGAL::Polygon_mesh_processing::remove_self_intersections() from > CGAL/Polygon_mesh_processing/repair.h and at first sight it gives > good repaired models. i have tried to call CGAL::Polygon_mesh_processing::remove_self_intersections() for all meshes before calling CGAL::Polygon_mesh_processing::corefine_and_compute_difference() and after for the intermediate result mesh i also tried to call CGAL::Polygon_mesh_processing::remove_degenerate_faces(*result); but still having the same invalid result when i try to call CGAL::Polygon_mesh_processing::corefine_and_compute_difference() for a second cut.  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 
Start by switching throw_on_self_intersection(true) in the named
parameters of corefine_and_XXX. Then you'll get an exception if you are trying to do something invalid. If you have selfintersections then try to fix them. I used the master version of remove_self_intersections() which might explain why you still have some. Sebastien. On 4/27/20 4:31 PM, stiklaz wrote: > Sebastien Loriot (GeometryFactory) wrote >> Your three meshes are selfintersecting. I try calling our >> nondocumented function >> CGAL::Polygon_mesh_processing::remove_self_intersections() from >> CGAL/Polygon_mesh_processing/repair.h and at first sight it gives >> good repaired models. > > i have tried to call > CGAL::Polygon_mesh_processing::remove_self_intersections() > for all meshes before calling > CGAL::Polygon_mesh_processing::corefine_and_compute_difference() > and after for the intermediate result mesh i also tried to call > CGAL::Polygon_mesh_processing::remove_degenerate_faces(*result); > but still having the same invalid result when i try to call > CGAL::Polygon_mesh_processing::corefine_and_compute_difference() for a > second cut. > > > > >  > 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 
Sebastien Loriot (GeometryFactory) wrote
> Start by switching throw_on_self_intersection(true) in the named > parameters of corefine_and_XXX. Then you'll get an exception if > you are trying to do something invalid. If you have selfintersections > then try to fix them. I used the master version of > remove_self_intersections() which might explain why you still have > some. I have tried to use remove_self_intersections() from the master version and also switched throw_on_self_intersection(true). I don`t get any exception so meshes are not self intersecting, but still having the same invalid result. Do you have any more ideas what`s can cause this?  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 
Could you create a gist.github.com containing the main.cpp you are using?
Thanks, Sebastien. On 4/29/20 11:31 AM, stiklaz wrote: > Sebastien Loriot (GeometryFactory) wrote >> Start by switching throw_on_self_intersection(true) in the named >> parameters of corefine_and_XXX. Then you'll get an exception if >> you are trying to do something invalid. If you have selfintersections >> then try to fix them. I used the master version of >> remove_self_intersections() which might explain why you still have >> some. > > I have tried to use remove_self_intersections() from the master version and > also switched throw_on_self_intersection(true). I don`t get any exception so > meshes are not self intersecting, but still having the same invalid result. > Do you have any more ideas what`s can cause this? > > > >  > 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 
Sebastien Loriot (GeometryFactory) wrote
> Could you create a gist.github.com containing the main.cpp you are using? It turns out i need to provide you original meshes not the ones i save, because after save/load they are slight different. After save/load meshes are somehow fixed and that`s why for you everything works. In my case, before saving, original meshes are not self intersecting, but after save / load they become self intersecting. Calling CGAL::Polygon_mesh_processing::experimental::remove_self_intersections() fixes self intersecting issue and CGAL::Polygon_mesh_processing::corefine_and_compute_difference(..) works as expected and gives correct result. Maybe you know what save/load does to the mesh and maybe there is some function to fix this kind of issue to avoid save/load (regenerate) 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 
To avoid unwanted rounding, try:
stream << std::setprecision(17) << my_mesh; Sebastien. On 4/30/20 1:15 PM, stiklaz wrote: > Sebastien Loriot (GeometryFactory) wrote >> Could you create a gist.github.com containing the main.cpp you are using? > > It turns out i need to provide you original meshes not the ones i save, > because after save/load they are slight different. > > After save/load meshes are somehow fixed and that`s why for you everything > works. > > In my case, before saving, original meshes are not self intersecting, but > after save / load they become self intersecting. > Calling > CGAL::Polygon_mesh_processing::experimental::remove_self_intersections() > fixes self intersecting issue > and CGAL::Polygon_mesh_processing::corefine_and_compute_difference(..) works > as expected and gives correct result. > > Maybe you know what save/load does to the mesh and maybe there is some > function to fix this kind of issue to avoid save/load (regenerate) 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 
Sebastien Loriot (GeometryFactory) wrote
> To avoid unwanted rounding, try: > > stream << std::setprecision(17) << my_mesh; Yes, now i get the same mesh after save/load. So here are the original meshes: mesh_end1.off <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_end1.off> mesh_end2.off <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_end2.off> mesh_main.off <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_main.off> and here is the code snippet where second cut fails: link <https://gist.github.com/stiklaz/39ee8ecf6827d25502900831d9f3e3aa>  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 
If you look at the return value of the function, it will tell you that
the second operation could not be computed. Looking in details, there is a small nonmanifold edge that prevents the operation to be performed. In you case, this happens because of rounding issues after the first operation. Two solutions: 1) you know that mesh_end1 and mesh_end2 are disjoint, you can call mesh_end1.join(mesh_end2) as in the attached example and do only one difference operation. 2) you have more operations to do and you want to use an exact vertex point map to avoid issues. The following example shows how to create an exact vertex point map that also maintains the rounded version: https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2corefinement_consecutive_bool_op_8cppexample.html Note that in your case your input was valid but if you have some nonmanifold edges in the output no result can be computed with the current version of the code. Best, Sebastien. On 4/30/20 3:40 PM, stiklaz wrote: > Sebastien Loriot (GeometryFactory) wrote >> To avoid unwanted rounding, try: >> >> stream << std::setprecision(17) << my_mesh; > > Yes, now i get the same mesh after save/load. > So here are the original meshes: > mesh_end1.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_end1.off> > mesh_end2.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_end2.off> > mesh_main.off > <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh_main.off> > > and here is the code snippet where second cut fails: link > <https://gist.github.com/stiklaz/39ee8ecf6827d25502900831d9f3e3aa> > > > > >  > 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 ex.cpp (985 bytes) Download Attachment 
Sebastien Loriot (GeometryFactory) wrote
> Two solutions: > 1) you know that mesh_end1 and mesh_end2 are disjoint, you can call > mesh_end1.join(mesh_end2) as in the attached example and do only one > difference operation. > > 2) you have more operations to do and you want to use an exact vertex > point map to avoid issues. The following example shows how to create > an exact vertex point map that also maintains the rounded version: > > https://doc.cgal.org/latest/Polygon_mesh_processing/Polygon_mesh_processing_2corefinement_consecutive_bool_op_8cppexample.html > > Note that in your case your input was valid but if you have some > nonmanifold edges in the output no result can be computed with > the current version of the code. Thank you! I have tried both solutions and both works and gives visually the same result. Result mesh looks almost good, but i get some almost zero depth parts: mesh.png <http://cgaldiscuss.949826.n4.nabble.com/file/t376212/mesh.png> Maybe there is some util to remove such parts? Also even with exact vertex point map solution the result mesh has some self intersections and remove_self_intersections(..) makes the result mesh look even worse.  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 