added missing iteration control inthe hc laplacian smoothing

This commit is contained in:
Paolo Cignoni 2009-06-11 23:56:06 +00:00
parent 70d3ccfa23
commit fde38e0612
1 changed files with 52 additions and 47 deletions

View File

@ -507,6 +507,8 @@ static void VertexCoordLaplacianHC(MeshType &m, int step, bool SmoothSelected=fa
lpz.sum=CoordType(0,0,0);
lpz.dif=CoordType(0,0,0);
lpz.cnt=0;
for(int i=0;i<step;++i)
{
SimpleTempData<typename MeshType::VertContainer,HCSmoothInfo > TD(m.vert,lpz);
// First Loop compute the laplacian
FaceIterator fi;
@ -554,6 +556,7 @@ static void VertexCoordLaplacianHC(MeshType &m, int step, bool SmoothSelected=fa
if(!SmoothSelected || (*vi).IsS())
(*vi).P()= TD[*vi].sum - (TD[*vi].sum - (*vi).P())*beta + (TD[*vi].dif)*(1.f-beta);
}
} // end for step
};
// Laplacian smooth of the quality.
@ -1097,6 +1100,9 @@ static void FaceNormalAngleThreshold(MeshType &m,
if(! (*ep.f).IsV() )
{
ScalarType cosang=ep.f->N().dot((*fi).N());
// Note that if two faces form an angle larger than 90 deg, their contribution should be very very small.
// Without this clamping
cosang = math::Clamp(cosang,0.0001f,1.f);
if(cosang >= sigma)
{
ScalarType w = cosang-sigma;
@ -1269,19 +1275,18 @@ static void VertexCoordPasoDoble(MeshType &m, int step, typename MeshType::Scala
// The sigma parameter affect the normal smoothing step
static void VertexCoordPasoDobleFast(MeshType &m, int step, typename MeshType::ScalarType Sigma=0, int FitStep=50, bool SmoothSelected =false)
static void VertexCoordPasoDobleFast(MeshType &m, int NormalSmoothStep, typename MeshType::ScalarType Sigma=0, int FitStep=50, bool SmoothSelected =false)
{
PDVertInfo lpzv;
lpzv.np=CoordType(0,0,0);
PDFaceInfo lpzf;
lpzf.m=CoordType(0,0,0);
assert(m.HasVFTopology());
m.HasVFTopology();
assert(HasVFAdjacency(m));
SimpleTempData< typename MeshType::VertContainer, PDVertInfo> TDV(m.vert,lpzv);
SimpleTempData< typename MeshType::FaceContainer, PDFaceInfo> TDF(m.face,lpzf);
for(int j=0;j<step;++j)
for(int j=0;j<NormalSmoothStep;++j)
FaceNormalAngleThreshold(m,TDF,Sigma);
for(int j=0;j<FitStep;++j)