CGAL / cgal

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

params::vertex_is_constrained_map setting in PMP::isotropic_remeshing does not set the corner points remain its position during remesh #8388

Open citystrawman opened 1 month ago

citystrawman commented 1 month ago

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

Issue Details

I am using PMP::isotropic_remeshing method to remesh a surface mesh. I have a vertex_is_constrained_map in which the corner points are set to be true.

Before isotropic_remeshing, the surface mesh is as follows: image

and the green points are corner points (for these vertices, vertex_is_constrained_map[vertex] = true )

However, after isotropic_remeshing, the corner points are not at the same position, which is not what I desire: image image

I use isotropic_remeshing to another example but that example works fine: the corner points all remains at its position: image I dont understand why the two isotropic_remeshing (I implement the two almost the same) results differently.

Source Code

//only part of the code is shown, because the code is a little long.

    std::vector<face_descriptor> sp_selected_faces;
    std::vector<bool> sp_is_selected(num_faces(mesh2_clip), false);
    for (edge_descriptor e : edges(mesh2_clip))
        if (sp_constrained_map[e])
        {
            // insert all faces incident to the target vertex
            for (halfedge_descriptor h : halfedges_around_target(halfedge(e, mesh2_clip), mesh2_clip))
            {
                if (!is_border(h, mesh2_clip))
                {
                    face_descriptor f = face(h, mesh2_clip);
                    if (!sp_is_selected[f])
                    {
                        sp_selected_faces.push_back(f);
                        sp_is_selected[f] = true;
                    }
                }
            }
        }
// increase the face selection
CGAL::expand_face_selection(sp_selected_faces, mesh2_clip, 2,
    Vector_pmap_wrapper(sp_is_selected), std::back_inserter(sp_selected_faces));

std::cout << sp_selected_faces.size()
    << " faces were selected for the remeshing step\n";

Mesh::Property_map<vertex_descriptor, bool> vertex_is_constrained_split =
    mesh2_clip.add_property_map<vertex_descriptor, bool>("v:is_constrained", false).first;

for each (vertex_descriptor v in v_constrained_vec_split)
{
    vertex_is_constrained_split[v] = true;
}

PMP::isotropic_remeshing(sp_selected_faces, target_edge_length, mesh2_clip, params::vertex_is_constrained_map(vertex_is_constrained_split));

mesh2_clip.collect_garbage();

CGAL::draw(mesh2_clip);

Environment

citystrawman commented 1 month ago

Hi @janetournois , I saw you have assigned this issue. Do you need the code and input files?

janetournois commented 1 month ago

Hello @citystrawman indeed the piece of code you sent is not enough to understand what's wrong in your code. I would need a standalone and the data to understand why vertex_is_constrained_map is not working

citystrawman commented 1 month ago

Hello @citystrawman indeed the piece of code you sent is not enough to understand what's wrong in your code. I would need a standalone and the data to understand why vertex_is_constrained_map is not working

Here's the code: clip_get_intersect_points_new_try_remove2.zip

Here's the input off model: model.zip

Because this code is my testing code, it is a bit long and has many intermediate processes, but you can find that I write out "slope_clip_before.off" and "slope_clip.off" which corresponds to the screenshot that I have shown, these two outputs are example that vertex_is_constrained_mapis not working. You can also find "slide_clip_before.off" and "slide_clip.off" , and these two outputs are example that vertex_is_constrained_map working fine.

If you have anything unclear, feel free to call me. Thank you!

citystrawman commented 1 month ago

Hello @citystrawman indeed the piece of code you sent is not enough to understand what's wrong in your code. I would need a standalone and the data to understand why vertex_is_constrained_map is not working

BTW I use 5.5.x version