Visual Computing Library
Loading...
Searching...
No Matches
mesh_containers.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_CONTAINERS_H
24#define VCL_TYPES_MESH_CONTAINERS_H
25
26#include "base.h"
27#include "filter_types.h"
28#include "pointers.h"
29
30namespace vcl {
31
32namespace mesh {
33
34namespace detail {
35
45template<uint ELEM_ID, typename... Containers>
46struct ContainerOfElementPred
47{
48private:
49 template<typename Cont>
50 struct SameElPred
51 {
52 static constexpr bool value = Cont::ELEMENT_ID == ELEM_ID;
53 };
54
55public:
56 // TypeWrapper of the found container, if any
57 using type =
58 typename FilterTypesByCondition<SameElPred, Containers...>::type;
59 static constexpr bool value = NumberOfTypes<type>::value == 1;
60};
61
62// TypeWrapper specialization
63template<uint ELEM_ID, typename... Containers>
64struct ContainerOfElementPred<ELEM_ID, TypeWrapper<Containers...>> :
65 public ContainerOfElementPred<ELEM_ID, Containers...>
66{
67};
68
69} // namespace detail
70
74
79template<typename T>
81{
82 static const bool value =
83 std::is_base_of<ElementContainerTriggerer, RemoveRef<T>>::value;
84};
85
105template<uint ELEM_ID, typename MeshType>
107{
108public:
109 using type = FirstTypeT<typename detail::ContainerOfElementPred<
110 ELEM_ID,
111 typename RemoveRef<MeshType>::Containers>::type>;
112};
113
132template<uint ELEM_ID, typename MeshType>
133using ContainerOfElementType =
135
136template<typename El, typename MeshType>
138{
139 static constexpr bool value = detail::ContainerOfElementPred<
141 typename RemoveRef<MeshType>::Containers>::value;
142};
143
144template<uint ELEM_ID, typename MeshType>
146{
147 static constexpr bool value = detail::ContainerOfElementPred<
148 ELEM_ID,
149 typename RemoveRef<MeshType>::Containers>::value;
150};
151
152} // namespace mesh
153
154} // namespace vcl
155
156#endif // VCL_TYPES_MESH_CONTAINERS_H
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Definition mesh_containers.h:72
typename FirstType< Args... >::type FirstTypeT
Alias for the type of the first type in a pack of types.
Definition variadic_templates.h:65
std::remove_reference_t< T > RemoveRef
Utility alias to get a type type without the reference. e.g. If T is int&, the resulting type is int.
Definition pointers.h:55
The ContainerOfElement structure exposes the type of the container of the given MeshType having eleme...
Definition mesh_containers.h:107
Definition mesh_containers.h:146
Definition mesh_containers.h:138
The predicate IsElementContainerPred sets its bool value to true when the type T satisfies the Elemen...
Definition mesh_containers.h:81