BQ_
BQ_

Reputation: 60

Meshlab: How to update mesh after performing VertexCoordLaplacian() smoothing

I am currently developing a custom plugin in MeshLab. Based on the template edit_select, I am trying to use the VertexCoordLaplacian() function to perform Laplacian smoothing on the selected faces. The function runs successfully and outputs the result, but the updated mesh is not reflected in the MeshLab interface in real-time.

Here’s my code:

m.updateDataMask(MeshModel::MM_FACEFACETOPO);
vcg::tri::UpdateTopology<CMeshO>::FaceFace(m.cm);

m.updateDataMask(MeshModel::MM_VERTFACETOPO);
vcg::tri::UpdateTopology<CMeshO>::VertexFace(m.cm);

tri::UpdateFlags<CMeshO>::FaceBorderFromNone(m.cm);

// Update vertex selection based on selected faces
m.cm.svn = tri::UpdateSelection<CMeshO>::VertexFromFaceStrict(m.cm);

// Update data mask for coordinates
m.updateDataMask(MeshModel::MM_VERTCOORD);

tri::Smooth<CMeshO>::VertexCoordLaplacian(m.cm, 3, true, true); // Vertex smoothing

// Update bounding box and normals
m.updateBoxAndNormals();

// Update data mask to indicate modified vertices and normals
m.updateDataMask(
    MeshModel::MM_VERTCOORD |    // Vertex coordinates modified
    MeshModel::MM_VERTNORMAL |   // Vertex normals modified
    MeshModel::MM_FACENORMAL     // Face normals modified
);

I’m unsure if this approach is correct. Could anyone guide me on how to ensure the mesh is updated in real-time in MeshLab after performing operations like Laplacian smoothing?

Any suggestions or corrections would be greatly appreciated!

I have tried calling the filter_unsharp plugin within edit_select, but I failed.

I suspect the reason is that I haven't paid enough attention to the OpenGL-based mesh update mechanism in MeshLab. I also tried to trace the process of the FP_LAPLACIAN_SMOOTH mode in filter_unsharp, but I couldn't find where exactly it updates the mesh. This is a bit difficult for me. Can anyone help me?

Upvotes: 0

Views: 57

Answers (1)

Rockcat
Rockcat

Reputation: 3250

It is suppossed that a call to MainWindow::endEdit() or glarea::endEdit() has to be executed after you finish the changes in the mesh. This will execute a call to glarea::update() that make the actual redraw.

This call should be done automatically by the filter. Did you remember to make a call to startEdit() before of starting to change the mesh?

Upvotes: 0

Related Questions