From 8b49a7803a34afac96fbbc0deb2a083e331758ac Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Fri, 16 Jun 2017 11:51:26 +0200 Subject: [PATCH] Added management of selection in laplacian smoothing for remeshing --- vcg/complex/algorithms/isotropic_remeshing.h | 37 ++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/vcg/complex/algorithms/isotropic_remeshing.h b/vcg/complex/algorithms/isotropic_remeshing.h index 7a762651..afb5f888 100644 --- a/vcg/complex/algorithms/isotropic_remeshing.h +++ b/vcg/complex/algorithms/isotropic_remeshing.h @@ -646,18 +646,35 @@ private: return count; } - /* - Simple Laplacian Smoothing step - Border and crease vertices are kept fixed. - */ + /** + * Simple Laplacian Smoothing step + * Border and crease vertices are kept fixed. + * If there are selected faces and the param.onlySelected is true we compute + * the set of internal vertices to the selection and we combine it in and with + * the vertexes not on border or creases + */ static void ImproveByLaplacian(MeshType &m, Params params) { - tri::UpdateTopology::FaceFace(m); - tri::UpdateFlags::VertexBorderFromFaceAdj(m); - tri::UpdateSelection::VertexFromBorderFlag(m); - selectVertexFromCrease(m, params.creaseAngleCosThr); - tri::UpdateSelection::VertexInvert(m); - tri::Smooth::VertexCoordPlanarLaplacian(m,1,params.creaseAngleRadThr,true); - tri::UpdateSelection::VertexClear(m); + SelectionStack ss(m); + + if(params.selectedOnly) { + ss.push(); + tri::UpdateSelection::VertexFromFaceStrict(m); + ss.push(); + } + tri::UpdateTopology::FaceFace(m); + tri::UpdateFlags::VertexBorderFromFaceAdj(m); + tri::UpdateSelection::VertexFromBorderFlag(m); + selectVertexFromCrease(m, params.creaseAngleCosThr); + tri::UpdateSelection::VertexInvert(m); + if(params.selectedOnly) { + ss.popAnd(); + } + tri::Smooth::VertexCoordPlanarLaplacian(m,1,params.creaseAngleRadThr,true); + tri::UpdateSelection::VertexClear(m); + if(params.selectedOnly) { + ss.pop(); + } } /* Reprojection step, this method reprojects each vertex on the original surface