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/requirements.h>
27#include <vclib/space/complex/tri_poly_index_bimap.h>
28#include <vclib/types.h>
29#include <vclib/views/mesh.h>
100template<MeshConcept MeshType>
102 const MeshType& mesh,
114 const auto& coord = mesh.vertex(v).coord();
115 if (
storage == MatrixStorageType::ROW_MAJOR) {
116 buffer[
i * 3 + 0] = coord.x();
117 buffer[
i * 3 + 1] = coord.y();
118 buffer[
i * 3 + 2] = coord.z();
175template<FaceMeshConcept MeshType>
177 const MeshType& mesh,
181 uint largestFaceSize = 3,
190 const uint
FACE_NUM = mesh.faceNumber();
192 uint
vFirst = mesh.vertexNumber();
195 for (
const auto& f : faces) {
196 if (
storage == MatrixStorageType::ROW_MAJOR)
197 buffer[f.first * largestFaceSize + f.second] =
vi;
252template<FaceMeshConcept MeshType>
254 const MeshType& mesh,
267 uint
vFirst = mesh.vertexNumber();
278 for (uint
vi =
vFirst;
const auto& [vert, faces] :
284 for (
const auto& f : faces) {
289 for (uint
j = 0;
j < 3; ++
j) {
290 if (
storage == MatrixStorageType::ROW_MAJOR) {
291 if (buffer[t * 3 +
j] == vert) {
292 buffer[t * 3 +
j] =
vi;
344template<MeshConcept MeshType>
346 const MeshType& mesh,
355 buffer[
i] = mesh.vertex(v).selected();
397template<MeshConcept MeshType>
399 const MeshType& mesh,
408 requirePerVertexNormal(mesh);
413 const auto& normal = mesh.vertex(v).normal();
414 if (
storage == MatrixStorageType::ROW_MAJOR) {
415 buffer[
i * 3 + 0] = normal.x();
416 buffer[
i * 3 + 1] = normal.y();
417 buffer[
i * 3 + 2] = normal.z();
466template<MeshConcept MeshType>
468 const MeshType& mesh,
478 requirePerVertexColor(mesh);
484 const auto& c = mesh.vertex(v).color();
485 if (
storage == MatrixStorageType::ROW_MAJOR) {
486 buffer[
i * 4 + 0] =
R_INT ? c.red() : c.redF();
487 buffer[
i * 4 + 1] =
R_INT ? c.green() : c.greenF();
488 buffer[
i * 4 + 2] =
R_INT ? c.blue() : c.blueF();
489 buffer[
i * 4 + 3] =
R_INT ? c.alpha() : c.alphaF();
540template<MeshConcept MeshType>
542 const MeshType& mesh,
551 requirePerVertexColor(mesh);
554 const auto& c = mesh.vertex(v).color();
557 case ABGR: buffer[
i] = c.abgr();
break;
558 case ARGB: buffer[
i] = c.argb();
break;
559 case RGBA: buffer[
i] = c.rgba();
break;
560 case BGRA: buffer[
i] = c.bgra();
break;
602template<MeshConcept MeshType>
604 const MeshType& mesh,
612 requirePerVertexQuality(mesh);
615 buffer[
i] = mesh.vertex(v).quality();
661template<MeshConcept MeshType>
663 const MeshType& mesh,
672 requirePerVertexTexCoord(mesh);
677 const auto& t = mesh.vertex(v).texCoord();
678 if (
storage == MatrixStorageType::ROW_MAJOR) {
679 buffer[
i * 2 + 0] = t.u();
680 buffer[
i * 2 + 1] = t.v();
731template<MeshConcept MeshType>
733 const MeshType& mesh,
741 requirePerVertexTexCoord(mesh);
744 buffer[
i] = mesh.vertex(v).texCoord().index();
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:43
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 appendDuplicateVertexCoordsToBuffer(const MeshType &mesh, const std::list< uint > &vertsToDuplicate, auto *buffer, MatrixStorageType storage=MatrixStorageType::ROW_MAJOR)
Append the coordinates of the duplicated vertices to the given buffer.
Definition append_replace_to_buffer.h:101
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:253
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:603
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:467
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:176
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:345
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:398
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:732
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:662
MatrixStorageType
A simple type that enumerates the main storage types for matrices (row or column major).
Definition base.h:76