added missing iteration control inthe hc laplacian smoothing
This commit is contained in:
parent
70d3ccfa23
commit
fde38e0612
|
@ -507,53 +507,56 @@ static void VertexCoordLaplacianHC(MeshType &m, int step, bool SmoothSelected=fa
|
||||||
lpz.sum=CoordType(0,0,0);
|
lpz.sum=CoordType(0,0,0);
|
||||||
lpz.dif=CoordType(0,0,0);
|
lpz.dif=CoordType(0,0,0);
|
||||||
lpz.cnt=0;
|
lpz.cnt=0;
|
||||||
SimpleTempData<typename MeshType::VertContainer,HCSmoothInfo > TD(m.vert,lpz);
|
for(int i=0;i<step;++i)
|
||||||
// First Loop compute the laplacian
|
|
||||||
FaceIterator fi;
|
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi)if(!(*fi).IsD())
|
|
||||||
{
|
{
|
||||||
for(int j=0;j<3;++j)
|
SimpleTempData<typename MeshType::VertContainer,HCSmoothInfo > TD(m.vert,lpz);
|
||||||
{
|
// First Loop compute the laplacian
|
||||||
TD[(*fi).V(j)].sum+=(*fi).V1(j)->P();
|
FaceIterator fi;
|
||||||
TD[(*fi).V1(j)].sum+=(*fi).V(j)->P();
|
for(fi=m.face.begin();fi!=m.face.end();++fi)if(!(*fi).IsD())
|
||||||
++TD[(*fi).V(j)].cnt;
|
{
|
||||||
++TD[(*fi).V1(j)].cnt;
|
for(int j=0;j<3;++j)
|
||||||
// se l'edge j e' di bordo si deve sommare due volte
|
{
|
||||||
if((*fi).IsB(j))
|
TD[(*fi).V(j)].sum+=(*fi).V1(j)->P();
|
||||||
{
|
TD[(*fi).V1(j)].sum+=(*fi).V(j)->P();
|
||||||
TD[(*fi).V(j)].sum+=(*fi).V1(j)->P();
|
++TD[(*fi).V(j)].cnt;
|
||||||
TD[(*fi).V1(j)].sum+=(*fi).V(j)->P();
|
++TD[(*fi).V1(j)].cnt;
|
||||||
++TD[(*fi).V(j)].cnt;
|
// se l'edge j e' di bordo si deve sommare due volte
|
||||||
++TD[(*fi).V1(j)].cnt;
|
if((*fi).IsB(j))
|
||||||
|
{
|
||||||
|
TD[(*fi).V(j)].sum+=(*fi).V1(j)->P();
|
||||||
|
TD[(*fi).V1(j)].sum+=(*fi).V(j)->P();
|
||||||
|
++TD[(*fi).V(j)].cnt;
|
||||||
|
++TD[(*fi).V1(j)].cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
VertexIterator vi;
|
||||||
}
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi) if(!(*vi).IsD())
|
||||||
VertexIterator vi;
|
TD[*vi].sum/=(float)TD[*vi].cnt;
|
||||||
for(vi=m.vert.begin();vi!=m.vert.end();++vi) if(!(*vi).IsD())
|
|
||||||
TD[*vi].sum/=(float)TD[*vi].cnt;
|
// Second Loop compute average difference
|
||||||
|
for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD())
|
||||||
// Second Loop compute average difference
|
{
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD())
|
for(int j=0;j<3;++j)
|
||||||
{
|
{
|
||||||
for(int j=0;j<3;++j)
|
TD[(*fi).V(j)].dif +=TD[(*fi).V1(j)].sum-(*fi).V1(j)->P();
|
||||||
{
|
TD[(*fi).V1(j)].dif+=TD[(*fi).V(j)].sum-(*fi).V(j)->P();
|
||||||
TD[(*fi).V(j)].dif +=TD[(*fi).V1(j)].sum-(*fi).V1(j)->P();
|
// se l'edge j e' di bordo si deve sommare due volte
|
||||||
TD[(*fi).V1(j)].dif+=TD[(*fi).V(j)].sum-(*fi).V(j)->P();
|
if((*fi).IsB(j))
|
||||||
// se l'edge j e' di bordo si deve sommare due volte
|
{
|
||||||
if((*fi).IsB(j))
|
TD[(*fi).V(j)].dif +=TD[(*fi).V1(j)].sum-(*fi).V1(j)->P();
|
||||||
{
|
TD[(*fi).V1(j)].dif+=TD[(*fi).V(j)].sum-(*fi).V(j)->P();
|
||||||
TD[(*fi).V(j)].dif +=TD[(*fi).V1(j)].sum-(*fi).V1(j)->P();
|
}
|
||||||
TD[(*fi).V1(j)].dif+=TD[(*fi).V(j)].sum-(*fi).V(j)->P();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
{
|
{
|
||||||
TD[*vi].dif/=(float)TD[*vi].cnt;
|
TD[*vi].dif/=(float)TD[*vi].cnt;
|
||||||
if(!SmoothSelected || (*vi).IsS())
|
if(!SmoothSelected || (*vi).IsS())
|
||||||
(*vi).P()= TD[*vi].sum - (TD[*vi].sum - (*vi).P())*beta + (TD[*vi].dif)*(1.f-beta);
|
(*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.
|
// Laplacian smooth of the quality.
|
||||||
|
@ -1097,6 +1100,9 @@ static void FaceNormalAngleThreshold(MeshType &m,
|
||||||
if(! (*ep.f).IsV() )
|
if(! (*ep.f).IsV() )
|
||||||
{
|
{
|
||||||
ScalarType cosang=ep.f->N().dot((*fi).N());
|
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)
|
if(cosang >= sigma)
|
||||||
{
|
{
|
||||||
ScalarType w = 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
|
// 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;
|
PDVertInfo lpzv;
|
||||||
lpzv.np=CoordType(0,0,0);
|
lpzv.np=CoordType(0,0,0);
|
||||||
PDFaceInfo lpzf;
|
PDFaceInfo lpzf;
|
||||||
lpzf.m=CoordType(0,0,0);
|
lpzf.m=CoordType(0,0,0);
|
||||||
|
|
||||||
assert(m.HasVFTopology());
|
assert(HasVFAdjacency(m));
|
||||||
m.HasVFTopology();
|
|
||||||
SimpleTempData< typename MeshType::VertContainer, PDVertInfo> TDV(m.vert,lpzv);
|
SimpleTempData< typename MeshType::VertContainer, PDVertInfo> TDV(m.vert,lpzv);
|
||||||
SimpleTempData< typename MeshType::FaceContainer, PDFaceInfo> TDF(m.face,lpzf);
|
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);
|
FaceNormalAngleThreshold(m,TDF,Sigma);
|
||||||
|
|
||||||
for(int j=0;j<FitStep;++j)
|
for(int j=0;j<FitStep;++j)
|
||||||
|
|
Loading…
Reference in New Issue