Visual Computing Library  devel
Loading...
Searching...
No Matches
base.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_MESH_COMPONENTS_BASE_BASE_H
24#define VCL_MESH_COMPONENTS_BASE_BASE_H
25
26#include <vclib/base.h>
27
28namespace vcl {
29
47struct CompId
48{
49 enum Enum {
50 BIT_FLAGS = 0,
51 POSITION,
52 NORMAL,
53 COLOR,
54 QUALITY,
55 MARK,
56 PRINCIPAL_CURVATURE,
57 TEX_COORD,
58 VERTEX_REFERENCES,
59 ADJACENT_EDGES,
60 ADJACENT_FACES,
61 ADJACENT_VERTICES,
62 WEDGE_COLORS,
63 WEDGE_TEX_COORDS,
64 BOUNDING_BOX,
65 NAME,
66 TEXTURE_IMAGES,
67 TEXTURE_PATHS,
68 TRANSFORM_MATRIX,
69 CUSTOM_COMPONENTS,
70 // Additional components here
71
72 COMPONENTS_NUMBER,
73 };
74};
75
82constexpr const char* COMPONENT_ENUM_STRINGS[CompId::COMPONENTS_NUMBER] = {
83 "BitFlags",
84 "Position",
85 "Normal",
86 "Color",
87 "Quality",
88 "Mark",
89 "PrincipalCurvature",
90 "TexCoord",
91 "VertexPointers",
92 "AdjacentEdges",
93 "AdjacentFaces",
94 "AdjacentVertices",
95 "WedgeColors",
96 "WedgeTexCoords",
97 "BoundingBox",
98 "Name",
99 "TextureImages",
100 "TexturePaths",
101 "TransformMatrix",
102 "CustomComponents",
103};
104
116template<uint COMP_ID>
118{
122 const char* str = COMP_ID < CompId::COMPONENTS_NUMBER ?
124 nullptr;
125};
126
135template<uint COMP_ID>
136constexpr const char* componentEnumString()
137{
138 static_assert(
139 ComponentString<COMP_ID>().str != nullptr,
140 "Invalid ComponentIDEnum. You should specialize the 'ComponentString' "
141 "struct with your COMP_ID value.");
142
143 return ComponentString<COMP_ID>().str;
144}
145
146namespace comp {
147
148namespace detail {
149
159template<uint COMP_ID, typename... Components>
160struct ComponentOfTypePred
161{
162private:
163 template<typename Comp>
164 struct SameCompPred
165 {
166 static constexpr bool value = Comp::COMPONENT_ID == COMP_ID;
167 };
168
169public:
170 // TypeWrapper of the found container, if any
171 using type =
172 typename FilterTypesByCondition<SameCompPred, Components...>::type;
173 static constexpr bool value = NumberOfTypes<type>::value == 1;
174};
175
176// TypeWrapper specialization
177template<uint COMP_ID, typename... Components>
178struct ComponentOfTypePred<COMP_ID, TypeWrapper<Components...>> :
179 public ComponentOfTypePred<COMP_ID, Components...>
180{
181};
182
183} // namespace detail
184
192template<uint COMP_ID, typename... Components>
194 typename detail::ComponentOfTypePred<COMP_ID, Components...>::type>;
195
196template<typename T>
200
201} // namespace comp
202
203} // namespace vcl
204
205#endif // VCL_MESH_COMPONENTS_BASE_BASE_H
A class representing a box in N-dimensional space.
Definition box.h:46
typename FirstType< Args... >::type FirstTypeT
Alias for the type of the first type in a pack of types.
Definition variadic_templates.h:63
constexpr const char * COMPONENT_ENUM_STRINGS[CompId::COMPONENTS_NUMBER]
The COMPONENT_ENUM_STRINGS array contains the string representation of the CompId::Enum values.
Definition base.h:82
constexpr const char * componentEnumString()
Returns the string associated to the COMP_ID value.
Definition base.h:136
The CompId struct enumerates the components that can compose a element or a mesh.
Definition base.h:48
The ComponentString class is used to retrieve the string associated to a COMP_ID value,...
Definition base.h:118
const char * str
The string associated to the COMPONENT_ID.
Definition base.h:122