Visual Computing Library
Loading...
Searching...
No Matches
mesh_info.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_SPACE_COMPLEX_MESH_INFO_H
24#define VCL_SPACE_COMPLEX_MESH_INFO_H
25
26#include <vclib/mesh/requirements.h>
27#include <vclib/types.h>
28
29#include <array>
30#include <bitset>
31#include <string>
32#include <typeindex>
33#include <vector>
34
35namespace vcl {
36
76{
77public:
82 enum class MeshType { TRIANGLE_MESH, QUAD_MESH, POLYGON_MESH, UNKNOWN };
83
91 enum Element { VERTEX, FACE, EDGE, MESH, NUM_ELEMENTS };
92
97 enum Component {
98 COORD,
99 VREFS,
100 NORMAL,
101 COLOR,
102 QUALITY,
103 TEXCOORD,
104 WEDGE_TEXCOORDS,
105 CUSTOM_COMPONENTS,
106 TEXTURES,
107 NUM_COMPONENTS
108 };
109
114
120 {
121 std::string name;
122 DataType type;
123
124 CustomComponent(std::string n, DataType t) : name(n), type(t) {}
125 };
126
127private:
128 // Tell if elements are present in the file
129 std::bitset<NUM_ELEMENTS> mElements = {false};
130
131 // Tell if per element components are present in the file
132 std::array<std::bitset<NUM_COMPONENTS>, NUM_ELEMENTS> mPerElemComponents = {
133 false};
134
135 // Tell the data type for each component of each element
136 Eigen::Matrix<DataType, NUM_ELEMENTS, NUM_COMPONENTS>
137 mPerElemComponentsType;
138
139 // Store name and type of per element custom components
140 std::array<std::vector<CustomComponent>, NUM_ELEMENTS>
141 mPerElemCustomComponents;
142
143 // Mesh Type
144 MeshType mType = MeshType::UNKNOWN;
145
146public:
153 MeshInfo() { mPerElemComponentsType.fill(PrimitiveType::NONE); }
154
164 template<MeshConcept Mesh>
166 {
167 setVertices();
168 setVertexCoords(
170 if constexpr (HasPerVertexNormal<Mesh>) {
171 if (isPerVertexNormalAvailable(m)) {
172 setVertexNormals(
173 true,
174 getType<
175 typename Mesh::VertexType::NormalType::ScalarType>());
176 }
177 }
178 if constexpr (HasPerVertexColor<Mesh>) {
179 if (isPerVertexColorAvailable(m)) {
180 setVertexColors(true, PrimitiveType::UCHAR);
181 }
182 }
183 if constexpr (HasPerVertexQuality<Mesh>) {
184 if (isPerVertexQualityAvailable(m)) {
185 setVertexQuality(
187 }
188 }
189 if constexpr (HasPerVertexTexCoord<Mesh>) {
190 if (isPerVertexTexCoordAvailable(m)) {
191 setVertexTexCoords(
192 true,
193 getType<
194 typename Mesh::VertexType::TexCoordType::ScalarType>());
195 }
196 }
198 auto names = m.perVertexCustomComponentNames();
199 for (auto& name : names) {
200 DataType dt = getType(m.perVertexCustomComponentType(name));
201 if (dt != PrimitiveType::NONE) {
202 addVertexCustomComponent(name, dt);
203 }
204 }
205 }
206
207 if constexpr (HasFaces<Mesh>) {
208 setFaces();
209 setFaceVRefs();
210 if (HasTriangles<Mesh>) {
211 setTriangleMesh();
212 }
213 else if (HasQuads<Mesh>) {
214 setQuadMesh();
215 }
216 else {
217 setPolygonMesh();
218 }
219 if constexpr (HasPerFaceNormal<Mesh>) {
221 setFaceNormals(
222 true,
223 getType<
224 typename Mesh::FaceType::NormalType::ScalarType>());
225 }
226 }
227 if constexpr (HasPerFaceColor<Mesh>) {
229 setFaceColors(true, PrimitiveType::UCHAR);
230 }
231 }
232 if constexpr (HasPerFaceQuality<Mesh>) {
234 setFaceQuality(
236 }
237 }
238 if constexpr (HasPerFaceWedgeTexCoords<Mesh>) {
240 setFaceWedgeTexCoords(
241 true,
242 getType<typename Mesh::FaceType::WedgeTexCoordType::
243 ScalarType>());
244 }
245 }
246 if constexpr (HasPerFaceCustomComponents<Mesh>) {
247 auto names = m.perFaceCustomComponentNames();
248 for (auto& name : names) {
249 DataType dt = getType(m.perFaceCustomComponentType(name));
250 if (dt != PrimitiveType::NONE) {
251 addFaceCustomComponent(name, dt);
252 }
253 }
254 }
255 }
256
257 if constexpr (HasEdges<Mesh>) {
258 setEdges();
259 setEdgeVRefs();
260 // if constexpr (HasPerEdgeColor<Mesh>)
261 // if (isPerEdgeColorAvailable(m))
262 // setEdgeColors(true, UCHAR);
263 }
264
265 if constexpr (HasTexturePaths<Mesh>) {
266 if (m.textureNumber() > 0) {
267 setTextures(true);
268 }
269 }
270 }
271
278 void clear()
279 {
280 mElements.reset();
281 for (auto& comp : mPerElemComponents)
282 comp.reset();
283 mPerElemComponentsType.fill(PrimitiveType::NONE);
284
285 for (auto& v : mPerElemCustomComponents)
286 v.clear();
287
288 mType = MeshType::UNKNOWN;
289 }
290
295 bool isEmpty() const { return !mElements.any(); }
296
297 bool isUnkownMesh() const { return mType == MeshType::UNKNOWN; }
298
304 bool isTriangleMesh() const { return mType == MeshType::TRIANGLE_MESH; }
305
311 bool isQuadMesh() const { return mType == MeshType::QUAD_MESH; }
312
318 bool isPolygonMesh() const { return mType == MeshType::POLYGON_MESH; }
319
320 /*
321 * Getter Elements/Components functions: they are used mostly after the
322 * loading of a Mesh from a file, to know if Elements/Components have been
323 * loaded.
324 */
325
326 bool hasElement(Element el) const { return mElements[el]; }
327
328 bool hasPerElementComponent(Element el, Component comp) const
329 {
330 return mPerElemComponents[el][comp];
331 }
332
337 bool hasVertices() const { return hasElement(VERTEX); }
338
343 bool hasVertexCoords() const
344 {
345 return hasPerElementComponent(VERTEX, COORD);
346 }
347
352 bool hasVertexNormals() const
353 {
354 return hasPerElementComponent(VERTEX, NORMAL);
355 }
356
361 bool hasVertexColors() const
362 {
363 return hasPerElementComponent(VERTEX, COLOR);
364 }
365
370 bool hasVertexQuality() const
371 {
372 return hasPerElementComponent(VERTEX, QUALITY);
373 }
374
380 {
381 return hasPerElementComponent(VERTEX, TEXCOORD);
382 }
383
389 {
390 return hasPerElementComponent(VERTEX, CUSTOM_COMPONENTS);
391 }
392
397 bool hasFaces() const { return hasElement(FACE); }
398
403 bool hasFaceVRefs() const { return hasPerElementComponent(FACE, VREFS); }
404
405 bool hasFaceNormals() const { return hasPerElementComponent(FACE, NORMAL); }
406
407 bool hasFaceColors() const { return hasPerElementComponent(FACE, COLOR); }
408
409 bool hasFaceQuality() const
410 {
411 return hasPerElementComponent(FACE, QUALITY);
412 }
413
414 bool hasFaceWedgeTexCoords() const
415 {
416 return hasPerElementComponent(FACE, WEDGE_TEXCOORDS);
417 }
418
419 bool hasFaceCustomComponents() const
420 {
421 return hasPerElementComponent(FACE, CUSTOM_COMPONENTS);
422 }
423
428 bool hasEdges() const { return hasElement(EDGE); }
429
430 bool hasEdgeVRefs() const { return hasPerElementComponent(EDGE, VREFS); }
431
432 bool hasEdgeColors() const { return hasPerElementComponent(EDGE, COLOR); }
433
434 bool hasEdgeNormals() const { return hasPerElementComponent(EDGE, NORMAL); }
435
436 bool hasEdgeQuality() const
437 {
438 return hasPerElementComponent(EDGE, QUALITY);
439 }
440
441 bool hasEdgeCustomComponents() const
442 {
443 return hasPerElementComponent(EDGE, CUSTOM_COMPONENTS);
444 }
445
446 bool hasTextures() const { return hasPerElementComponent(MESH, TEXTURES); }
447
448 /*
449 * Setter functions: they are used by the load functions to tell which
450 * Elements/Components are loaded from a file, and they can be used by the
451 * user that wants to save in a file only a specific set of
452 * Elements/Components of a Mesh.
453 */
454
455 void updateMeshType(uint faceSize)
456 {
457 if (mType == MeshType::UNKNOWN) {
458 if (faceSize == 3)
459 setTriangleMesh();
460 else if (faceSize == 4)
461 setQuadMesh();
462 else
463 setPolygonMesh();
464 }
465 else if (mType == MeshType::TRIANGLE_MESH && faceSize != 3) {
466 setPolygonMesh();
467 }
468 else if (mType == MeshType::QUAD_MESH && faceSize != 4) {
469 setPolygonMesh();
470 }
471 }
472
473 void setUnknownMesh() { mType = MeshType::UNKNOWN; }
474
475 void setTriangleMesh() { mType = MeshType::TRIANGLE_MESH; }
476
477 void setQuadMesh() { mType = MeshType::QUAD_MESH; }
478
479 void setPolygonMesh() { mType = MeshType::POLYGON_MESH; }
480
481 void setMeshType(MeshType t) { mType = t; }
482
483 void setElement(Element el, bool b = true) { mElements[el] = b; }
484
485 void setElementComponents(Element el, Component c, bool b, DataType t)
486 {
487 mElements[el] = b;
488 mPerElemComponents[el][c] = b;
489 if (b)
490 mPerElemComponentsType(el, c) = t;
491 }
492
493 void setVertices(bool b = true) { setElement(VERTEX, b); }
494
495 void setVertexCoords(bool b = true, DataType t = PrimitiveType::DOUBLE)
496 {
497 setElementComponents(VERTEX, COORD, b, t);
498 }
499
500 void setVertexNormals(bool b = true, DataType t = PrimitiveType::FLOAT)
501 {
502 setElementComponents(VERTEX, NORMAL, b, t);
503 }
504
505 void setVertexColors(bool b = true, DataType t = PrimitiveType::UCHAR)
506 {
507 setElementComponents(VERTEX, COLOR, b, t);
508 }
509
510 void setVertexQuality(bool b = true, DataType t = PrimitiveType::DOUBLE)
511 {
512 setElementComponents(VERTEX, QUALITY, b, t);
513 }
514
515 void setVertexTexCoords(bool b = true, DataType t = PrimitiveType::FLOAT)
516 {
517 setElementComponents(VERTEX, TEXCOORD, b, t);
518 }
519
520 void setVertexCustomComponents(bool b = true)
521 {
522 setElementComponents(VERTEX, CUSTOM_COMPONENTS, b, PrimitiveType::NONE);
523 }
524
525 void setFaces(bool b = true) { setElement(FACE, b); }
526
527 void setFaceVRefs(bool b = true)
528 {
529 setElementComponents(FACE, VREFS, b, PrimitiveType::NONE);
530 }
531
532 void setFaceNormals(bool b = true, DataType t = PrimitiveType::FLOAT)
533 {
534 setElementComponents(FACE, NORMAL, b, t);
535 }
536
537 void setFaceColors(bool b = true, DataType t = PrimitiveType::UCHAR)
538 {
539 setElementComponents(FACE, COLOR, b, t);
540 }
541
542 void setFaceQuality(bool b = true, DataType t = PrimitiveType::DOUBLE)
543 {
544 setElementComponents(FACE, QUALITY, b, t);
545 }
546
547 void setFaceWedgeTexCoords(bool b = true, DataType t = PrimitiveType::FLOAT)
548 {
549 setElementComponents(FACE, WEDGE_TEXCOORDS, b, t);
550 }
551
552 void setFaceCustomComponents(bool b = true)
553 {
554 setElementComponents(FACE, CUSTOM_COMPONENTS, b, PrimitiveType::NONE);
555 }
556
557 void setEdges(bool b = true) { setElement(EDGE, b); }
558
559 void setEdgeVRefs(bool b = true)
560 {
561 setElementComponents(EDGE, VREFS, b, PrimitiveType::NONE);
562 }
563
564 void setEdgeColors(bool b = true, DataType t = PrimitiveType::UCHAR)
565 {
566 setElementComponents(EDGE, COLOR, b, t);
567 }
568
569 void setEdgeNormals(bool b = true, DataType t = PrimitiveType::FLOAT)
570 {
571 setElementComponents(EDGE, NORMAL, b, t);
572 }
573
574 void setEdgeQuality(bool b = true, DataType t = PrimitiveType::DOUBLE)
575 {
576 setElementComponents(EDGE, QUALITY, b, t);
577 }
578
579 void setEdgeCustomComponents(bool b = true)
580 {
581 setElementComponents(EDGE, CUSTOM_COMPONENTS, b, PrimitiveType::NONE);
582 }
583
584 void setTextures(bool b = true)
585 {
586 setElementComponents(MESH, TEXTURES, b, PrimitiveType::NONE);
587 }
588
589 void addElementCustomComponent(
590 Element el,
591 const std::string& name,
592 DataType t)
593 {
594 setElementComponents(el, CUSTOM_COMPONENTS, true, PrimitiveType::NONE);
595 mPerElemCustomComponents[el].emplace_back(name, t);
596 }
597
598 void clearElementCustomComponents(Element el)
599 {
600 setElementComponents(el, CUSTOM_COMPONENTS, false, PrimitiveType::NONE);
601 mPerElemCustomComponents[el].clear();
602 }
603
604 void addVertexCustomComponent(const std::string& name, DataType t)
605 {
606 addElementCustomComponent(VERTEX, name, t);
607 }
608
609 void clearVertexCustomComponents() { clearElementCustomComponents(VERTEX); }
610
611 void addFaceCustomComponent(const std::string& name, DataType t)
612 {
613 addElementCustomComponent(FACE, name, t);
614 }
615
616 void clearFaceCustomComponents() { clearElementCustomComponents(FACE); }
617
618 void addEdgeCustomComponent(const std::string& name, DataType t)
619 {
620 addElementCustomComponent(EDGE, name, t);
621 }
622
623 void clearEdgeCustomComponents() { clearElementCustomComponents(EDGE); }
624
625 /*
626 * Getter Component type functions : they are used mostly by save functions
627 * to know the type that needs to use to save a given Component
628 */
629
630 DataType elementComponentType(Element el, Component comp) const
631 {
632 return mPerElemComponentsType(el, comp);
633 }
634
635 DataType vertexCoordsType() const
636 {
637 return elementComponentType(VERTEX, COORD);
638 }
639
640 DataType vertexNormalsType() const
641 {
642 return elementComponentType(VERTEX, NORMAL);
643 }
644
645 DataType vertexColorsType() const
646 {
647 return elementComponentType(VERTEX, COLOR);
648 }
649
650 DataType vertexQualityType() const
651 {
652 return elementComponentType(VERTEX, QUALITY);
653 }
654
655 DataType vertexTexCoordsType() const
656 {
657 return elementComponentType(VERTEX, TEXCOORD);
658 }
659
660 DataType faceNormalsType() const
661 {
662 return elementComponentType(FACE, NORMAL);
663 }
664
665 DataType faceColorsType() const
666 {
667 return elementComponentType(FACE, COLOR);
668 }
669
670 DataType faceQualityType() const
671 {
672 return elementComponentType(FACE, QUALITY);
673 }
674
675 DataType faceWedgeTexCoordsType() const
676 {
677 return elementComponentType(FACE, WEDGE_TEXCOORDS);
678 }
679
680 DataType edgeColorsType() const
681 {
682 return elementComponentType(EDGE, COLOR);
683 }
684
685 DataType edgeNormalsType() const
686 {
687 return elementComponentType(EDGE, NORMAL);
688 }
689
690 DataType edgeQualityType() const
691 {
692 return elementComponentType(EDGE, QUALITY);
693 }
694
695 const std::vector<CustomComponent>& vertexCustomComponents() const
696 {
697 return mPerElemCustomComponents[VERTEX];
698 }
699
700 const std::vector<CustomComponent>& faceCustomComponents() const
701 {
702 return mPerElemCustomComponents[FACE];
703 }
704
705 const std::vector<CustomComponent>& edgeCustomComponents() const
706 {
707 return mPerElemCustomComponents[EDGE];
708 }
709
721 [[nodiscard]] MeshInfo intersect(const MeshInfo& info) const
722 {
724 for (uint i = 0; i < NUM_ELEMENTS; ++i) {
725 res.mElements[i] = mElements[i] && info.mElements[i];
726 for (uint j = 0; j < NUM_COMPONENTS; ++j) {
727 res.mPerElemComponents[i][j] =
728 mPerElemComponents[i][j] && info.mPerElemComponents[i][j];
729
730 if (res.mPerElemComponents[i][j]) {
731 res.mPerElemComponentsType(i, j) =
732 mPerElemComponentsType(i, j);
733 }
734 }
735 }
736
737 if (mType == info.mType) {
738 res.mType = mType;
739 }
740 res.mPerElemCustomComponents = mPerElemCustomComponents;
741
742 return res;
743 }
744
745private:
754 template<typename T>
756 {
757 if constexpr (std::is_same_v<T, char>)
758 return PrimitiveType::CHAR;
759 if constexpr (std::is_same_v<T, unsigned char>)
760 return PrimitiveType::UCHAR;
761 if constexpr (std::is_same_v<T, short>)
762 return PrimitiveType::SHORT;
763 if constexpr (std::is_same_v<T, unsigned short>)
764 return PrimitiveType::USHORT;
765 if constexpr (std::is_same_v<T, int>)
766 return PrimitiveType::INT;
767 if constexpr (std::is_same_v<T, uint>)
768 return PrimitiveType::UINT;
769 if constexpr (std::is_integral_v<T>)
770 return PrimitiveType::INT; // fallback to int
771 if constexpr (std::is_same_v<T, float>)
772 return PrimitiveType::FLOAT;
773 if constexpr (std::is_same_v<T, double>)
774 return PrimitiveType::DOUBLE;
775 if constexpr (std::is_floating_point_v<T>)
776 return PrimitiveType::FLOAT; // fallback to float
777 return PrimitiveType::NONE;
778 }
779
780 static DataType getType(std::type_index ti)
781 {
782 if (ti == typeid(char))
783 return PrimitiveType::CHAR;
784 if (ti == typeid(unsigned char))
785 return PrimitiveType::UCHAR;
786 if (ti == typeid(short))
787 return PrimitiveType::SHORT;
788 if (ti == typeid(unsigned short))
789 return PrimitiveType::USHORT;
790 if (ti == typeid(int))
791 return PrimitiveType::INT;
792 if (ti == typeid(uint))
793 return PrimitiveType::UINT;
794 if (ti == typeid(float))
795 return PrimitiveType::FLOAT;
796 if (ti == typeid(double))
797 return PrimitiveType::DOUBLE;
798 return PrimitiveType::NONE;
799 }
800};
801
802template<uint ELEM_ID, MeshConcept MeshType>
803void addPerElementCustomComponent(
804 MeshType& m,
805 const MeshInfo::CustomComponent& cc)
806{
807 switch (cc.type) {
808 case PrimitiveType::CHAR:
809 m.template addPerElementCustomComponent<ELEM_ID, char>(cc.name);
810 break;
811 case PrimitiveType::UCHAR:
812 m.template addPerElementCustomComponent<ELEM_ID, unsigned char>(
813 cc.name);
814 break;
815 case PrimitiveType::SHORT:
816 m.template addPerElementCustomComponent<ELEM_ID, short>(cc.name);
817 break;
818 case PrimitiveType::USHORT:
819 m.template addPerElementCustomComponent<ELEM_ID, unsigned short>(
820 cc.name);
821 break;
822 case PrimitiveType::INT:
823 m.template addPerElementCustomComponent<ELEM_ID, int>(cc.name);
824 break;
825 case PrimitiveType::UINT:
826 m.template addPerElementCustomComponent<ELEM_ID, uint>(cc.name);
827 break;
828 case PrimitiveType::FLOAT:
829 m.template addPerElementCustomComponent<ELEM_ID, float>(cc.name);
830 break;
831 case PrimitiveType::DOUBLE:
832 m.template addPerElementCustomComponent<ELEM_ID, double>(cc.name);
833 break;
834 default: assert(0);
835 }
836}
837
838template<MeshConcept MeshType>
839void addPerVertexCustomComponent(
840 MeshType& m,
841 const MeshInfo::CustomComponent& cc)
842{
843 addPerElementCustomComponent<ElemId::VERTEX>(m, cc);
844}
845
846template<FaceMeshConcept MeshType>
847void addPerFaceCustomComponent(MeshType& m, const MeshInfo::CustomComponent& cc)
848{
849 addPerElementCustomComponent<ElemId::FACE>(m, cc);
850}
851
852template<EdgeMeshConcept MeshType>
853void addPerEdgeCustomComponent(MeshType& m, const MeshInfo::CustomComponent& cc)
854{
855 addPerElementCustomComponent<ElemId::EDGE>(m, cc);
856}
857
871template<MeshConcept MeshType>
872void enableOptionalComponentsFromInfo(MeshInfo& info, MeshType& m)
873{
874 if (info.hasVertices()) {
875 if (info.hasVertexColors()) {
876 if (!enableIfPerVertexColorOptional(m)) {
877 info.setVertexColors(false);
878 }
879 }
880 if (info.hasVertexNormals()) {
881 if (!enableIfPerVertexNormalOptional(m)) {
882 info.setVertexNormals(false);
883 }
884 }
885 if (info.hasVertexQuality()) {
886 if (!enableIfPerVertexQualityOptional(m)) {
887 info.setVertexQuality(false);
888 }
889 }
890 if (info.hasVertexTexCoords()) {
891 if (!enableIfPerVertexTexCoordOptional(m)) {
892 info.setVertexTexCoords(false);
893 }
894 }
895 if (info.hasVertexCustomComponents()) {
896 if constexpr (HasPerVertexCustomComponents<MeshType>) {
897 for (const auto& cc : info.vertexCustomComponents()) {
898 addPerVertexCustomComponent(m, cc);
899 }
900 }
901 else {
902 info.clearVertexCustomComponents();
903 }
904 }
905 }
906 else {
907 info.setVertices(false);
908 }
909
910 if constexpr (HasFaces<MeshType>) {
911 if (info.hasFaces()) {
912 if (info.hasFaceColors()) {
914 info.setFaceColors(false);
915 }
916 }
917 if (info.hasFaceNormals()) {
919 info.setFaceNormals(false);
920 }
921 }
922 if (info.hasFaceQuality()) {
924 info.setFaceQuality(false);
925 }
926 }
927 if (info.hasFaceWedgeTexCoords()) {
929 info.setFaceWedgeTexCoords(false);
930 }
931 }
932 if (info.hasFaceCustomComponents()) {
933 if constexpr (HasPerFaceCustomComponents<MeshType>) {
934 for (const auto& cc : info.faceCustomComponents()) {
935 addPerFaceCustomComponent(m, cc);
936 }
937 }
938 else {
939 info.clearFaceCustomComponents();
940 }
941 }
942 }
943 else {
944 info.setFaces(false);
945 }
946 }
947 else {
948 info.setFaces(false);
949 }
950
951 if constexpr (HasEdges<MeshType>) {
952 if (info.hasEdges()) {
953 if (info.hasEdgeColors()) {
955 info.setEdgeColors(false);
956 }
957 }
958 if (info.hasEdgeNormals()) {
960 info.setEdgeNormals(false);
961 }
962 }
963 if (info.hasEdgeQuality()) {
965 info.setEdgeQuality(false);
966 }
967 }
968 if (info.hasEdgeCustomComponents()) {
969 if constexpr (HasPerEdgeCustomComponents<MeshType>) {
970 for (const auto& cc : info.edgeCustomComponents()) {
971 addPerEdgeCustomComponent(m, cc);
972 }
973 }
974 else {
975 info.clearEdgeCustomComponents();
976 }
977 }
978 }
979 else {
980 info.setEdges(false);
981 }
982 }
983 else {
984 info.setEdges(false);
985 }
986}
987
988} // namespace vcl
989
990#endif // VCL_SPACE_COMPLEX_MESH_INFO_H
The Element class.
Definition element.h:57
A simple class that allows to store which elements and their components have been imported/loaded or ...
Definition mesh_info.h:76
MeshInfo intersect(const MeshInfo &info) const
Returns a MeshInfo object that is the intersection between this and info.
Definition mesh_info.h:721
static DataType getType()
Given the template T, returns the corresponding enum DataType value of T.
Definition mesh_info.h:755
bool isEmpty() const
Returns whether the current MeshInfo object is empty, i.e., it has no Elements set.
Definition mesh_info.h:295
bool hasVertexColors() const
Returns true if the current object has Vertex Colors.
Definition mesh_info.h:361
Component
Enum used to describe the type of Components that each Element can have.
Definition mesh_info.h:97
bool isTriangleMesh() const
Returns true if the current object has Mesh type set to MeshType::TRIANGLE_MESH.
Definition mesh_info.h:304
void clear()
Clears the MeshInfo object.
Definition mesh_info.h:278
bool hasFaceVRefs() const
Returns true if the current object has per Face Vertex References.
Definition mesh_info.h:403
bool isQuadMesh() const
Returns true if the current object has Mesh type set to MeshType::QUAD_MESH.
Definition mesh_info.h:311
bool hasVertices() const
Returns true if the current object has Vertex Elements.
Definition mesh_info.h:337
bool hasVertexCustomComponents() const
Returns true if the current object has Vertex Custom Components.
Definition mesh_info.h:388
bool isPolygonMesh() const
Returns true if the current object has Mesh type set to MeshType::POLYGON_MESH.
Definition mesh_info.h:318
PrimitiveType DataType
Enum used to describe the type of Data stored in a component.
Definition mesh_info.h:113
bool hasFaces() const
Returns true if the current object has Face Elements.
Definition mesh_info.h:397
bool hasVertexQuality() const
Returns true if the current object has Vertex Quality.
Definition mesh_info.h:370
bool hasVertexCoords() const
Returns true if the current object has Vertex Coordinates.
Definition mesh_info.h:343
bool hasVertexTexCoords() const
Returns true if the current object has Vertex Texture Coordinates.
Definition mesh_info.h:379
bool hasEdges() const
Returns true if the current object has Edge Elements.
Definition mesh_info.h:428
Element
Enum used to describe the type of Elements that can be found in a file.
Definition mesh_info.h:91
bool hasVertexNormals() const
Returns true if the current object has Vertex Normals.
Definition mesh_info.h:352
MeshInfo()
Default constructor.
Definition mesh_info.h:153
MeshInfo(const Mesh &m)
Sets the current status of the MeshInfo object from the input mesh.
Definition mesh_info.h:165
MeshType
Enum used to describe the type of the Mesh - by default, the value is set to UNKNOWN.
Definition mesh_info.h:82
The Mesh class represents a generic 3D mesh. A mesh is composed of a generic number of containers of ...
Definition mesh.h:68
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
HasEdges concepts is satisfied when at least one of its template types is (or inherits from) a vcl::m...
Definition edge_container.h:131
HasFaces concepts is satisfied when at least one of its template types is (or inherits from) a vcl::m...
Definition face_container.h:133
Concept that checks if a Mesh has the per Face Color component.
Definition per_face.h:111
Concept that checks if a Mesh has the per Face CustomComponents component.
Definition per_face.h:127
Concept that checks if a Mesh has the per Face Normal component.
Definition per_face.h:158
Concept that checks if a Mesh has the per Face Quality component.
Definition per_face.h:206
Concept that checks if a Mesh has the per Face WedgeTexCoords component.
Definition per_face.h:270
Concept that checks if a Mesh has the per Vertex Color component.
Definition per_vertex.h:98
Concept that checks if a Mesh has the per Vertex CustomComponents.
Definition per_vertex.h:188
Concept that checks if a Mesh has the per Vertex Normal component.
Definition per_vertex.h:128
Concept that checks if a Mesh has the per Vertex Quality component.
Definition per_vertex.h:159
Concept that checks if a Mesh has the per Vertex TexCoord component.
Definition per_vertex.h:174
Definition per_face.h:44
Concept that checks if a Mesh has the TexturePaths component.
Definition per_mesh.h:112
Definition per_face.h:40
bool enableIfPerEdgeColorOptional(MeshType &m)
If the input mesh has a EdgeContainer, and the Edge Element has a Color Component,...
Definition edge_requirements.h:238
bool enableIfPerEdgeNormalOptional(MeshType &m)
If the input mesh has a EdgeContainer, and the Edge Element has a Normal Component,...
Definition edge_requirements.h:354
bool enableIfPerEdgeQualityOptional(MeshType &m)
If the input mesh has a EdgeContainer, and the Edge Element has a Quality Component,...
Definition edge_requirements.h:412
bool enableIfPerFaceQualityOptional(MeshType &m)
If the input mesh has a FaceContainer, and the Face Element has a Quality Component,...
Definition face_requirements.h:475
bool enableIfPerFaceWedgeTexCoordsOptional(MeshType &m)
If the input mesh has a FaceContainer, and the Face Element has a WedgeTexCoords Component,...
Definition face_requirements.h:597
bool isPerFaceWedgeTexCoordsAvailable(const MeshType &m)
Returns true if the WedgeTexCoords component is available (enabled) in the Face element of the input ...
Definition face_requirements.h:571
bool isPerFaceNormalAvailable(const MeshType &m)
Returns true if the Normal component is available (enabled) in the Face element of the input mesh m.
Definition face_requirements.h:330
bool isPerFaceQualityAvailable(const MeshType &m)
Returns true if the Quality component is available (enabled) in the Face element of the input mesh m.
Definition face_requirements.h:451
bool isPerFaceColorAvailable(const MeshType &m)
Returns true if the Color component is available (enabled) in the Face element of the input mesh m.
Definition face_requirements.h:214
bool enableIfPerFaceNormalOptional(MeshType &m)
If the input mesh has a FaceContainer, and the Face Element has a Normal Component,...
Definition face_requirements.h:354
bool enableIfPerFaceColorOptional(MeshType &m)
If the input mesh has a FaceContainer, and the Face Element has a Color Component,...
Definition face_requirements.h:238
PrimitiveType
A simple type that enumerates the main primitive types.
Definition base.h:58
The CustomComponent struct is a simple structure that describes a custom component of an Element (or ...
Definition mesh_info.h:120