Visual Computing Library
Loading...
Searching...
No Matches
mesh_concept.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_CONCEPTS_MESH_MESH_CONCEPT_H
24#define VCL_CONCEPTS_MESH_MESH_CONCEPT_H
25
26#include "containers/edge_container.h"
27#include "containers/vertex_container.h"
28#include "elements/element.h"
29#include "per_face.h"
30
31namespace vcl {
32
33namespace mesh {
34
35template<typename MeshType, uint ELEM_ID>
37 HasContainerOfElementPred<ELEM_ID, MeshType>::value;
38
39template<typename MeshType, uint ELEM_ID, uint COMP_ID>
43 typename ContainerOfElementType<ELEM_ID, MeshType>::ElementType,
44 COMP_ID>;
45
46template<typename MeshType, uint ELEM_ID, uint COMP_ID>
50 typename ContainerOfElementType<ELEM_ID, MeshType>::ElementType,
51 COMP_ID>;
52
53} // namespace mesh
54
76template<typename T>
77concept MeshConcept =
78 // the mesh has a VertexContainer
79 mesh::HasVertexContainer<T> && requires (
80 T&& obj,
81 typename RemoveRef<T>::VertexType v,
82 typename RemoveRef<T>::VertexType& vR,
83 typename RemoveRef<T>::VertexType* vP,
84 std::vector<uint> vec) {
85 // The mesh defines TypeWrappers for Containers and Components
86 typename RemoveRef<T>::Containers;
87 typename RemoveRef<T>::Components;
88
89 // calling MeshType::ElementType<ElemId::VERTEX> does return the
90 // VertexType
91 requires std::same_as<
92 decltype(v),
93 typename RemoveRef<T>::template ElementType<ElemId::VERTEX>>;
94
95 // can call hasContainerOf static function with element types
96 requires RemoveRef<T>::template hasContainerOf<decltype(v)>();
97
98 // can call hasContainerOf static function with element ids
99 requires RemoveRef<T>::template hasContainerOf<ElemId::VERTEX>();
100
101 // can call the hasPerElementComponent static function
102 requires RemoveRef<T>::template hasPerElementComponent<
103 ElemId::VERTEX,
104 CompId::COORDINATE>();
105
106 // constructors
107 RemoveRef<T>();
108 RemoveRef<T>(obj);
109
110 // member functions
111 { obj.isCompact() } -> std::same_as<bool>;
112 { obj.index(v) } -> std::same_as<uint>;
113
114 // generic per ElemId member functions
115 {
116 obj.template element<ElemId::VERTEX>(uint())
117 } -> std::convertible_to<decltype(v)>;
118
119 { obj.template number<ElemId::VERTEX>() } -> std::same_as<uint>;
120 { obj.template containerSize<ElemId::VERTEX>() } -> std::same_as<uint>;
121 { obj.template deletedNumber<ElemId::VERTEX>() } -> std::same_as<uint>;
122 {
123 obj.template compactIndices<ElemId::VERTEX>()
124 } -> std::same_as<decltype(vec)>;
125
126 { obj.template begin<ElemId::VERTEX>() } -> InputIterator<decltype(v)>;
127 {
128 obj.template begin<ElemId::VERTEX>(bool())
129 } -> InputIterator<decltype(v)>;
130 { obj.template end<ElemId::VERTEX>() } -> InputIterator<decltype(v)>;
131 { obj.template elements<ElemId::VERTEX>() } -> InputRange<decltype(v)>;
132 {
133 obj.template elements<ElemId::VERTEX>(bool())
134 } -> InputRange<decltype(v)>;
135
136 // non const requirements
137 requires IsConst<T> || requires {
138 // member functions
139 { obj.clear() } -> std::same_as<void>;
140 { obj.compact() } -> std::same_as<void>;
141 { obj.enableAllOptionalComponents() } -> std::same_as<void>;
142 { obj.disableAllOptionalComponents() } -> std::same_as<void>;
143 { obj.enableSameOptionalComponentsOf(obj) } -> std::same_as<void>;
144 { obj.append(obj) } -> std::same_as<void>;
145 { obj.importFrom(obj) } -> std::same_as<void>;
146 { obj.swap(obj) } -> std::same_as<void>;
147 { obj.deleteElement(v) } -> std::same_as<void>;
148 { obj.deleteElement(vP) } -> std::same_as<void>;
149
150 // assignment operator
151 { obj = obj } -> std::same_as<T&>;
152
153 // generic per ElemId member functions
154 {
155 obj.template element<ElemId::VERTEX>(uint())
156 } -> std::same_as<decltype(vR)>;
157 { obj.template add<ElemId::VERTEX>() } -> std::same_as<uint>;
158 { obj.template add<ElemId::VERTEX>(uint()) } -> std::same_as<uint>;
159 {
160 obj.template clearElements<ElemId::VERTEX>()
161 } -> std::same_as<void>;
162 {
163 obj.template resize<ElemId::VERTEX>(uint())
164 } -> std::same_as<void>;
165 {
166 obj.template reserve<ElemId::VERTEX>(uint())
167 } -> std::same_as<void>;
168 {
169 obj.template deleteElement<ElemId::VERTEX>(uint())
170 } -> std::same_as<void>;
171 {
172 obj.template updateIndices<ElemId::VERTEX>(vec)
173 } -> std::same_as<void>;
174
175 {
176 obj.template begin<ElemId::VERTEX>()
177 } -> OutputIterator<decltype(v)>;
178 {
179 obj.template begin<ElemId::VERTEX>(bool())
180 } -> OutputIterator<decltype(v)>;
181 {
182 obj.template end<ElemId::VERTEX>()
183 } -> OutputIterator<decltype(v)>;
184 {
185 obj.template elements<ElemId::VERTEX>()
186 } -> OutputRange<decltype(v)>;
187 {
188 obj.template elements<ElemId::VERTEX>(bool())
189 } -> OutputRange<decltype(v)>;
190 };
191 };
192
199template<typename T>
201
208template<typename T>
210
217template<typename T>
219
220template<typename T>
222
223template<typename T>
225
226template<typename T>
228
229} // namespace vcl
230
231#endif // VCL_CONCEPTS_MESH_MESH_CONCEPT_H
The EdgeMeshConcept is evaluated true if the type T is a Mesh (it satisfies the vcl::MeshConcept) and...
Definition mesh_concept.h:209
Definition element.h:31
the ElementOrMesh Concept is evaluated to true when the type is either a Mesh or an Element.
Definition mesh_concept.h:200
The FaceMeshConcept is evaluated true if the type T is a Mesh (it satisfies the vcl::MeshConcept) and...
Definition mesh_concept.h:218
Definition per_face.h:48
Definition per_face.h:44
Definition per_face.h:40
The InputIterator concept is satisfied if T is an input iterator that implements the operator* return...
Definition iterators.h:46
Utility concept that is evaluated true the Range R is an Input Range and has a value_type that is con...
Definition range.h:89
The IsConst concept is satisfied if T satisfies one of the following conditions:
Definition const_correctness.h:43
The Mesh Concept is evaluated to true when the type is a Mesh.
Definition mesh_concept.h:77
The OutputIterator concept is satisfied if T is an output iterator that implements the operator* retu...
Definition iterators.h:60
Utility concept that is evaluated true the Range R is an Output Range and has a value_type that is T.
Definition range.h:113
Definition mesh_concept.h:227
Definition mesh_concept.h:224
Definition mesh_concept.h:221
The HasComponentOfType concept checks whether a type T (that may be a Mesh or a MeshElement) has a co...
Definition component.h:246
The HasOptionalComponentOfType concept checks whether a type T (that should be a MeshElement) has an ...
Definition component.h:288
The HasEdgeContainer concept is satisfied only if a container class provides the types and member fun...
Definition edge_container.h:44
Definition mesh_concept.h:36
The HasFaceContainer concept is satisfied only if a container class provides the types and member fun...
Definition face_container.h:44
Definition mesh_concept.h:40
Definition mesh_concept.h:47
The HasVertexContainer concept is satisfied only if a container class provides the types and member f...
Definition vertex_container.h:44