Visual Computing Library
Loading...
Searching...
No Matches
vertex_references.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_COMPONENTS_VERTEX_REFERENCES_H
24#define VCL_CONCEPTS_MESH_COMPONENTS_VERTEX_REFERENCES_H
25
26#include <vclib/concepts/const_correctness.h>
27#include <vclib/concepts/iterators.h>
28#include <vclib/concepts/ranges/range.h>
29
30#include <vector>
31
32namespace vcl::comp {
33
42template<typename T>
43concept HasVertexReferences = requires (
44 T&& obj,
45 typename RemoveRef<T>::VertexType v,
46 typename RemoveRef<T>::VertexIterator it,
47 typename RemoveRef<T>::ConstVertexIterator cIt,
48 typename RemoveRef<T>::ConstVertexIndexIterator cIIt,
49 typename RemoveRef<T>::VertexType* vP,
50 const typename RemoveRef<T>::VertexType* cVP,
51 std::vector<typename RemoveRef<T>::VertexType*> vecV,
52 std::vector<uint> vecU) {
53 RemoveRef<T>::VERTEX_NUMBER;
54
55 typename RemoveRef<T>::VertexType;
56 typename RemoveRef<T>::VertexIterator;
57 typename RemoveRef<T>::ConstVertexIterator;
58 typename RemoveRef<T>::ConstVertexIndexIterator;
59
60 { obj.vertexNumber() } -> std::same_as<uint>;
61
62 { obj.vertex(uint()) } -> std::convertible_to<decltype(cVP)>;
63 { obj.vertexIndex(uint()) } -> std::same_as<uint>;
64 { obj.vertexMod(int()) } -> std::convertible_to<decltype(cVP)>;
65 { obj.vertexIndexMod(int()) } -> std::same_as<uint>;
66
67 { obj.containsVertex(&v) } -> std::same_as<bool>;
68 { obj.containsVertex(uint()) } -> std::same_as<bool>;
69 { obj.indexOfVertex(&v) } -> std::same_as<uint>;
70 { obj.indexOfVertex(uint()) } -> std::same_as<uint>;
71 { obj.indexOfEdge(&v, &v) } -> std::same_as<uint>;
72 { obj.indexOfEdge(uint(), uint()) } -> std::same_as<uint>;
73
74 { obj.vertexBegin() } -> InputIterator<decltype(cVP)>;
75 { obj.vertexEnd() } -> InputIterator<decltype(cVP)>;
76
77 { obj.vertexIndexBegin() } -> InputIterator<uint>;
78 { obj.vertexIndexEnd() } -> InputIterator<uint>;
79
80 { obj.vertices() } -> InputRange<decltype(cVP)>;
81 { obj.vertexIndices() } -> InputRange<uint>;
82
83 // non const requirements
84 requires IsConst<T> || requires {
85 { obj.vertex(uint()) } -> std::same_as<decltype(vP)>;
86 { obj.vertexMod(int()) } -> std::same_as<decltype(vP)>;
87
88 { obj.setVertex(uint(), &v) } -> std::same_as<void>;
89 { obj.setVertex(uint(), uint()) } -> std::same_as<void>;
90 { obj.setVertex(it, &v) } -> std::same_as<void>;
91 { obj.setVertex(it, uint()) } -> std::same_as<void>;
92 { obj.setVertex(cIt, &v) } -> std::same_as<void>;
93 { obj.setVertex(cIt, uint()) } -> std::same_as<void>;
94 { obj.setVertex(cIIt, &v) } -> std::same_as<void>;
95 { obj.setVertex(cIIt, uint()) } -> std::same_as<void>;
96 { obj.setVertexMod(int(), &v) } -> std::same_as<void>;
97 { obj.setVertexMod(int(), uint()) } -> std::same_as<void>;
98 { obj.setVertices(vecV) } -> std::same_as<void>;
99 { obj.setVertices(vecU) } -> std::same_as<void>;
100
101 // for references components, the iterators returned by begin() and
102 // end() are input iterators because they do not allow to modify the
103 // content of the container (the only way to do that is by using the set
104 // member functions). However, they allow to modify the elements
105 // pointed by the iterators (const references components allow to
106 // iterate only trough const pointers instead).
107 { obj.vertexBegin() } -> InputIterator<decltype(vP)>;
108 { obj.vertexEnd() } -> InputIterator<decltype(vP)>;
109
110 { obj.vertices() } -> InputRange<decltype(vP)>;
111 };
112};
113
114} // namespace vcl::comp
115
116#endif // VCL_CONCEPTS_MESH_COMPONENTS_VERTEX_REFERENCES_H
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
HasVertexReferences concept is satisfied only if a Element class provides the types and member functi...
Definition vertex_references.h:43