From 5565647e82cbdfad965451c5d322d31385a11cec Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 3 Nov 2014 14:36:58 +0000 Subject: [PATCH] Added two functions VertexFromAttributeHandle and FaceFromAttributeHandle to map a pervertex/perface scalar handle into the quality --- vcg/complex/algorithms/update/quality.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/vcg/complex/algorithms/update/quality.h b/vcg/complex/algorithms/update/quality.h index e8c1f0d9..ac20f8b1 100644 --- a/vcg/complex/algorithms/update/quality.h +++ b/vcg/complex/algorithms/update/quality.h @@ -56,7 +56,6 @@ public: typedef typename MeshType::FacePointer FacePointer; typedef typename MeshType::FaceIterator FaceIterator; - /** Assign to each vertex of the mesh a constant quality value. Useful for initialization. */ static void VertexConstant(MeshType &m, float q) @@ -69,13 +68,12 @@ static void VertexConstant(MeshType &m, float q) /** Clamp each vertex of the mesh with a range of values. */ static void VertexClamp(MeshType &m, - typename MeshType::ScalarType qmin, - typename MeshType::ScalarType qmax) + typename MeshType::VertexType::QualityType qmin, + typename MeshType::VertexType::QualityType qmax) { tri::RequirePerVertexQuality(m); - for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) - if(!(*vi).IsD()) - (*vi).Q()=std::min(qmax, std::max(qmin,typename MeshType::ScalarType((*vi).Q()))); + for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) if(!(*vi).IsD()) + (*vi).Q()=std::min(qmax, std::max(qmin,(*vi).Q())); } /** Normalize the vertex quality so that it fits in the specified range. @@ -145,6 +143,21 @@ static void VertexFromFace( MeshType &m, bool areaWeighted=true) } } +template +static void VertexFromAttributeHandle(MeshType &m, typename MeshType::template PerVertexAttributeHandle &h) +{ + for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) + if(!(*vi).IsD()) + (*vi).Q()=ScalarType(h[vi]); +} + +template +static void FaceFromAttributeHandle(MeshType &m, typename MeshType::template PerFaceAttributeHandle &h) +{ + for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD()) + (*fi).Q() =h[fi]; +} + static void FaceFromVertex( MeshType &m) { tri::RequirePerFaceQuality(m);