From dd229eb2e99e8d6da2e88a7b834dfd7622b88fba Mon Sep 17 00:00:00 2001 From: Marco Callieri Date: Mon, 4 Jun 2018 14:24:09 +0200 Subject: [PATCH] "only on selection" now works properly for depth smooth --- .../filter_unsharp/filter_unsharp.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp b/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp index 0ee506bc8..6b388e142 100644 --- a/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp +++ b/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp @@ -316,12 +316,13 @@ void FilterUnsharp::initParameterSet(QAction *action, MeshDocument &md, RichPara parlst.addParam(new RichInt ("stepSmoothNum", (int) 3,"Smoothing steps", "The number of times that the whole algorithm (normal smoothing + vertex fitting) is iterated.")); parlst.addParam(new RichBool ("Boundary",true,"1D Boundary Smoothing", "If true the boundary edges are smoothed only by themselves (e.g. the polyline forming the boundary of the mesh is independently smoothed). Can reduce the shrinking on the border but can have strange effects on very small boundaries.")); parlst.addParam(new RichBool ("cotangentWeight",true,"Cotangent weighting", "If true the cotangente weighting scheme is computed for the averaging of the position. Otherwise (false) the simpler umbrella scheme (1 if the edge is present) is used.")); - parlst.addParam(new RichBool ("Selected",md.mm()->cm.sfn>0,"Affect only selected faces","If checked the filter is performed only on the selected faces")); + parlst.addParam(new RichBool("Selected", md.mm()->cm.sfn>0, "Affect only selection", "If checked the filter is performed only on the selected area")); break; case FP_DEPTH_SMOOTH: - parlst.addParam(new RichInt ("stepSmoothNum", (int) 3,"Smoothing steps", "The number of times that the whole algorithm (normal smoothing + vertex fitting) is iterated.")); - parlst.addParam(new RichPoint3f ("viewPoint", Point3f(0,0,0),"Viewpoint", "The position of the view point that is used to get the constraint direction.")); - parlst.addParam(new RichBool ("Selected",md.mm()->cm.sfn>0,"Affect only selected faces","If checked the filter is performed only on the selected faces")); + parlst.addParam(new RichInt ("stepSmoothNum", (int) 3,"Smoothing steps", "The number of times that the whole algorithm (normal smoothing + vertex fitting) is iterated.")); + parlst.addParam(new RichPoint3f ("viewPoint", Point3f(0,0,0),"Viewpoint", "The position of the view point that is used to get the constraint direction.")); + parlst.addParam(new RichAbsPerc ("delta", 1.0, 0, 1.0, "Strength", "How much smoothign is applied: 0 (no smoot) e 1 (full smoot)")); + parlst.addParam(new RichBool ("Selected",md.mm()->cm.sfn>0,"Affect only selection","If checked the filter is performed only on the selected area")); break; case FP_DIRECTIONAL_PRESERVATION: parlst.addParam(new RichEnum("step", 0, @@ -407,19 +408,20 @@ bool FilterUnsharp::applyFilter(QAction *filter, MeshDocument &md, RichParameter if(!boundarySmooth) tri::UpdateFlags::FaceClearB(m.cm); tri::Smooth::VertexCoordLaplacian(m.cm,stepSmoothNum,Selected,cotangentWeight,cb); - Log( "Smoothed %d vertices", Selected>0 ? m.cm.svn : m.cm.vn); + Log( "Smoothed %d vertices", Selected ? m.cm.svn : m.cm.vn); m.UpdateBoxAndNormals(); } break; case FP_DEPTH_SMOOTH : { int stepSmoothNum = par.getInt("stepSmoothNum"); - size_t cnt=tri::UpdateSelection::VertexFromFaceStrict(m.cm); - //float delta = par.getAbsPerc("delta"); + bool Selected = par.getBool("Selected"); + if (Selected && m.cm.svn == 0) + m.cm.svn = tri::UpdateSelection::VertexFromFaceStrict(m.cm); + float delta = par.getAbsPerc("delta"); Point3m viewpoint = par.getPoint3m("viewPoint"); - float alpha = 1; - tri::Smooth::VertexCoordViewDepth(m.cm,viewpoint,alpha,stepSmoothNum,true); - Log( "depth Smoothed %d vertices", cnt>0 ? cnt : m.cm.vn); + tri::Smooth::VertexCoordViewDepth(m.cm, viewpoint, delta, stepSmoothNum, Selected,true); + Log("depth Smoothed %d vertices", Selected ? m.cm.svn : m.cm.vn); m.UpdateBoxAndNormals(); } break;