23#ifndef VCL_ALGORITHMS_MESH_IMPORT_EXPORT_EXPORT_MATRIX_H
24#define VCL_ALGORITHMS_MESH_IMPORT_EXPORT_EXPORT_MATRIX_H
26#include "export_buffer.h"
28#include <vclib/algorithms/mesh/stat/topology.h>
30#include <vclib/mesh.h>
31#include <vclib/space/core.h>
71template<MatrixConcept Matrix, MeshConcept MeshType>
72Matrix vertexPositionsMatrix(
const MeshType& mesh)
74 Matrix vM(mesh.vertexNumber(), 3);
115template<
typename Vect, FaceMeshConcept MeshType>
116Vect faceSizesVector(
const MeshType& mesh)
118 requireVertexContainerCompactness(mesh);
120 Vect fM(mesh.faceNumber());
158template<
typename Vect, FaceMeshConcept MeshType>
161 requireVertexContainerCompactness(mesh);
206template<MatrixConcept Matrix, FaceMeshConcept MeshType>
207Matrix faceVertexIndicesMatrix(
const MeshType& mesh)
209 requireVertexContainerCompactness(mesh);
213 Matrix fM(mesh.faceNumber(), fMaxSize);
249template<MatrixConcept Matrix, FaceMeshConcept MeshType>
250Matrix triangulatedFaceVertexIndicesMatrix(
251 const MeshType& mesh,
252 TriPolyIndexBiMap& indexMap = detail::indexMap)
254 requireVertexContainerCompactness(mesh);
258 Matrix tM(tNumber, 3);
263 mesh, tM.data(), indexMap, stg, tNumber);
298template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
301 requireVertexContainerCompactness(mesh);
341template<u
int ELEM_ID,
typename Vect, MeshConcept MeshType>
342Vect elementSelectionVector(
const MeshType& mesh)
344 Vect sV(mesh.template number<ELEM_ID>());
377template<
typename Vect, MeshConcept MeshType>
378Vect vertexSelectionVector(
const MeshType& mesh)
380 return elementSelectionVector<ElemId::VERTEX, Vect>(mesh);
411template<
typename Vect, FaceMeshConcept MeshType>
412Vect faceSelectionVector(
const MeshType& mesh)
414 return elementSelectionVector<ElemId::FACE, Vect>(mesh);
445template<
typename Vect, EdgeMeshConcept MeshType>
446Vect edgeSelectionVector(
const MeshType& mesh)
448 return elementSelectionVector<ElemId::EDGE, Vect>(mesh);
480template<u
int ELEM_ID, MatrixConcept Matrix, MeshConcept MeshType>
518template<MatrixConcept Matrix, MeshConcept MeshType>
550template<MatrixConcept Matrix, FaceMeshConcept MeshType>
585template<u
int ELEM_ID, MatrixConcept Matrix, MeshConcept MeshType>
629template<u
int ELEM_ID,
typename Vect, MeshConcept MeshType>
665template<MatrixConcept Matrix, MeshConcept MeshType>
701template<
typename Vect, MeshConcept MeshType>
733template<MatrixConcept Matrix, FaceMeshConcept MeshType>
769template<
typename Vect, MeshConcept MeshType>
801template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
837template<
typename Vect, MeshConcept MeshType>
873template<u
int ELEM_ID,
typename Vect, MeshConcept MeshType>
910template<
typename Vect, MeshConcept MeshType>
943template<
typename Vect, FaceMeshConcept MeshType>
976template<
typename Vect, EdgeMeshConcept MeshType>
1008template<MatrixConcept Matrix, MeshConcept MeshType>
1048template<
typename Vect, MeshConcept MeshType>
1086template<MatrixConcept Matrix, FaceMeshConcept MeshType>
1128template<
typename Vect, FaceMeshConcept MeshType>
1170 template<
typename,
typename...>
1173 MeshConcept MeshType>
1174Container<Container<T>> vertexAdjacentVerticesVectors(
const MeshType& mesh)
1176 requireVertexContainerCompactness(mesh);
1177 requirePerVertexAdjacentVertices(mesh);
1179 Container<Container<T>> vv(mesh.vertexNumber());
1181 auto vvIt = vv.begin();
1182 for (
const auto& v : mesh.vertices()) {
1185 vec.resize(v.adjVerticesNumber());
1186 auto vecIt = vec.begin();
1187 for (
const auto* ve : v.adjVertices()) {
1188 uint idx = ve ? ve->index() :
UINT_NULL;
1228template<MatrixConcept Matrix, MeshConcept MeshType>
1229Matrix vertexAdjacentVerticesMatrix(
const MeshType& mesh)
1233 Matrix vAVM(mesh.vertexNumber(), lva);
1283 template<
typename,
typename...>
1286 FaceMeshConcept MeshType>
1287Container<Container<T>> elementAdjacentFacesVectors(
const MeshType& mesh)
1290 requirePerElementComponent<ELEM_ID, CompId::ADJACENT_FACES>(mesh);
1292 Container<Container<T>> vv(mesh.template number<ELEM_ID>());
1294 auto vvIt = vv.begin();
1295 for (
const auto& v : mesh.template elements<ELEM_ID>()) {
1298 vec.resize(v.adjFacesNumber());
1299 auto vecIt = vec.begin();
1300 for (
const auto* fe : v.
adjFaces()) {
1301 uint idx = fe ? fe->index() :
UINT_NULL;
1348template<u
int ELEM_ID, MatrixConcept Matrix, FaceMeshConcept MeshType>
1349Matrix elementAdjacentFacesMatrix(
const MeshType& mesh)
1353 Matrix eAFM(mesh.template number<ELEM_ID>(), lfa);
1357 elementAdjacentFacesToBuffer<ELEM_ID>(mesh, eAFM.data(), lfa, stg);
1400 template<
typename,
typename...>
1403 FaceMeshConcept MeshType>
1404Container<Container<T>> vertexAdjacentFacesVectors(
const MeshType& mesh)
1406 return elementAdjacentFacesVectors<ElemId::VERTEX, Container, T>(mesh);
1444template<MatrixConcept Matrix, FaceMeshConcept MeshType>
1445Matrix vertexAdjacentFacesMatrix(
const MeshType& mesh)
1447 return elementAdjacentFacesMatrix<ElemId::VERTEX, Matrix>(mesh);
1483 template<
typename,
typename...>
1486 FaceMeshConcept MeshType>
1487Container<Container<T>> faceAdjacentFacesVectors(
const MeshType& mesh)
1489 return elementAdjacentFacesVectors<ElemId::FACE, Container, T>(mesh);
1522template<MatrixConcept Matrix, FaceMeshConcept MeshType>
1523Matrix faceAdjacentFacesMatrix(
const MeshType& mesh)
1525 return elementAdjacentFacesMatrix<ElemId::FACE, Matrix>(mesh);
1566 template<
typename,
typename...>
1569 FaceMeshConcept MeshType>
1570Container<Container<T>> edgeAdjacentFacesVectors(
const MeshType& mesh)
1571 requires EdgeMeshConcept<MeshType>
1573 return elementAdjacentFacesVectors<ElemId::EDGE, Container, T>(mesh);
1611template<MatrixConcept Matrix, FaceMeshConcept MeshType>
1612Matrix edgeAdjacentFacesMatrix(
const MeshType& mesh)
1613 requires EdgeMeshConcept<MeshType>
1615 return elementAdjacentFacesMatrix<ElemId::EDGE, Matrix>(mesh);
1659 template<
typename,
typename...>
1662 EdgeMeshConcept MeshType>
1663Container<Container<T>> elementAdjacentEdgesVectors(
const MeshType& mesh)
1666 requirePerElementComponent<ELEM_ID, CompId::ADJACENT_EDGES>(mesh);
1668 Container<Container<T>> vv(mesh.template number<ELEM_ID>());
1670 auto vvIt = vv.begin();
1671 for (
const auto& v : mesh.template elements<ELEM_ID>()) {
1674 vec.resize(v.adjEdgesNumber());
1675 auto vecIt = vec.begin();
1676 for (
const auto* fe : v.
adjEdges()) {
1677 uint idx = fe ? fe->index() :
UINT_NULL;
1724template<u
int ELEM_ID, MatrixConcept Matrix, EdgeMeshConcept MeshType>
1725Matrix elementAdjacentEdgesMatrix(
const MeshType& mesh)
1729 Matrix eAEM(mesh.template number<ELEM_ID>(), lea);
1733 elementAdjacentEdgesToBuffer<ELEM_ID>(mesh, eAEM.data(), lea, stg);
1776 template<
typename,
typename...>
1779 EdgeMeshConcept MeshType>
1780Container<Container<T>> vertexAdjacentEdgesVectors(
const MeshType& mesh)
1782 return elementAdjacentEdgesVectors<ElemId::VERTEX, Container, T>(mesh);
1820template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
1821Matrix vertexAdjacentEdgesMatrix(
const MeshType& mesh)
1823 return elementAdjacentEdgesMatrix<ElemId::VERTEX, Matrix>(mesh);
1864 template<
typename,
typename...>
1867 EdgeMeshConcept MeshType>
1868Container<Container<T>> faceAdjacentEdgesVectors(
const MeshType& mesh)
1869 requires FaceMeshConcept<MeshType>
1871 return elementAdjacentEdgesVectors<ElemId::FACE, Container, T>(mesh);
1909template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
1910Matrix faceAdjacentEdgesMatrix(
const MeshType& mesh)
1911 requires FaceMeshConcept<MeshType>
1913 return elementAdjacentEdgesMatrix<ElemId::FACE, Matrix>(mesh);
1949 template<
typename,
typename...>
1952 EdgeMeshConcept MeshType>
1953Container<Container<T>> edgeAdjacentEdgesVectors(
const MeshType& mesh)
1955 return elementAdjacentEdgesVectors<ElemId::EDGE, Container, T>(mesh);
1988template<MatrixConcept Matrix, EdgeMeshConcept MeshType>
1989Matrix edgeAdjacentEdgesMatrix(
const MeshType& mesh)
1991 return elementAdjacentEdgesMatrix<ElemId::EDGE, Matrix>(mesh);
A class representing a box in N-dimensional space.
Definition box.h:46
Format
Color format enumeration.
Definition color.h:77
MatrixStorageType
A simple type that enumerates the main storage types for matrices (row or column major).
Definition base.h:88
constexpr uint UINT_NULL
The UINT_NULL value represent a null value of uint that is the maximum value that can be represented ...
Definition base.h:48
void requireEdgeContainerCompactness(const MeshType &m)
This function asserts that a Mesh has the EdgeContainer compact (no elements flagged as deleted).
Definition edge_requirements.h:597
void vertexPositionsToBuffer(const MeshType &mesh, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=UINT_NULL)
Export the vertex positions of a mesh to a buffer.
Definition export_buffer.h:74
void edgeVertexIndicesToBuffer(const MeshType &mesh, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, bool getIndicesAsIfContainerCompact=true, uint rowNumber=UINT_NULL)
Export into a buffer the vertex indices for each edge of a Mesh.
Definition export_buffer.h:456
void triangulatedFaceVertexIndicesToBuffer(const MeshType &mesh, auto *buffer, TriPolyIndexBiMap &indexMap=detail::indexMap, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numTriangles=UINT_NULL, bool getIndicesAsIfContainerCompact=true)
Export into a buffer the vertex indices for each triangle computed by triangulating the faces of a Me...
Definition export_buffer.h:366
void vertexAdjacentVerticesToBuffer(const MeshType &mesh, auto *buffer, uint largestAdjacentVerticesSize, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=UINT_NULL)
Export into a buffer the adjacent vertex indices for each vertex of a Mesh. The number of adjacent ve...
Definition export_buffer.h:1899
void faceVertexIndicesToBuffer(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:226
void faceWedgeTexCoordsToBuffer(const MeshType &mesh, auto *buffer, uint largestFaceSize=3, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=UINT_NULL)
Export the selection status of the elements identified by ELEM_ID of a mesh to a buffer.
Definition export_buffer.h:1599
uint faceSizesToBuffer(const MeshType &mesh, auto *buffer)
Export into a buffer the sizes of the faces of a Mesh, and return the sum of the sizes.
Definition export_buffer.h:164
void faceMaterialIndicesToBuffer(const MeshType &mesh, auto *buffer)
Export into a buffer the per face material indices of a mesh.
Definition export_buffer.h:1650
Matrix vertexColorsMatrix(const MeshType &mesh)
Get a #V*4 Matrix of integers containing the colors of the vertices of a Mesh. The function is templa...
Definition export_matrix.h:666
Vect vertexQualityVector(const MeshType &mesh)
Get a #V Vector of scalars containing the quality of the vertices of a Mesh. The function is template...
Definition export_matrix.h:911
Matrix elementNormalsMatrix(const MeshType &mesh)
Get a #E Vector of booleans (or integers) containing the selection status of the elements identified ...
Definition export_matrix.h:481
Matrix vertexTexCoordsMatrix(const MeshType &mesh)
Get a #V*2 Matrix of scalars containing the texcoords of the vertices of a Mesh. The function is temp...
Definition export_matrix.h:1009
Vect 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 template...
Definition export_matrix.h:702
Matrix edgeColorsMatrix(const MeshType &mesh)
Get a #E*4 Matrix of integers containing the colors of the edges of a Mesh. The function is templated...
Definition export_matrix.h:802
Vect faceMaterialIndicesVector(const MeshType &mesh)
Get a #F vector of scalars containing the material indices of the faces of a Mesh....
Definition export_matrix.h:1129
Matrix faceColorsMatrix(const MeshType &mesh)
Get a #F*4 Matrix of integers containing the colors of the faces of a Mesh. The function is templated...
Definition export_matrix.h:734
Vect edgeQualityVector(const MeshType &mesh)
Get a #E Vector of scalars containing the quality of the edges of a Mesh. The function is templated o...
Definition export_matrix.h:977
Matrix faceWedgeTexCoordsMatrix(const MeshType &mesh)
Get a #F*(LFS*2) Matrix of scalars containing the wedge texcoords of the faces of a Mesh....
Definition export_matrix.h:1087
Vect vertexMaterialIndicesVector(const MeshType &mesh)
Get a #V vector of scalars containing the material indices of the vertices of a Mesh....
Definition export_matrix.h:1049
Matrix faceNormalsMatrix(const MeshType &mesh)
Get a #F*3 Matrix of scalars containing the normals of the faces of a Mesh. The function is templated...
Definition export_matrix.h:551
Vect faceQualityVector(const MeshType &mesh)
Get a #F Vector of scalars containing the quality of the faces of a Mesh. The function is templated o...
Definition export_matrix.h:944
Vect elementQualityVector(const MeshType &mesh)
Get a #E Vector of scalars containing the quality of the elements identified by ELEM_ID of a Mesh....
Definition export_matrix.h:874
Vect faceVertexIndicesVector(const MeshType &mesh)
Get a #V*3 Matrix of scalars containing the positions of the vertices of a Mesh. The function is temp...
Definition export_matrix.h:159
Vect 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....
Definition export_matrix.h:630
Matrix edgeVertexIndicesMatrix(const MeshType &mesh)
Get a #F*LFS Matrix of integers containing the vertex indices for each face of a Mesh....
Definition export_matrix.h:299
Vect edgeColorsVector(const MeshType &mesh, Color::Format colorFormat)
Get a #E Vector of integers containing the colors of the edges of a Mesh. The function is templated o...
Definition export_matrix.h:838
Matrix elementColorsMatrix(const MeshType &mesh)
Get a #E*4 Matrix of integers containing the colors of the elements identified by ELEM_ID of a Mesh....
Definition export_matrix.h:586
Matrix vertexNormalsMatrix(const MeshType &mesh)
Get a #V*3 Matrix of scalars containing the normals of the vertices of a Mesh. The function is templa...
Definition export_matrix.h:519
Vect 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 o...
Definition export_matrix.h:770
void requireFaceContainerCompactness(const MeshType &m)
This function asserts that a Mesh has the FaceContainer compact (no elements flagged as deleted).
Definition face_requirements.h:966
uint largestPerVertexAdjacentVerticesNumber(const MeshConcept auto &mesh)
Returns the largest number of per-vertex adjacent vertices in the mesh.
Definition topology.h:268
uint countPerFaceVertexReferences(const FaceMeshConcept auto &mesh)
Count the number of references to vertices in the mesh faces.
Definition topology.h:182
uint largestFaceSize(const FaceMeshConcept auto &mesh)
Returns the largest face size in the mesh.
Definition topology.h:212
uint countTriangulatedTriangles(const FaceMeshConcept auto &mesh)
Counts the number of resulting triangles if the input mesh would be triangulated by splitting each fa...
Definition topology.h:240
constexpr detail::AdjEdgesView adjEdges
The adjEdges view allows to obtain a view that access to the adjacent edges of the object that has be...
Definition adj_edges.h:65
constexpr detail::AdjFacesView adjFaces
The adjFaces view allows to obtain a view that access to the adjacent faces of the object that has be...
Definition adj_faces.h:65