CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.99k stars 1.39k forks source link

Obj file simplification process error #4183

Closed simonasdmd closed 5 years ago

simonasdmd commented 5 years ago

Please use the following template to help us solving your issue.

Issue Details

I simplified the obj file according to the documentation. However, an abnormality was found in the process. I hope to be corrected. The obj file has been successfully read. But there was a problem during the simplification process. Causes the program to be interrupted.

Source Code

main.txt

Environment

testdata: test_obj.zip

I hope to be corrected. I thank you from the heart.

afabri commented 5 years ago

Hello, I loaded the mesh into the Polyhedron demo. It is not really a 2-manifold as there are geometric edges with more than two incident patches. The mesh simplification algorithm then simplifies individual patches that is there is no guarantee that a shared geometric (and hence duplicated) edge gets the same treatment in the different patches. Note also that when you have objects with sharp features you probably should mark them as non-collapsible.

simonasdmd commented 5 years ago

How should I fix this problem? Is there a problem with my code? Can you help me with the correction?

afabri commented 5 years ago

As your mesh is not a two-manifold, but several two-manifolds that share geometric edges, the CGAL mesh simplification algorithm is not powerful enough for what you want to achieve.

simonasdmd commented 5 years ago

Will this be supported later?

sloriot commented 5 years ago

Actually it should be working. In your code you should have:

namespace PMP = CGAL::Polygon_mesh_processing;      
if (!PMP::is_polygon_soup_a_polygon_mesh(faces))
  PMP::orient_polygon_soup(points, faces);

then calling simplify should work without pb, except that non-manifold edges are duplicated and might be collapsed independently.

I try running it on my computer and I could simplify it.

Note that the changes in https://github.com/CGAL/cgal/pull/4069 were needed (now integrated in master) to read the file.

simonasdmd commented 5 years ago

thanks~