Visual Computing Library
Loading...
Searching...
No Matches
mesh_components.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_TYPES_MESH_COMPONENTS_H
24#define VCL_TYPES_MESH_COMPONENTS_H
25
26#include "filter_types.h"
27
28// TODO: complete documentation
29
30namespace vcl {
31
49struct CompId
50{
51 enum Enum {
52 BIT_FLAGS = 0,
53 COORDINATE,
54 NORMAL,
55 COLOR,
56 QUALITY,
57 MARK,
58 PRINCIPAL_CURVATURE,
59 TEX_COORD,
60 VERTEX_REFERENCES,
61 ADJACENT_EDGES,
62 ADJACENT_FACES,
63 ADJACENT_VERTICES,
64 WEDGE_COLORS,
65 WEDGE_TEX_COORDS,
66 BOUNDING_BOX,
67 NAME,
68 TEXTURE_IMAGES,
69 TEXTURE_PATHS,
70 TRANSFORM_MATRIX,
71 CUSTOM_COMPONENTS,
72 // Additional components here
73
74 COMPONENTS_NUMBER,
75 };
76};
77
84constexpr const char* COMPONENT_ENUM_STRINGS[CompId::COMPONENTS_NUMBER] = {
85 "BitFlags",
86 "Coordinate",
87 "Normal",
88 "Color",
89 "Quality",
90 "Mark",
91 "PrincipalCurvature",
92 "TexCoord",
93 "VertexPointers",
94 "AdjacentEdges",
95 "AdjacentFaces",
96 "AdjacentVertices",
97 "WedgeColors",
98 "WedgeTexCoords",
99 "BoundingBox",
100 "Name",
101 "TextureImages",
102 "TexturePaths",
103 "TransformMatrix",
104 "CustomComponents",
105};
106
118template<uint COMP_ID>
120{
124 const char* str = COMP_ID < CompId::COMPONENTS_NUMBER ?
126 nullptr;
127};
128
137template<uint COMP_ID>
138constexpr const char* componentEnumString()
139{
140 static_assert(
141 ComponentString<COMP_ID>().str != nullptr,
142 "Invalid ComponentIDEnum. You should specialize the 'ComponentString' "
143 "struct with your COMP_ID value.");
144
145 return ComponentString<COMP_ID>().str;
146}
147
148namespace comp {
149
150namespace detail {
151
161template<uint COMP_ID, typename... Components>
162struct ComponentOfTypePred
163{
164private:
165 template<typename Comp>
166 struct SameCompPred
167 {
168 static constexpr bool value = Comp::COMPONENT_ID == COMP_ID;
169 };
170
171public:
172 // TypeWrapper of the found container, if any
173 using type =
174 typename FilterTypesByCondition<SameCompPred, Components...>::type;
175 static constexpr bool value = NumberOfTypes<type>::value == 1;
176};
177
178// TypeWrapper specialization
179template<uint COMP_ID, typename... Components>
180struct ComponentOfTypePred<COMP_ID, TypeWrapper<Components...>> :
181 public ComponentOfTypePred<COMP_ID, Components...>
182{
183};
184
185} // namespace detail
186
187template<uint COMP_ID, typename... Components>
188using ComponentOfType = FirstTypeT<
189 typename detail::ComponentOfTypePred<COMP_ID, Components...>::type>;
190
191template<typename T>
195
196} // namespace comp
197
198} // namespace vcl
199
200#endif // VCL_TYPES_MESH_COMPONENTS_H
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Definition mesh_components.h:193
typename FirstType< Args... >::type FirstTypeT
Alias for the type of the first type in a pack of types.
Definition variadic_templates.h:65
constexpr const char * COMPONENT_ENUM_STRINGS[CompId::COMPONENTS_NUMBER]
The COMPONENT_ENUM_STRINGS array contains the string representation of the CompId::Enum values.
Definition mesh_components.h:84
constexpr const char * componentEnumString()
Returns the string associated to the COMP_ID value.
Definition mesh_components.h:138
The CompId struct enumerates the components that can compose a element or a mesh.
Definition mesh_components.h:50
The ComponentString class is used to retrieve the string associated to a COMP_ID value,...
Definition mesh_components.h:120
const char * str
The string associated to the COMPONENT_ID.
Definition mesh_components.h:124