Added PerVertexArea and PerFaceArea to collect vectors of areas from a mesh

This commit is contained in:
Paolo Cignoni 2014-11-13 22:50:39 +00:00
parent c38743aaff
commit 1d79254dbc
1 changed files with 23 additions and 0 deletions

View File

@ -220,6 +220,29 @@ public:
return ret;
}
template< class VecType >
static void PerVertexArea(MeshType &m, VecType &h)
{
tri::RequireCompactness(m);
h.resize(m.vn);
for(int i=0;i<m.vn;++i) h[i]=0;
for(FaceIterator fi=m.face.begin(); fi!=m.face.end();++fi)
{
ScalarType a = DoubleArea(*fi)/6.0;
for(int j=0;j<fi->VN();++j)
h[tri::Index(m,fi->V(j))] += a;
}
}
template< class VecType >
static void PerFaceArea(MeshType &m, VecType &h)
{
tri::RequireCompactness(m);
h.resize(m.fn);
for(int i=0;i<m.fn;++i)
h[i] =DoubleArea(m.face[i])/2.0;
}
static void MassMatrixEntry(MeshType &m,
std::vector<std::pair<int,int> > &index,