diff --git a/vcg/complex/trimesh/update/quality.h b/vcg/complex/trimesh/update/quality.h index b83a620c..e950ba4c 100644 --- a/vcg/complex/trimesh/update/quality.h +++ b/vcg/complex/trimesh/update/quality.h @@ -189,6 +189,28 @@ static void VertexClamp(MeshType &m, float qmin, float qmax) (*vi).Q()=std::min(qmax, std::max(qmin,(*vi).Q())); } +/** Normalize the vertex quality so that it fits in the specified range. +*/ +static void VertexNormalize(MeshType &m, float qmin=0.0, float qmax=1.0) +{ + ScalarType deltaRange = qmax-qmin; + std::pair minmax = tri::Stat::ComputePerVertexQualityMinMax(m); + VertexIterator vi; + for(vi = m.vert.begin(); vi != m.vert.end(); ++vi) + (*vi).Q() = qmin+deltaRange*((*vi).Q() - minmax.first)/(minmax.second - minmax.first); +} + +/** Normalize the face quality so that it fits in the specified range. +*/ +static void FaceNormalize(MeshType &m, float qmin=0.0, float qmax=1.0) +{ + ScalarType deltaRange = qmax-qmin; + std::pair minmax = tri::Stat::ComputePerFaceQualityMinMax(m); + FaceIterator fi; + for(fi = m.face.begin(); fi != m.face.end(); ++fi) + (*fi).Q() = qmin+deltaRange*((*fi).Q() - minmax.first)/(minmax.second - minmax.first); +} + /** Assign to each face of the mesh a constant quality value. Useful for initialization. */ static void FaceConstant(MeshType &m, float q)