23#ifndef VCL_ALGORITHMS_MESH_IMPORT_EXPORT_APPEND_REPLACE_TO_BUFFER_H
24#define VCL_ALGORITHMS_MESH_IMPORT_EXPORT_APPEND_REPLACE_TO_BUFFER_H
26#include <vclib/mesh.h>
27#include <vclib/space/complex.h>
99template<MeshConcept MeshType>
101 const MeshType& mesh,
113 const auto&
pos = mesh.vertex(v).position();
114 if (
storage == MatrixStorageType::ROW_MAJOR) {
115 buffer[
i * 3 + 0] =
pos.x();
116 buffer[
i * 3 + 1] =
pos.y();
117 buffer[
i * 3 + 2] =
pos.z();
174template<FaceMeshConcept MeshType>
176 const MeshType& mesh,
189 const uint
FACE_NUM = mesh.faceNumber();
191 uint
vFirst = mesh.vertexNumber();
194 for (
const auto& f : faces) {
195 if (
storage == MatrixStorageType::ROW_MAJOR)
251template<FaceMeshConcept MeshType>
253 const MeshType& mesh,
266 uint
vFirst = mesh.vertexNumber();
277 for (uint
vi =
vFirst;
const auto& [vert, faces] :
283 for (
const auto& f : faces) {
288 for (uint
j = 0;
j < 3; ++
j) {
289 if (
storage == MatrixStorageType::ROW_MAJOR) {
290 if (buffer[t * 3 +
j] == vert) {
291 buffer[t * 3 +
j] =
vi;
343template<MeshConcept MeshType>
345 const MeshType& mesh,
354 buffer[
i] = mesh.vertex(v).selected();
396template<MeshConcept MeshType>
398 const MeshType& mesh,
407 requirePerVertexNormal(mesh);
412 const auto& normal = mesh.vertex(v).normal();
413 if (
storage == MatrixStorageType::ROW_MAJOR) {
414 buffer[
i * 3 + 0] = normal.x();
415 buffer[
i * 3 + 1] = normal.y();
416 buffer[
i * 3 + 2] = normal.z();
465template<MeshConcept MeshType>
467 const MeshType& mesh,
477 requirePerVertexColor(mesh);
483 const auto& c = mesh.vertex(v).color();
484 if (
storage == MatrixStorageType::ROW_MAJOR) {
485 buffer[
i * 4 + 0] =
R_INT ? c.red() : c.redF();
486 buffer[
i * 4 + 1] =
R_INT ? c.green() : c.greenF();
487 buffer[
i * 4 + 2] =
R_INT ? c.blue() : c.blueF();
488 buffer[
i * 4 + 3] =
R_INT ? c.alpha() : c.alphaF();
539template<MeshConcept MeshType>
541 const MeshType& mesh,
550 requirePerVertexColor(mesh);
553 const auto& c = mesh.vertex(v).color();
556 case ABGR: buffer[
i] = c.abgr();
break;
557 case ARGB: buffer[
i] = c.argb();
break;
558 case RGBA: buffer[
i] = c.rgba();
break;
559 case BGRA: buffer[
i] = c.bgra();
break;
601template<MeshConcept MeshType>
603 const MeshType& mesh,
611 requirePerVertexQuality(mesh);
614 buffer[
i] = mesh.vertex(v).quality();
660template<MeshConcept MeshType>
662 const MeshType& mesh,
671 requirePerVertexTexCoord(mesh);
676 const auto& t = mesh.vertex(v).texCoord();
677 if (
storage == MatrixStorageType::ROW_MAJOR) {
678 buffer[
i * 2 + 0] = t.u();
679 buffer[
i * 2 + 1] = t.v();
730template<MeshConcept MeshType>
732 const MeshType& mesh,
740 requirePerVertexTexCoord(mesh);
743 buffer[
i] = mesh.vertex(v).texCoord().index();
A class representing a box in N-dimensional space.
Definition box.h:46
PointT size() const
Computes the size of the box.
Definition box.h:267
Format
Color format enumeration.
Definition color.h:77
Representation
Color representation enumeration.
Definition color.h:64
The TriPolyIndexBiMap class allows to store a bidirectional mapping between a Polygon Mesh and a Tria...
Definition tri_poly_index_bimap.h:50
uint triangleBegin(uint polygonIndex) const
Returns the smallest index of set of triangles mapped to the polygon having the index given as input ...
Definition tri_poly_index_bimap.h:83
uint triangleNumber(uint polygonIndex) const
Returns the number of (consecutive index) triangles mapped to a polygon.
Definition tri_poly_index_bimap.h:112
void appendDuplicateVertexPositionsToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Append the positions of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:100
void replaceTriangulatedFaceIndicesByVertexDuplicationToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, const std::list< std::list< std::pair< uint, uint > > > &facesToReassign, const TriPolyIndexBiMap &indexMap, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Replace the triangulated face vertex indices in the given buffer with the new indices of the duplicat...
Definition append_replace_to_buffer.h:252
void appendDuplicateVertexQualityToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer)
Append the quality of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:602
void appendDuplicateVertexColorsToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer, Color::Representation representation=Color::Representation::INT_0_255, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Append the colors of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:466
void replaceFaceIndicesByVertexDuplicationToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, const std::list< std::list< std::pair< uint, uint > > > &facesToReassign, auto *buffer, uint largestFaceSize=3, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Replace the face vertex indices in the given buffer with the new indices of the duplicated vertices.
Definition append_replace_to_buffer.h:175
void appendDuplicateVertexSelectionToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer)
Append the selection of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:344
void appendDuplicateVertexNormalsToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Append the normals of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:397
void appendDuplicateVertexTexCoordIndicesToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer)
Append the texture coordinate indices of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:731
void appendDuplicateVertexTexCoordsToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Append the texture coordinates of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:661
MatrixStorageType
A simple type that enumerates the main storage types for matrices (row or column major).
Definition base.h:76
uint largestFaceSize(const FaceMeshConcept auto &mesh)
Returns the largest face size in the mesh.
Definition topology.h:211