diff --git a/vcg/complex/algorithms/mesh_to_matrix.h b/vcg/complex/algorithms/mesh_to_matrix.h index 5b01853e..2a48a0a6 100644 --- a/vcg/complex/algorithms/mesh_to_matrix.h +++ b/vcg/complex/algorithms/mesh_to_matrix.h @@ -39,7 +39,9 @@ class MeshToMatrix // define types typedef typename MeshType::FaceType FaceType; + typedef typename MeshType::FaceIterator FaceIterator; typedef typename MeshType::VertexType VertexType; + typedef typename MeshType::VertexIterator VertexIterator; typedef typename MeshType::CoordType CoordType; typedef typename MeshType::ScalarType ScalarType; typedef typename Eigen::Matrix MatrixXm; @@ -218,27 +220,37 @@ public: } - static void MassMatrixEntry(MeshType &mesh, + static void MassMatrixEntry(MeshType &m, std::vector > &index, std::vector &entry) { - //calculate area - UpdateQuality::FaceArea(mesh); - //then distribute per vertex - UpdateQuality::VertexFromFace(mesh); + tri::RequireCompactness(m); - std::pair minmax=Stat::ComputePerVertexQualityMinMax(mesh); + typename MeshType::template PerVertexAttributeHandle h = + tri::Allocator:: template GetPerVertexAttribute(m, "area"); + for(size_t i=0;iVN();++j) + h[tri::Index(m,fi->V(j))] += a; + } + ScalarType maxA=0; + for(size_t i=0;i(currI,currI)); - entry.push_back(mesh.vert[i].Q()/(ScalarType)minmax.second); + entry.push_back(h[i]); } } + tri::Allocator::template DeletePerVertexAttribute(m,h); }