Visual Computing Library
Loading...
Searching...
No Matches
element_requirements.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_REQUIREMENTS_ELEMENT_REQUIREMENTS_H
24#define VCL_MESH_REQUIREMENTS_ELEMENT_REQUIREMENTS_H
25
26#include <vclib/concepts/mesh.h>
27#include <vclib/exceptions/mesh.h>
28
29namespace vcl {
30
45template<uint ELEM_ID, MeshConcept MeshType>
46bool isElementContainerCompact(const MeshType& m)
47{
48 return (
49 m.template number<ELEM_ID>() == m.template containerSize<ELEM_ID>());
50}
51
81template<uint ELEM_ID, uint COMP_ID, MeshConcept MeshType>
82bool isPerElementComponentAvailable(const MeshType& m)
83{
85 using Container = mesh::ContainerOfElementType<ELEM_ID, MeshType>;
86 using Element = Container::ElementType;
89 }
90 else {
92 }
93 }
94 else {
95 return false;
96 }
97}
98
119template<uint ELEM_ID, uint COMP_ID, MeshConcept MeshType>
121{
123 using Container = mesh::ContainerOfElementType<ELEM_ID, MeshType>;
124 using Element = Container::ElementType;
127 return true;
128 }
129 else {
131 }
132 }
133 else {
134 return false;
135 }
136}
137
157template<uint ELEM_ID, MeshConcept MeshType>
159{
163 " Container of the Mesh is not compact.");
164}
165
193template<uint ELEM_ID, uint COMP_ID, MeshConcept MeshType>
194void requirePerElementComponent(const MeshType& m)
195{
198 "Per " + std::string(elementEnumString<ELEM_ID>()) + " " +
199 std::string(componentEnumString<COMP_ID>()) +
200 " Component is not enabled.");
201 }
202}
203
204} // namespace vcl
205
206#endif // VCL_MESH_REQUIREMENTS_ELEMENT_REQUIREMENTS_H
The Element class.
Definition element.h:57
Exception thrown when the mesh is not compact.
Definition mesh.h:81
Exception thrown when a mesh/element component is missing (not enabled).
Definition mesh.h:104
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
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
Definition mesh_concept.h:36
bool isPerElementComponentAvailable(const MeshType &m)
Returns true if the given component is available in the given element of the input mesh m.
Definition element_requirements.h:82
bool isElementContainerCompact(const MeshType &m)
Returns true if the given mesh has its Container of the given Element compact.
Definition element_requirements.h:46
void requirePerElementComponent(const MeshType &m)
This function asserts that a Mesh has the Container of the given Element ID, the Element has a Compon...
Definition element_requirements.h:194
void requireElementContainerCompactness(const MeshType &m)
This function asserts that a Mesh has the Container of the given Element ID compact (no elements flag...
Definition element_requirements.h:158
bool enableIfPerElementComponentOptional(MeshType &m)
Makes available the given Component in the given Element of the input mesh m, and returns true if it ...
Definition element_requirements.h:120