Added Quality weighted laplacian smoothing
This commit is contained in:
parent
c22d64e65b
commit
62244759fc
|
@ -23,6 +23,9 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
History
|
History
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.11 2006/10/19 07:33:03 cignoni
|
||||||
|
Corrected Laplacian, Added selection to HCSmooth
|
||||||
|
|
||||||
Revision 1.10 2006/09/25 09:41:41 cignoni
|
Revision 1.10 2006/09/25 09:41:41 cignoni
|
||||||
Added new version of pasodoble smoothing
|
Added new version of pasodoble smoothing
|
||||||
|
|
||||||
|
@ -211,8 +214,12 @@ public:
|
||||||
FLT cnt;
|
FLT cnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Classical Laplacian Smoothing. Each vertex can be moved onto the average of the adjacent vertices.
|
||||||
|
// Can smooth only the selected vertices and weight the smoothing according to the quality
|
||||||
|
// In the latter case 0 means that the vertex is not moved and 1 means that the vertex is moved onto the computed position.
|
||||||
|
|
||||||
template<class MESH_TYPE>
|
template<class MESH_TYPE>
|
||||||
void LaplacianSmooth(MESH_TYPE &m, int step, bool SmoothSelected=false)
|
void LaplacianSmooth(MESH_TYPE &m, int step, bool SmoothSelected=false, float QualityWeight=0)
|
||||||
{
|
{
|
||||||
SimpleTempData<typename MESH_TYPE::VertContainer,LaplacianInfo<typename MESH_TYPE::ScalarType> > TD(m.vert);
|
SimpleTempData<typename MESH_TYPE::VertContainer,LaplacianInfo<typename MESH_TYPE::ScalarType> > TD(m.vert);
|
||||||
LaplacianInfo<typename MESH_TYPE::ScalarType> lpz;
|
LaplacianInfo<typename MESH_TYPE::ScalarType> lpz;
|
||||||
|
@ -263,6 +270,20 @@ void LaplacianSmooth(MESH_TYPE &m, int step, bool SmoothSelected=false)
|
||||||
++TD[(*fi).V1(j)].cnt;
|
++TD[(*fi).V1(j)].cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(QualityWeight>0)
|
||||||
|
{ // quality weighted smoothing
|
||||||
|
// We assume that weights are in the 0..1 range.
|
||||||
|
assert(tri::HasPerVertexQuality(m));
|
||||||
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
|
if(!(*vi).IsD() && TD[*vi].cnt>0 )
|
||||||
|
if(!SmoothSelected || (*vi).IsS())
|
||||||
|
{
|
||||||
|
float q=1.0-(*vi).Q();
|
||||||
|
(*vi).P()=(*vi).P()*(1.0-q) + (TD[*vi].sum/TD[*vi].cnt)*q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
if(!(*vi).IsD() && TD[*vi].cnt>0 )
|
if(!(*vi).IsD() && TD[*vi].cnt>0 )
|
||||||
if(!SmoothSelected || (*vi).IsS())
|
if(!SmoothSelected || (*vi).IsS())
|
||||||
|
@ -347,6 +368,8 @@ void HCSmooth(MESH_TYPE &m, int step, bool SmoothSelected=false )
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Laplacian smooth of the quality.
|
||||||
|
|
||||||
template<class FLT>
|
template<class FLT>
|
||||||
class QualitySmoothInfo
|
class QualitySmoothInfo
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue