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

List Export Mesh to Buffer algorithms. More...

Collaboration diagram for Export Mesh to Buffer Algorithms:

Functions

template<MeshConcept MeshType>
void vcl::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.
 
template<FaceMeshConcept MeshType>
uint vcl::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.
 
template<FaceMeshConcept MeshType>
void vcl::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.
 
template<FaceMeshConcept MeshType>
void vcl::faceIndicesToBuffer (const MeshType &mesh, auto *buffer, uint largestFaceSize, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, bool getIndicesAsIfContainerCompact=true, uint rowNumber=UINT_NULL)
 Export into a buffer the vertex indices for each face of a Mesh. Faces can be polygons, and the number of output columns can be set by the user with the largestFaceSize parameter.
 
template<FaceMeshConcept MeshType>
void vcl::triangulatedFaceIndicesToBuffer (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 Mesh.
 
template<EdgeMeshConcept MeshType>
void vcl::edgeIndicesToBuffer (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.
 
template<FaceMeshConcept MeshType>
void vcl::wireframeIndicesToBuffer (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 that composes the wireframe of the Mesh (i.e., the edges of the faces).
 
template<FaceMeshConcept MeshType>
void vcl::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.
 
template<FaceMeshConcept MeshType>
void vcl::faceWedgeTexCoordIndicesToBuffer (const MeshType &mesh, auto *buffer)
 Export into a buffer the per face wedge texture indices of a mesh.
 
template<FaceMeshConcept MeshType>
void vcl::triangulatedFaceWedgeTexCoordIndicesToBuffer (const MeshType &mesh, auto *buffer, const TriPolyIndexBiMap &indexMap)
 Export into a buffer the per triangle wedge texture indices of a mesh. Triangles are computed by triangulating the faces of the mesh.
 

Detailed Description

List Export Mesh to Buffer algorithms.

They allow to export mesh data to pre-allocated buffers.

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

Function Documentation

◆ edgeIndicesToBuffer()

template<EdgeMeshConcept MeshType>
void vcl::edgeIndicesToBuffer ( 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.

This function exports the vertex indices of the edges of a mesh to a buffer. Indices are stored following the order the edges appear in the mesh. The buffer must be preallocated with the correct size (number of edges times 2).

Note
As a default behaviour (getIndicesAsIfContainerCompact == true) the function stores the vertex indices as if the vertex container of the mesh is compact. This means that, if the mesh has deleted vertices, the vertex indices stored in the buffer may not correspond to the vertex indices of the mesh. If you want to store the actual vertex indices in the input mesh, set getIndicesAsIfContainerCompact to false.
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.
Parameters
[in]meshinput mesh
[out]bufferpreallocated buffer
[in]storagestorage type of the matrix (row or column major)
[in]getIndicesAsIfContainerCompactif true, the function will store the vertex indices as if the vertex container of the mesh is compact. If false, the actual vertex indices in the input mesh will be stored.
[in]rowNumbernumber of rows of the matrix (if different from the number of edges in the mesh) - used only when storage is column major

◆ faceIndicesToBuffer() [1/2]

template<FaceMeshConcept MeshType>
void vcl::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.

This function exports the vertex indices of the polygonal faces of a mesh to a buffer. Indices are stored consecutively in the buffer, following the order the faces appear in the mesh. The buffer must be preallocated with the correct size (sum of the sizes of the faces).

You can use the function vcl::faceSizesToBuffer to get the sizes of the faces and allocate the buffer accordingly:

std::vector<uint> faceSizes(myMesh.faceNumber());
uint sum = vcl::faceSizesToBuffer(myMesh, sizes.data());
std::vector<uint> faceIndices(sum);
// read indices for each face
uint offset = 0;
for (uint i = 0; i < myMesh.faceNumber(); ++i) {
uint size = faceSizes[i];
for (uint j = 0; j < size; ++j) {
uint vIdx = faceIndices[offset + j];
// do something with the vertex index
}
offset += size;
}
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
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:149
Note
As a default behaviour (getIndicesAsIfContainerCompact == true) the function stores the vertex indices as if the vertex container of the mesh is compact. This means that, if the mesh has deleted vertices, the vertex indices stored in the buffer may not correspond to the vertex indices of the mesh. If you want to store the actual vertex indices in the input mesh, set getIndicesAsIfContainerCompact to false.
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
[out]bufferpreallocated buffer
[in]getIndicesAsIfContainerCompactif true, the function will store the vertex indices as if the vertex container of the mesh is compact. If false, the actual vertex indices in the input mesh will be stored.

◆ faceIndicesToBuffer() [2/2]

template<FaceMeshConcept MeshType>
void vcl::faceIndicesToBuffer ( const MeshType &  mesh,
auto buffer,
uint  largestFaceSize,
MatrixStorageType  storage = MatrixStorageType::ROW_MAJOR,
bool  getIndicesAsIfContainerCompact = true,
uint  rowNumber = UINT_NULL 
)

Export into a buffer the vertex indices for each face of a Mesh. Faces can be polygons, and the number of output columns can be set by the user with the largestFaceSize parameter.

This function exports the vertex indices of the polygonal faces of a mesh to a buffer. Indices are stored following the order the faces appear in the mesh. The buffer must be preallocated with the correct size (number of faces times largestFaceSize). For each face that has less vertices than the largest face size, the remaining indices are set to -1.

For triangle meshes, you can set largestFaceSize to 3. For polygonal meshes, you can use the function vcl::largestFaceSize to get the largest face size and allocate the buffer accordingly:

uint lfs = vcl::largestFaceSize(myMesh);
Eigen::MatrixXi faceIndices(myMesh.faceNumber(), lfs);
myMesh, faceIndices.data(), lfs, MatrixStorageType::COLUMN_MAJOR);
Note
As a default behaviour (getIndicesAsIfContainerCompact == true) the function stores the vertex indices as if the vertex container of the mesh is compact. This means that, if the mesh has deleted vertices, the vertex indices stored in the buffer may not correspond to the vertex indices of the mesh. If you want to store the actual vertex indices in the input mesh, set getIndicesAsIfContainerCompact to false.
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
[out]bufferpreallocated buffer
[in]largestFaceSizesize of the largest face in the mesh
[in]storagestorage type of the matrix (row or column major)
[in]getIndicesAsIfContainerCompactif true, the function will store the vertex indices as if the vertex container of the mesh is compact. If false, the actual vertex indices in the input mesh will be stored.
[in]rowNumbernumber of rows of the matrix (if different from the number of faces in the mesh) - used only when storage is column major

◆ faceSizesToBuffer()

template<FaceMeshConcept MeshType>
uint vcl::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.

This function could be useful when dealing with polygonal meshes: it exports the sizes of the faces of a mesh to a buffer. Sizes are stored following the order the faces appear in the mesh. The buffer must be preallocated with the correct size (number of faces).

The return value is the sum of the sizes of the faces. This value is useful when you need to allocate a buffer to store the vertex indices of the faces (its size is the sum of the face sizes).

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
[out]bufferpreallocated buffer
Returns
sum of the sizes of the faces

◆ faceWedgeTexCoordIndicesToBuffer()

template<FaceMeshConcept MeshType>
void vcl::faceWedgeTexCoordIndicesToBuffer ( const MeshType &  mesh,
auto buffer 
)

Export into a buffer the per face wedge texture indices of a mesh.

This function exports the per face wedge texture coordinate indices of a mesh to a buffer. Texture coordinate indices are stored in the buffer following the order the faces appear in the mesh. The buffer must be preallocated with the correct size (number of faces).

Note
This function does not guarantee that the rows of the buffer 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
[out]bufferpreallocated buffer

◆ faceWedgeTexCoordsToBuffer()

template<FaceMeshConcept MeshType>
void vcl::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.

This function exports the selection status of the elements identified by ELEM_ID of a mesh to a buffer. Values are stored in the buffer following the order the elements appear in the mesh. The buffer must be preallocated with the correct size (number of elements).

Usage example with std::vector<bool>:

std::vector<bool> vec(myMesh.elementNumber<ElemId::VERTEX>());
@endif
@note This function does not guarantee that the rows of the buffer
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.
@param[in] mesh: input mesh
@param[out] buffer: preallocated buffer
@ingroup export_buffer
/
template<uint ELEM_ID, MeshConcept MeshType>
void elementSelectionToBuffer(const MeshType& mesh, auto* buffer)
{
for (uint i = 0; const auto& e : mesh.template elements<ELEM_ID>()) {
buffer[i] = e.selected();
++i;
}
}
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
[out]bufferpreallocated buffer
[in]largestFaceSizesize of the largest face in the mesh
[in]storagestorage type of the matrix (row or column major)
[in]rowNumbernumber of rows of the matrix (if different from the number of faces in the mesh) - used only when storage is column major

◆ triangulatedFaceIndicesToBuffer()

template<FaceMeshConcept MeshType>
void vcl::triangulatedFaceIndicesToBuffer ( 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 Mesh.

This function exports the vertex indices of the triangles computed by triangulating the faces of a mesh to a buffer. Indices are stored following the order the faces appear in the mesh. The buffer must be preallocated with the correct size (number of resulting triangles times 3).

You can use the function vcl::countTriangulatedTriangles to get the number of resulting triangles and allocate the buffer accordingly:

uint numTris = vcl::countTriangulatedTriangles(myMesh);
Eigen::MatrixXi triIndices(numTris, 3);
myMesh, triIndices.data(), indexMap, MatrixStorageType::COLUMN_MAJOR,
numTris);
The TriPolyIndexBiMap class allows to store a bidirectional mapping between a Polygon Mesh and a Tria...
Definition tri_poly_index_bimap.h:50
void triangulatedFaceIndicesToBuffer(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:357

The input indexMap is used to map each triangle to the face index. If the storage of the buffer is column major, the number of resulting triangles (that should be known when calling this function) should be given as input. If the number of resulting triangles is not given, the function will compute it again.

Note
As a default behaviour (getIndicesAsIfContainerCompact == true) the function stores the vertex indices as if the vertex container of the mesh is compact. This means that, if the mesh has deleted vertices, the vertex indices stored in the buffer may not correspond to the vertex indices of the mesh. If you want to store the actual vertex indices in the input mesh, set getIndicesAsIfContainerCompact to false.
Parameters
[in]meshinput mesh
[out]bufferpreallocated buffer
[out]indexMapmap from triangle index to face index
[in]storagestorage type of the matrix (row or column major)
[in]numTrianglesnumber of resulting triangles (necessary only if the storage is column major)
[in]getIndicesAsIfContainerCompactif true, the function will store the vertex indices as if the vertex container of the mesh is compact. If false, the actual vertex indices in the input mesh will be stored.

◆ triangulatedFaceWedgeTexCoordIndicesToBuffer()

template<FaceMeshConcept MeshType>
void vcl::triangulatedFaceWedgeTexCoordIndicesToBuffer ( const MeshType &  mesh,
auto buffer,
const TriPolyIndexBiMap indexMap 
)

Export into a buffer the per triangle wedge texture indices of a mesh. Triangles are computed by triangulating the faces of the mesh.

This function exports the per triangle wedge texture coordinate indices of a mesh to a buffer. Texture coordinate indices are stored in the buffer following the order the faces appear in the mesh. The buffer must be preallocated with the correct size (number of triangles).

The function requires an already computed index map, which maps each triangle to the face index and vice versa. You can use the vcl::triangulatedFaceIndicesToBuffer function to get the index map. You can use the function vcl::countTriangulatedTriangles to get the number of resulting triangles and allocate the buffer accordingly.

Parameters
[in]meshinput mesh
[out]bufferpreallocated buffer
[in]indexMapmap from triangle index to face index

◆ vertexCoordsToBuffer()

template<MeshConcept MeshType>
void vcl::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.

This function exports the vertex coordinates of a mesh to a buffer. Vertices are stored in the buffer following the order they appear in the mesh. The buffer must be preallocated with the correct size (number of vertices times the number of coordinates per vertex).

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
[out]bufferpreallocated buffer
[in]storagestorage type of the matrix (row or column major)
[in]rowNumbernumber of rows of the matrix (if different from the number of vertices in the mesh) - used only when storage is column major

◆ wireframeIndicesToBuffer()

template<FaceMeshConcept MeshType>
void vcl::wireframeIndicesToBuffer ( 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 that composes the wireframe of the Mesh (i.e., the edges of the faces).

This function exports the vertex indices of the wireframe edges of a mesh to a buffer. Indices are stored following the order the edges appear in the faces. The buffer must be preallocated with the correct size (number of references to vertices in the mesh faces times 2 - see countPerFaceVertexReferences).

Note
As a default behaviour (getIndicesAsIfContainerCompact == true) the function stores the vertex indices as if the vertex container of the mesh is compact. This means that, if the mesh has deleted vertices, the vertex indices stored in the buffer may not correspond to the vertex indices of the mesh. If you want to store the actual vertex indices in the input mesh, set getIndicesAsIfContainerCompact to false.
Parameters
[in]meshinput mesh
[out]bufferpreallocated buffer
[in]storagestorage type of the matrix (row or column major)
[in]getIndicesAsIfContainerCompactif true, the function will store the vertex indices as if the vertex container of the mesh is compact. If false, the actual vertex indices in the input mesh will be stored.
[in]rowNumbernumber of rows of the matrix (if different from the number of references to vertices in the mesh faces times 2) - used only when storage is column major