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(vertexNumber);
110 if (vertexNumber != mesh.vertexNumber()) {
112 "The input vertex number does not match the number of vertices "
114 "Number of vertices in the mesh: " +
115 std::to_string(mesh.vertexNumber()) +
116 "\nNumber of input vertex number: " +
117 std::to_string(vertexNumber));
121 for (uint
i = 0;
auto&
p : mesh.vertices() | views::positions) {
189template<FaceMeshConcept MeshType>
199 using namespace detail;
205 mesh.resizeFaces(faceNumber);
208 if (faceNumber != mesh.faceNumber()) {
210 "The input face number does not match the number of faces "
212 "Number of faces in the mesh: " +
213 std::to_string(mesh.faceNumber()) +
214 "\nNumber of input face number: " + std::to_string(faceNumber));
220 for (
auto& f : mesh.faces()) {
221 uint vertexNumber = 0;
231 f.resizeVertices(vertexNumber);
233 for (uint
j = 0;
j < vertexNumber; ++
j)
239 using FaceType = MeshType::FaceType;
241 constexpr int VN = FaceType::VERTEX_NUMBER;
244 for (
auto& f : mesh.faces()) {
245 for (uint
j = 0;
j <
VN; ++
j)
255 "The input face buffer has a different face size "
256 "than the vertex number of the faces of the mesh.\n"
257 "Vertex number of faces in the mesh: " +
259 "\nNumber of columns in the input face buffer: " +
308template<EdgeMeshConcept MeshType>
317 using namespace detail;
321 mesh.resizeEdges(edgeNumber);
324 if (edgeNumber != mesh.edgeNumber()) {
326 "The input edge number does not match the number of edges "
328 "Number of edges in the mesh: " +
329 std::to_string(mesh.edgeNumber()) +
330 "\nNumber of input edge number: " + std::to_string(edgeNumber));
335 for (
auto& e : mesh.edges()) {
356template<u
int ELEM_ID, MeshConcept MeshType>
360 e.selected() = buffer[
i];
379template<MeshConcept MeshType>
399template<FaceMeshConcept MeshType>
421template<EdgeMeshConcept MeshType>
457template<u
int ELEM_ID, MeshConcept MeshType>
464 using namespace detail;
509template<MeshConcept MeshType>
547template<FaceMeshConcept MeshType>
585template<EdgeMeshConcept MeshType>
636template<u
int ELEM_ID, MeshConcept MeshType>
645 using namespace detail;
653 " colors must have 3 or 4 channels.");
707template<u
int ELEM_ID, MeshConcept MeshType>
759template<MeshConcept MeshType>
792template<MeshConcept MeshType>
839template<FaceMeshConcept MeshType>
872template<FaceMeshConcept MeshType>
918template<EdgeMeshConcept MeshType>
951template<EdgeMeshConcept MeshType>
979template<u
int ELEM_ID, MeshConcept MeshType>
986 e.quality() = buffer[
i];
1010template<MeshConcept MeshType>
1035template<FaceMeshConcept MeshType>
1060template<EdgeMeshConcept MeshType>
1092template<MeshConcept MeshType>
1099 using namespace detail;
1104 enableIfPerVertexTexCoordOptional(mesh);
1105 requirePerVertexTexCoord(mesh);
1107 for (uint
i = 0;
auto& t : mesh.vertices() | views::texCoords) {
1135template<MeshConcept MeshType>
1138 enableIfPerVertexMaterialIndexOptional(mesh);
1139 requirePerVertexMaterialIndex(mesh);
1141 for (uint
i = 0;
auto& v : mesh.vertices()) {
1142 v.materialIndex() = buffer[
i];
1183template<FaceMeshConcept MeshType>
1191 using namespace detail;
1199 for (uint
i = 0;
auto& f : mesh.faces()) {
1200 for (uint
j = 0;
auto& w : f.wedgeTexCoords()) {
1231template<FaceMeshConcept MeshType>
1237 for (uint
i = 0;
auto& f : mesh.faces()) {
1238 f.materialIndex() = buffer[
i];
A class representing a box in N-dimensional space.
Definition box.h:46
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
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: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
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 vertexPositionsFromBuffer(MeshType &mesh, const auto *buffer, uint vertexNumber, bool clearBeforeSet=true, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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 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:980
void vertexNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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:510
void edgeNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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:586
void elementColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelsNumber=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint rowNumber=UINT_NULL)
Sets the element identified by ELEM_ID colors of the given input mesh from the input buffer,...
Definition import_buffer.h:637
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 faceIndicesFromBuffer(MeshType &mesh, const auto *buffer, uint faceNumber, uint faceSize=3, bool clearBeforeSet=true, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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 faceColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelsNumber=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint rowNumber=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:840
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:422
void edgeColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelsNumber=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint rowNumber=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:919
void vertexColorsFromBuffer(MeshType &mesh, const auto *buffer, uint channelsNumber=4, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, Color::Representation representation=Color::Representation::INT_0_255, uint rowNumber=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:760
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 elementNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=UINT_NULL)
Sets the element identified by ELEM_ID normals of the given input mesh from the input buffer,...
Definition import_buffer.h:458
void faceWedgeTexCoordsFromBuffer(MeshType &mesh, const auto *buffer, uint largestFaceSize=3, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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:1184
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:1011
void vertexTexCoordsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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:1093
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:1232
void faceNormalsFromBuffer(MeshType &mesh, const auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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:548
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:1036
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 edgeIndicesFromBuffer(MeshType &mesh, const auto *buffer, uint edgeNumber, bool clearBeforeSet=true, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR, uint rowNumber=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 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:1136
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:1061
uint largestFaceSize(const FaceMeshConcept auto &mesh)
Returns the largest face size in the mesh.
Definition topology.h:212