Visual Computing Library
Loading...
Searching...
No Matches
Export Mesh to Matrix Algorithms

List Export Mesh to Matrix algorithms. More...

Collaboration diagram for Export Mesh to Matrix Algorithms:

Functions

template<typename Vect , FaceMeshConcept MeshType>
Vect vcl::faceIndicesVector (const MeshType &mesh)
 Get a #V*3 Matrix of scalars containing the coordinates of the vertices of a Mesh. The function is templated on the Matrix itself.
 
template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
Matrix vcl::edgeIndicesMatrix (const MeshType &mesh)
 Get a #F*max(size(F)) Matrix of integers containing the vertex indices for each face of a Mesh.
 
template<uint ELEM_ID, MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::elementNormalsMatrix (const MeshType &mesh)
 Get a #E Vector of booleans (or integers) containing the selection status of the elements identified by ELEM_ID of a Mesh. The function is templated on the Vector itself.
 
template<MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::vertexNormalsMatrix (const MeshType &mesh)
 Get a #V*3 Matrix of scalars containing the normals of the vertices of a Mesh. The function is templated on the Matrix itself.
 
template<MatrixConcept Matrix, FaceMeshConcept MeshType>
Matrix vcl::faceNormalsMatrix (const MeshType &mesh)
 Get a #F*3 Matrix of scalars containing the normals of the faces of a Mesh. The function is templated on the Matrix itself.
 
template<uint ELEM_ID, MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::elementColorsMatrix (const MeshType &mesh)
 Get a #E*4 Matrix of integers containing the colors of the elements identified by ELEM_ID of a Mesh. The function is templated on the Matrix itself.
 
template<uint ELEM_ID, typename Vect , MeshConcept MeshType>
Vect vcl::elementColorsVector (const MeshType &mesh, Color::Format colorFormat)
 Get a #E Vector of integers containing the colors of the elements identified by ELEM_ID of a Mesh. The function is templated on the Vector itself. The color is packed in a single 32 bit value using the provided format.
 
template<MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::vertexColorsMatrix (const MeshType &mesh)
 Get a #V*4 Matrix of integers containing the colors of the vertices of a Mesh. The function is templated on the Matrix itself.
 
template<typename Vect , MeshConcept MeshType>
Vect vcl::vertexColorsVector (const MeshType &mesh, Color::Format colorFormat)
 Get a #V Vector of integers containing the colors of the vertices of a Mesh. The function is templated on the Vector itself. The color is packed in a single 32 bit value using the provided format.
 
template<MatrixConcept Matrix, FaceMeshConcept MeshType>
Matrix vcl::faceColorsMatrix (const MeshType &mesh)
 Get a #F*4 Matrix of integers containing the colors of the faces of a Mesh. The function is templated on the Matrix itself.
 
template<typename Vect , MeshConcept MeshType>
Vect vcl::faceColorsVector (const MeshType &mesh, Color::Format colorFormat)
 Get a #F Vector of integers containing the colors of the faces of a Mesh. The function is templated on the Vector itself. The color is packed in a single 32 bit value using the provided format.
 
template<uint ELEM_ID, typename Vect , MeshConcept MeshType>
Vect vcl::elementQualityVector (const MeshType &mesh)
 Get a #E Vector of scalars containing the quality of the elements identified by ELEM_ID of a Mesh. The function is templated on the Vector itself.
 
template<typename Vect , MeshConcept MeshType>
Vect vcl::vertexQualityVector (const MeshType &mesh)
 Get a #V Vector of scalars containing the quality of the vertices of a Mesh. The function is templated on the Vector itself.
 
template<typename Vect , FaceMeshConcept MeshType>
Vect vcl::faceQualityVector (const MeshType &mesh)
 Get a #F Vector of scalars containing the quality of the faces of a Mesh. The function is templated on the Vector itself.
 

Detailed Description

List Export Mesh to Matrix algorithms.

They allow to export mesh data to matrices.

You can access these algorithms by including #include <vclib/algorithms/mesh/import_export.h>

Function Documentation

◆ edgeIndicesMatrix()

template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
Matrix vcl::edgeIndicesMatrix ( const MeshType &  mesh)

Get a #F*max(size(F)) Matrix of integers containing the vertex indices for each face of a Mesh.

If the mesh is polygonal, the matrix will have a number of rows equal to the greatest polygon of the mesh, and unused values will be set to -1.

This function works with every Matrix type that satisfies the MatrixConcept.

Usage example with Eigen Matrix:

@endif
@throws vcl::MissingCompactnessException if the vertex container is not
compact.
@note This function does not guarantee that the rows of the matrix
correspond to the face indices of the mesh. This scenario is possible
when the mesh has deleted faces. To be sure to have a direct
correspondence, compact the face container before calling this function.
@tparam Matrix: type of the matrix to be returned, it must satisfy the
MatrixConcept.
@tparam MeshType: type of the input mesh, it must satisfy the
FaceMeshConcept.
@param[in] mesh: input mesh
@return \#F*max(size(F)) matrix of vertex indices
@ingroup export_matrix
/
template<MatrixConcept Matrix, FaceMeshConcept MeshType>
Matrix faceIndicesMatrix(const MeshType& mesh)
{
requireVertexContainerCompactness(mesh);
uint fMaxSize = largestFaceSize(mesh);
Matrix fM(mesh.faceNumber(), fMaxSize);
MatrixStorageType stg = matrixStorageType<Matrix>();
faceIndicesToBuffer(mesh, fM.data(), fMaxSize, stg);
return fM;
}
Exception thrown when the mesh is not compact.
Definition mesh.h:81
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
void faceIndicesToBuffer(const MeshType &mesh, auto *buffer, bool getIndicesAsIfContainerCompact=true)
Export into a buffer the vertex indices for each face of a Mesh. Faces can be polygons.
Definition export_buffer.h:211
constexpr auto max(const T &p1, const T &p2)
Returns the maximum between the two parameters.
Definition min_max.h:83
MatrixStorageType
A simple type that enumerates the main storage types for matrices (row or column major).
Definition base.h:76
Exceptions
vcl::MissingCompactnessExceptionif the vertex container is not compact.
Note
This function does not guarantee that the rows of the matrix correspond to the edge indices of the mesh. This scenario is possible when the mesh has deleted edges. To be sure to have a direct correspondence, compact the edge container before calling this function.
Template Parameters
Matrixtype of the matrix to be returned, it must satisfy the MatrixConcept.
MeshTypetype of the input mesh, it must satisfy the EdgeMeshConcept.
Parameters
[in]meshinput mesh
Returns
#E*2 matrix of integers (edge indices)

◆ elementColorsMatrix()

template<uint ELEM_ID, MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::elementColorsMatrix ( const MeshType &  mesh)

Get a #E*4 Matrix of integers containing the colors of the elements identified by ELEM_ID of a Mesh. The function is templated on the Matrix itself.

This function works with every Matrix type that satisfies the MatrixConcept, and requires that the mesh has per-element colors.

Usage example with Eigen Matrix:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-element colors available.
Note
This function does not guarantee that the rows of the matrix correspond to the element indices of the mesh. This scenario is possible when the mesh has deleted elements. To be sure to have a direct correspondence, compact the element container before calling this function.
Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]meshinput mesh
Returns
#E*4 matrix of integers (element colors)

◆ elementColorsVector()

template<uint ELEM_ID, typename Vect , MeshConcept MeshType>
Vect vcl::elementColorsVector ( const MeshType &  mesh,
Color::Format  colorFormat 
)

Get a #E Vector of integers containing the colors of the elements identified by ELEM_ID of a Mesh. The function is templated on the Vector itself. The color is packed in a single 32 bit value using the provided format.

This function works with every Vector type that has a constructor with a size_t argument and an operator[uint], and requires that the mesh has per-element colors.

Usage example with Eigen Vector:

Eigen::VectorXi EC =
myMesh, Color::Format::RGBA);
Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-element colors available.
Note
This function does not guarantee that the rows of the vector correspond to the element indices of the mesh. This scenario is possible when the mesh has deleted elements. To be sure to have a direct correspondence, compact the element container before calling this function.
Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]meshinput mesh
Returns
#E vector of integers (element colors)

◆ elementNormalsMatrix()

template<uint ELEM_ID, MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::elementNormalsMatrix ( const MeshType &  mesh)

Get a #E Vector of booleans (or integers) containing the selection status of the elements identified by ELEM_ID of a Mesh. The function is templated on the Vector itself.

This function works with every Vector type that has a constructor with a size_t argument and an operator[uint].

Usage example with Eigen Vector:

Eigen::VectorXi S =
@endif
@note This function does not guarantee that the rows of the vector
correspond to the element indices of the mesh. This scenario is possible
when the mesh has deleted elements. To be sure to have a direct
correspondence, compact the element container before calling this function.
@tparam ELEM_ID: the ID of the element.
@tparam Vect: type of the vector to be returned.
@tparam MeshType: type of the input mesh, it must satisfy the MeshConcept.
@param[in] mesh: input mesh
@return \#E vector of booleans or integers (element selection)
@ingroup export_matrix
/
template<uint ELEM_ID, typename Vect, MeshConcept MeshType>
Vect elementSelectionVector(const MeshType& mesh)
{
Vect sV(mesh.template number<ELEM_ID>());
return sV;
}
Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-element normals available.
Note
This function does not guarantee that the rows of the matrix correspond to the element indices of the mesh. This scenario is possible when the mesh has deleted elements. To be sure to have a direct correspondence, compact the element container before calling this function.
Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]meshinput mesh
Returns
#E*3 matrix of scalars (element normals)

◆ elementQualityVector()

template<uint ELEM_ID, typename Vect , MeshConcept MeshType>
Vect vcl::elementQualityVector ( const MeshType &  mesh)

Get a #E Vector of scalars containing the quality of the elements identified by ELEM_ID of a Mesh. The function is templated on the Vector itself.

This function works with every Vector type that has a constructor with a size_t argument and an operator[uint], and requires that the mesh has per-element quality.

Usage example with Eigen Vector:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-element quality available.
Note
This function does not guarantee that the rows of the vector correspond to the element indices of the mesh. This scenario is possible when the mesh has deleted elements. To be sure to have a direct correspondence, compact the element container before calling this function.
Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]meshinput mesh
Returns
#E vector of scalars (element quality)

◆ faceColorsMatrix()

template<MatrixConcept Matrix, FaceMeshConcept MeshType>
Matrix vcl::faceColorsMatrix ( const MeshType &  mesh)

Get a #F*4 Matrix of integers containing the colors of the faces of a Mesh. The function is templated on the Matrix itself.

This function works with every Matrix type that satisfies the MatrixConcept, and requires that the mesh has per-face colors.

Usage example with Eigen Matrix:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-face colors available.
Note
This function does not guarantee that the rows of the matrix correspond to the face indices of the mesh. This scenario is possible when the mesh has deleted faces. To be sure to have a direct correspondence, compact the face container before calling this function.
Parameters
[in]meshinput mesh
Returns
#F*4 matrix of integers (face colors)

◆ faceColorsVector()

template<typename Vect , MeshConcept MeshType>
Vect vcl::faceColorsVector ( const MeshType &  mesh,
Color::Format  colorFormat 
)

Get a #F Vector of integers containing the colors of the faces of a Mesh. The function is templated on the Vector itself. The color is packed in a single 32 bit value using the provided format.

This function works with every Vector type that has a constructor with a size_t argument and an operator[uint], and requires that the mesh has per-vertex colors.

Usage example with Eigen Vector:

Eigen::VectorXi FC =
myMesh, Color::Format::RGBA);
Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-face colors available.
Note
This function does not guarantee that the rows of the vector correspond to the face indices of the mesh. This scenario is possible when the mesh has deleted faces. To be sure to have a direct correspondence, compact the face container before calling this function.
Parameters
[in]meshinput mesh
Returns
#F vector of integers (face colors)

◆ faceIndicesVector()

template<typename Vect , FaceMeshConcept MeshType>
Vect vcl::faceIndicesVector ( const MeshType &  mesh)

Get a #V*3 Matrix of scalars containing the coordinates of the vertices of a Mesh. The function is templated on the Matrix itself.

This function works with every Matrix type that satisfies the MatrixConcept.

Usage example with an Eigen Matrix:

@endif
@note This function does not guarantee that the rows of the matrix
correspond to the vertex indices of the mesh. This scenario is possible
when the mesh has deleted vertices. To be sure to have a direct
correspondence, compact the vertex container before calling this function.
@tparam Matrix: type of the matrix to be returned, it must satisfy the
MatrixConcept.
@tparam MeshType: type of the input mesh, it must satisfy the MeshConcept.
@param[in] mesh: input mesh
@return \#V*3 matrix of scalars (vertex coordinates)
@ingroup export_matrix
/
template<MatrixConcept Matrix, MeshConcept MeshType>
Matrix vertexCoordsMatrix(const MeshType& mesh)
{
Matrix vM(mesh.vertexNumber(), 3);
MatrixStorageType stg = matrixStorageType<Matrix>();
vertexCoordsToBuffer(mesh, vM.data(), stg);
return vM;
}
void vertexCoordsToBuffer(const MeshType &mesh, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=UINT_NULL)
Export the vertex coordinates of a mesh to a buffer.
Definition export_buffer.h:101
Parameters
[in]meshinput mesh
Returns
#(sum of face sizes) vector of vertex indices

◆ faceNormalsMatrix()

template<MatrixConcept Matrix, FaceMeshConcept MeshType>
Matrix vcl::faceNormalsMatrix ( const MeshType &  mesh)

Get a #F*3 Matrix of scalars containing the normals of the faces of a Mesh. The function is templated on the Matrix itself.

This function works with every Matrix type that satisfies the MatrixConcept, and requires that the mesh has per-face normals.

Usage example with Eigen Matrix:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-face normals available.
Note
This function does not guarantee that the rows of the matrix correspond to the face indices of the mesh. This scenario is possible when the mesh has deleted faces. To be sure to have a direct correspondence, compact the face container before calling this function.
Parameters
[in]meshinput mesh
Returns
#F*3 matrix of scalars (face normals)

◆ faceQualityVector()

template<typename Vect , FaceMeshConcept MeshType>
Vect vcl::faceQualityVector ( const MeshType &  mesh)

Get a #F Vector of scalars containing the quality of the faces of a Mesh. The function is templated on the Vector itself.

This function works with every Vector type that has a constructor with a size_t argument and an operator(uint), and requires that the mesh has per-face quality.

Usage example with Eigen Vector:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-face quality available.
Note
This function does not guarantee that the rows of the vector correspond to the face indices of the mesh. This scenario is possible when the mesh has deleted faces. To be sure to have a direct correspondence, compact the face container before calling this function.
Parameters
[in]meshinput mesh
Returns
#F vector of scalars (face quality)

◆ vertexColorsMatrix()

template<MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::vertexColorsMatrix ( const MeshType &  mesh)

Get a #V*4 Matrix of integers containing the colors of the vertices of a Mesh. The function is templated on the Matrix itself.

This function works with every Matrix type that satisfies the MatrixConcept, and requires that the mesh has per-vertex colors.

Usage example with Eigen Matrix:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-vertex colors available.
Note
This function does not guarantee that the rows of the matrix correspond to the vertex indices of the mesh. This scenario is possible when the mesh has deleted vertices. To be sure to have a direct correspondence, compact the vertex container before calling this function.
Parameters
[in]meshinput mesh
Returns
#V*4 matrix of integers (vertex colors)

◆ vertexColorsVector()

template<typename Vect , MeshConcept MeshType>
Vect vcl::vertexColorsVector ( const MeshType &  mesh,
Color::Format  colorFormat 
)

Get a #V Vector of integers containing the colors of the vertices of a Mesh. The function is templated on the Vector itself. The color is packed in a single 32 bit value using the provided format.

This function works with every Vector type that has a constructor with a size_t argument and an operator[uint], and requires that the mesh has per-vertex colors.

Usage example with Eigen Vector:

Eigen::VectorXi VC =
myMesh, Color::Format::RGBA);
Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-vertex colors available.
Note
This function does not guarantee that the rows of the vector correspond to the vertex indices of the mesh. This scenario is possible when the mesh has deleted vertices. To be sure to have a direct correspondence, compact the vertex container before calling this function.
Parameters
[in]meshinput mesh
Returns
#V vector of integers (vertex colors)

◆ vertexNormalsMatrix()

template<MatrixConcept Matrix, MeshConcept MeshType>
Matrix vcl::vertexNormalsMatrix ( const MeshType &  mesh)

Get a #V*3 Matrix of scalars containing the normals of the vertices of a Mesh. The function is templated on the Matrix itself.

This function works with every Matrix type that satisfies the MatrixConcept, and requires that the mesh has per-vertex normals.

Usage example with Eigen Matrix:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-vertex normals available.
Note
This function does not guarantee that the rows of the matrix correspond to the vertex indices of the mesh. This scenario is possible when the mesh has deleted vertices. To be sure to have a direct correspondence, compact the vertex container before calling this function.
Parameters
[in]meshinput mesh
Returns
#V*3 matrix of scalars (vertex normals)

◆ vertexQualityVector()

template<typename Vect , MeshConcept MeshType>
Vect vcl::vertexQualityVector ( const MeshType &  mesh)

Get a #V Vector of scalars containing the quality of the vertices of a Mesh. The function is templated on the Vector itself.

This function works with every Vector type that has a constructor with a size_t argument and an operator(uint), and requires that the mesh has per-vertex quality.

Usage example with Eigen Vector:

Exceptions
vcl::MissingComponentExceptionif the mesh does not have per-vertex quality available.
Note
This function does not guarantee that the rows of the vector correspond to the vertex indices of the mesh. This scenario is possible when the mesh has deleted vertices. To be sure to have a direct correspondence, compact the vertex container before calling this function.
Parameters
[in]meshinput mesh
Returns
#V vector of scalars (vertex quality)