add export eigen edge matrix from CMesh

This commit is contained in:
alemuntoni 2021-10-25 10:41:58 +02:00
parent fb7e1ec7e2
commit 77097029db
2 changed files with 27 additions and 0 deletions

View File

@ -555,6 +555,32 @@ Eigen::MatrixX3i meshlab::faceMatrix(const CMeshO& mesh)
return faces;
}
/**
* @brief Get a #E*2 Eigen matrix of integers containing the vertex indices of
* the edges of a CMeshO.
* The edges in the mesh must be compact (no deleted edges).
* If the mesh is not compact, a vcg::MissingCompactnessException will be thrown.
*
* @param mesh: input mesh
* @return #E*2 matrix of integers (vertex indices composing the edges)
*/
Eigen::MatrixX2i meshlab::edgeMatrix(const CMeshO& mesh)
{
vcg::tri::RequireEdgeCompactness(mesh);
// create eigen matrix of edges
Eigen::MatrixXi edges(mesh.EN(), 2);
// copy faces
for (int i = 0; i < mesh.EN(); i++) {
for (int j = 0; j < 2; j++) {
edges(i, j) = (int) vcg::tri::Index(mesh, mesh.edge[i].V(j));
}
}
return edges;
}
/**
* @brief Get a #F list of Eigen vectors of integers containing the vertex indices of
* the polygonal mesh contained in the CMeshO mesh.

View File

@ -82,6 +82,7 @@ void addFaceVectorAttribute(
// From CMeshO to Eigen
EigenMatrixX3m vertexMatrix(const CMeshO& mesh);
Eigen::MatrixX3i faceMatrix(const CMeshO& mesh);
Eigen::MatrixX2i edgeMatrix(const CMeshO& mesh);
std::list<EigenVectorXui> polygonalFaceList(const CMeshO& mesh);
EigenMatrixX3m vertexNormalMatrix(const CMeshO& mesh);
EigenMatrixX3m faceNormalMatrix(const CMeshO& mesh);