Visual Computing Library
Loading...
Searching...
No Matches
adjacent_vertices.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_ADJACENT_VERTICES_H
24#define VCL_CONCEPTS_MESH_COMPONENTS_ADJACENT_VERTICES_H
25
26#include "component.h"
27
28#include <vclib/concepts/const_correctness.h>
29#include <vclib/concepts/iterators.h>
30#include <vclib/concepts/ranges/range.h>
31
32#include <vector>
33
34namespace vcl::comp {
35
51template<typename T>
52concept HasAdjacentVertices = requires (
53 T&& obj,
54 typename RemoveRef<T>::AdjacentVertexType v,
55 typename RemoveRef<T>::AdjacentVertexIterator it,
56 typename RemoveRef<T>::ConstAdjacentVertexIterator cIt,
57 typename RemoveRef<T>::ConstAdjacentVertexIndexIterator cIIt,
58 typename RemoveRef<T>::AdjacentVertexType* vP,
59 const typename RemoveRef<T>::AdjacentVertexType* cVP,
60 std::vector<typename RemoveRef<T>::AdjacentVertexType*> vec) {
61 typename RemoveRef<T>::AdjacentVertexType;
62 typename RemoveRef<T>::AdjacentVertexIterator;
63 typename RemoveRef<T>::ConstAdjacentVertexIterator;
64 typename RemoveRef<T>::ConstAdjacentVertexIndexIterator;
65
66 { obj.adjVerticesNumber() } -> std::same_as<uint>;
67
68 { obj.adjVertex(uint()) } -> std::convertible_to<decltype(cVP)>;
69 { obj.adjVertexIndex(uint()) } -> std::same_as<uint>;
70 { obj.adjVertexMod(int()) } -> std::convertible_to<decltype(cVP)>;
71 { obj.adjVertexIndexMod(uint()) } -> std::same_as<uint>;
72
73 { obj.containsAdjVertex(&v) } -> std::same_as<bool>;
74 { obj.containsAdjVertex(uint()) } -> std::same_as<bool>;
75 { obj.indexOfAdjVertex(&v) } -> std::same_as<uint>;
76 { obj.indexOfAdjVertex(uint()) } -> std::same_as<uint>;
77
78 { obj.adjVertexBegin() } -> InputIterator<decltype(cVP)>;
79 { obj.adjVertexEnd() } -> InputIterator<decltype(cVP)>;
80
81 { obj.adjVertexIndexBegin() } -> InputIterator<uint>;
82 { obj.adjVertexIndexEnd() } -> InputIterator<uint>;
83
84 { obj.adjVertices() } -> InputRange<decltype(cVP)>;
85 { obj.adjVertexIndices() } -> InputRange<uint>;
86
87 // non const requirements
88 requires IsConst<T> || requires {
89 { obj.adjVertex(uint()) } -> std::same_as<decltype(vP)>;
90 { obj.adjVertexMod(int()) } -> std::same_as<decltype(vP)>;
91
92 { obj.setAdjVertex(uint(), &v) } -> std::same_as<void>;
93 { obj.setAdjVertex(uint(), uint()) } -> std::same_as<void>;
94 { obj.setAdjVertex(it, &v) } -> std::same_as<void>;
95 { obj.setAdjVertex(it, uint()) } -> std::same_as<void>;
96 { obj.setAdjVertex(cIt, &v) } -> std::same_as<void>;
97 { obj.setAdjVertex(cIt, uint()) } -> std::same_as<void>;
98 { obj.setAdjVertex(cIIt, &v) } -> std::same_as<void>;
99 { obj.setAdjVertex(cIIt, uint()) } -> std::same_as<void>;
100 { obj.setAdjVertexMod(int(), &v) } -> std::same_as<void>;
101 { obj.setAdjVertexMod(int(), uint()) } -> std::same_as<void>;
102 { obj.setAdjVertices(vec) } -> std::same_as<void>;
103
104 // for references components, the iterators returned by begin() and
105 // end() are input iterators because they do not allow to modify the
106 // content of the container (the only way to do that is by using the set
107 // member functions). However, they allow to modify the elements
108 // pointed by the iterators (const references components allow to
109 // iterate only trough const pointers instead).
110 { obj.adjVertexBegin() } -> InputIterator<decltype(vP)>;
111 { obj.adjVertexEnd() } -> InputIterator<decltype(vP)>;
112
113 { obj.adjVertices() } -> InputRange<decltype(vP)>;
114 };
115};
116
124template<typename T>
128
129} // namespace vcl::comp
130
131#endif // VCL_CONCEPTS_MESH_COMPONENTS_ADJACENT_VERTICES_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
HasAdjacentVertices concept is satisfied only if a Element class provides the types and member functi...
Definition adjacent_vertices.h:52
HasOptionalAdjacentVertices concept is satisfied only if a class satisfies the vcl::comp::HasAdjacent...
Definition adjacent_vertices.h:125
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:72