23#ifndef VCL_ALGORITHMS_MESH_IMPORT_EXPORT_IMPORT_BUFFER_H
24#define VCL_ALGORITHMS_MESH_IMPORT_EXPORT_IMPORT_BUFFER_H
28#include <vclib/mesh.h>
29#include <vclib/space/core.h>
92template<MeshConcept MeshType>
101 using namespace detail;
106 mesh.clearVertices();
107 mesh.resizeVertices(vertexCount);
110 if (vertexCount != mesh.vertexCount()) {
112 "The input vertex number does not match the number of vertices "
114 "Number of vertices in the mesh: " +
115 std::to_string(mesh.vertexCount()) +
116 "\nNumber of input vertex number: " +
117 std::to_string(vertexCount));
121 for (uint
i = 0;
auto&
p : mesh.vertices() | views::positions) {
189template<FaceMeshConcept MeshType>
199 using namespace detail;
205 mesh.resizeFaces(faceCount);
208 if (faceCount != mesh.faceCount()) {
210 "The input face count does not match the number of faces of "
212 "Number of faces in the mesh: " +
213 std::to_string(mesh.faceCount()) +
214 "\nNumber of input face count: " + std::to_string(faceCount));
220 for (
auto& f : mesh.faces()) {
221 uint vertexCount = 0;
231 f.resizeVertices(vertexCount);
233 for (uint
j = 0;
j < vertexCount; ++
j)
239 using FaceType = MeshType::FaceType;
241 constexpr int VC = FaceType::VERTEX_COUNT;
244 for (
auto& f : mesh.faces()) {
245 for (uint
j = 0;
j <
VC; ++
j)
255 "The input face buffer has a different face size "
256 "than the vertex count of the faces of the mesh.\n"
257 "Faces vertex count in the mesh: " +
259 "\nNumber of columns in the input face buffer: " +
308template<EdgeMeshConcept MeshType>
317 using namespace detail;
321 mesh.resizeEdges(edgeCount);
324 if (edgeCount != mesh.edgeCount()) {
326 "The input edge count does not match the number of edges "
328 "Number of edges in the mesh: " +
329 std::to_string(mesh.edgeCount()) +
330 "\nNumber of input edge count: " + std::to_string(edgeCount));
335 for (
auto& e : mesh.edges()) {
356template<u
int ELEM_ID, MeshConcept MeshType>
360 e.selected() = buffer[
i];
379template<MeshConcept MeshType>
399template<FaceMeshConcept MeshType>
419template<EdgeMeshConcept MeshType>
455template<u
int ELEM_ID, MeshConcept MeshType>
462 using namespace detail;
507template<MeshConcept MeshType>
545template<FaceMeshConcept MeshType>
583template<EdgeMeshConcept MeshType>
634template<u
int ELEM_ID, MeshConcept MeshType>
643 using namespace detail;
651 " colors must have 3 or 4 channels.");
704template<u
int ELEM_ID, MeshConcept MeshType>
756template<MeshConcept MeshType>
789template<MeshConcept MeshType>
836template<FaceMeshConcept MeshType>
869template<FaceMeshConcept MeshType>
915template<EdgeMeshConcept MeshType>
948template<EdgeMeshConcept MeshType>
976template<u
int ELEM_ID, MeshConcept MeshType>
983 e.quality() = buffer[
i];
1007template<MeshConcept MeshType>
1032template<FaceMeshConcept MeshType>
1057template<EdgeMeshConcept MeshType>
1089template<MeshConcept MeshType>
1096 using namespace detail;
1100 enableIfPerVertexTexCoordOptional(mesh);
1101 requirePerVertexTexCoord(mesh);
1103 for (uint
i = 0;
auto& t : mesh.vertices() | views::texCoords) {
1131template<MeshConcept MeshType>
1134 enableIfPerVertexMaterialIndexOptional(mesh);
1135 requirePerVertexMaterialIndex(mesh);
1137 for (uint
i = 0;
auto& v : mesh.vertices()) {
1138 v.materialIndex() = buffer[
i];
1179template<FaceMeshConcept MeshType>
1187 using namespace detail;
1195 for (uint
i = 0;
auto& f : mesh.faces()) {
1196 for (uint
j = 0;
auto& w : f.wedgeTexCoords()) {
1227template<FaceMeshConcept MeshType>
1233 for (uint
i = 0;
auto& f : mesh.faces()) {
1234 f.materialIndex() = buffer[
i];
The Color class represents a 32 bit color.
Definition color.h:48
Format
Color format enumeration.
Definition color.h:77
Representation
Color representation enumeration.
Definition color.h:64
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:41
Exception thrown when the size (generally of a container) is not the expected one.
Definition exceptions.h:45
Definition face_requirements.h:60
MatrixStorageType
A simple type that enumerates the main storage types for matrices (row or column major).
Definition base.h:89
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:49
bool enableIfPerFaceWedgeTexCoordsOptional(MeshType &m)
If the input mesh has a FaceContainer, and the Face Element has a WedgeTexCoords Component,...
Definition face_requirements.h:936
void requirePerFaceWedgeTexCoords(const MeshType &m)
This function asserts that a Mesh has a FaceContainer, the Face has a WedgeTexCoords Component,...
Definition face_requirements.h:1322
void requirePerFaceMaterialIndex(const MeshType &m)
This function asserts that a Mesh has a FaceContainer, the Face has a MaterialIndex Component,...
Definition face_requirements.h:1143
bool enableIfPerFaceMaterialIndexOptional(MeshType &m)
If the input mesh has a FaceContainer, and the Face Element has a MaterialIndex Component,...
Definition face_requirements.h:633
void vertexTexCoordsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the vertex texcoords of the given input mesh from the input buffer, that is expected to be a con...
Definition import_buffer.h:1090
void edgeIndicesFromBuffer(MeshType &mesh, const auto *buffer, uint edgeCount, bool clearBeforeSet=true, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the edge indices of the given input mesh from the input edge buffer, that is expected to be a co...
Definition import_buffer.h:309
void elementQualityFromBuffer(MeshType &mesh, const auto *buffer)
Sets the element identified by ELEM_ID quality of the given input mesh from the input quality buffer,...
Definition import_buffer.h:977
void faceIndicesFromBuffer(MeshType &mesh, const auto *buffer, uint faceCount, uint faceSize=3, bool clearBeforeSet=true, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the face indices of the given input mesh from the input face buffer, that is expected to be a co...
Definition import_buffer.h:190
void faceWedgeTexCoordsFromBuffer(MeshType &mesh, const auto *buffer, uint largestFaceSize=3, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the face wedge texcoords of the given input mesh from the input buffer, that is expected to be a...
Definition import_buffer.h:1180
void elementSelectionFromBuffer(MeshType &mesh, const auto *buffer)
Sets the element identified by ELEM_ID selection of the given input mesh from the input selection buf...
Definition import_buffer.h:357
void edgeSelectionFromBuffer(MeshType &mesh, const auto *buffer)
Sets the edge selection of the given input mesh from the input selection buffer.
Definition import_buffer.h:420
void elementNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the element identified by ELEM_ID normals of the given input mesh from the input buffer,...
Definition import_buffer.h:456
void faceNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the face normals of the given input mesh from the input buffer, that is expected to be a contigu...
Definition import_buffer.h:546
void edgeColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelCount=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint numRows=UINT_NULL)
Sets the edge colors of the given input mesh from the input buffer, that is expected to be a contiguo...
Definition import_buffer.h:916
void vertexNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the vertex normals of the given input mesh from the input buffer, that is expected to be a conti...
Definition import_buffer.h:508
void faceSelectionFromBuffer(MeshType &mesh, const auto *buffer)
Sets the face selection of the given input mesh from the input selection buffer.
Definition import_buffer.h:400
void edgeNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the edge normals of the given input mesh from the input buffer, that is expected to be a contigu...
Definition import_buffer.h:584
void faceColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelCount=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint numRows=UINT_NULL)
Sets the face colors of the given input mesh from the input buffer, that is expected to be a contiguo...
Definition import_buffer.h:837
void vertexQualityFromBuffer(MeshType &mesh, const auto *buffer)
Sets the vertex quality of the given input mesh from the input quality buffer, that is expected to be...
Definition import_buffer.h:1008
void vertexPositionsFromBuffer(MeshType &mesh, const auto *buffer, uint vertexCount, bool clearBeforeSet=true, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint numRows=UINT_NULL)
Sets the vertex positions of the given input mesh from the input buffer, that is expected to be a con...
Definition import_buffer.h:93
void faceMaterialIndicesFromBuffer(MeshType &mesh, const auto *buffer)
Sets the face material indices of the given input mesh from the input material indices buffer,...
Definition import_buffer.h:1228
void faceQualityFromBuffer(MeshType &mesh, const auto *buffer)
Sets the face quality of the given input mesh from the input quality buffer, that is expected to be a...
Definition import_buffer.h:1033
void vertexColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelCount=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint numRows=UINT_NULL)
Sets the vertex colors of the given input mesh from the input buffer, that is expected to be a contig...
Definition import_buffer.h:757
void vertexSelectionFromBuffer(MeshType &mesh, const auto *buffer)
Sets the vertex selection of the given input mesh from the input selection buffer.
Definition import_buffer.h:380
void vertexMaterialIndicesFromBuffer(MeshType &mesh, const auto *buffer)
Sets the vertex material indices of the given input mesh from the input material indices buffer,...
Definition import_buffer.h:1132
void edgeQualityFromBuffer(MeshType &mesh, const auto *buffer)
Sets the edge quality of the given input mesh from the input quality buffer, that is expected to be a...
Definition import_buffer.h:1058
void elementColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelCount=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint numRows=UINT_NULL)
Sets the element identified by ELEM_ID colors of the given input mesh from the input buffer,...
Definition import_buffer.h:635
uint largestFaceSize(const FaceMeshConcept auto &mesh)
Returns the largest face size in the mesh.
Definition topology.h:212