Added two functions VertexFromAttributeHandle and FaceFromAttributeHandle to map a pervertex/perface scalar handle into the quality

This commit is contained in:
Paolo Cignoni 2014-11-03 14:36:58 +00:00
parent b278f29129
commit 5565647e82
1 changed files with 19 additions and 6 deletions

View File

@ -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 <class HandleScalar>
static void VertexFromAttributeHandle(MeshType &m, typename MeshType::template PerVertexAttributeHandle<HandleScalar> &h)
{
for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
if(!(*vi).IsD())
(*vi).Q()=ScalarType(h[vi]);
}
template <class HandleScalar>
static void FaceFromAttributeHandle(MeshType &m, typename MeshType::template PerFaceAttributeHandle<HandleScalar> &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);