CGAL / cgal

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

Isotropic remeshing creates self intersections #8134

Open ning-zelin opened 2 months ago

ning-zelin commented 2 months ago

Isotropic remeshing creates self intersections

Issue Details

My tests using the following data found that self-intersections were produced after remesh, even if I set do_collapse(false).

Source Code

if(PMP::does_self_intersect(mesh)){
  std::cout<<"input mesh self-intersect"<<std::endl;
}
PMP::isotropic_remeshing(faces(mesh), 0.3, mesh,
                         CGAL::parameters::number_of_iterations(10)
                                          .protect_constraints(true).do_collapse(false)); //i.e. protect border, here
if(PMP::does_self_intersect(mesh)){
  std::cout<<"out-put mesh self-intersect"<<std::endl;
}
sloriot commented 2 months ago

@janetournois It seems to come from the projection step. The vertex 2459 is very close to a face in the input: image In the output, I guess it gets projected onto the face rather that the original vertex (probably because of the smoothing that moves it). I'm not sure we can do much in such a case. For sure adding that vertex as constrained vertex would fix the issue, but it's a "manual" fix.

As it seems the mesh was not combinatorially modified near that vertex, maybe the smoothing should only apply to modified regions?

ning-zelin commented 2 months ago

But it still has self-intersections after setting do_projection to false.

  PMP::isotropic_remeshing(faces(mesh), 0.3, mesh,
                           CGAL::parameters::number_of_iterations(10)
                                            .protect_constraints(true).do_project(false)); 
sloriot commented 2 months ago

As I tried to say, I guess that the smoothing moves the vertex across the face and the projection put it on the face.

sloriot commented 2 months ago

You can try disabling the smoothing

ning-zelin commented 2 months ago

As I tried to say, I guess that the smoothing moves the vertex across the face and the projection put it on the face.

Thanks. I set number_of_relaxation_steps(0), and the problem was solved.

ning-zelin commented 2 months ago

As I tried to say, I guess that the smoothing moves the vertex across the face and the projection put it on the face.

Thanks. I set number_of_relaxation_steps(0), and the problem was solved.

Thank you very much for your assistance. I conducted further tests, and although probability of occurrence is less, it still doesn't resolve all cases.

  PMP::isotropic_remeshing(faces(merge_mesh), 0.3, merge_mesh,
                           CGAL::parameters::number_of_iterations(3).number_of_relaxation_steps(0).do_project(false) 

merged_43.zip

janetournois commented 1 month ago

Hello @ning-zelin The example functor I proposed in PR #8210 above is not 100% reliable for your problem, but it works and avoids creation of self-intersections on your data

ning-zelin commented 1 month ago

Hello @janetournois Thank you for your response. Could you please advise if there is any method or engineering trick that could fully resolve this issue? Thank you again for your assistance!