Visual Computing Library
Loading...
Searching...
No Matches
bit_flags.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_BIT_FLAGS_H
24#define VCL_CONCEPTS_MESH_COMPONENTS_BIT_FLAGS_H
25
26#include <vclib/concepts/const_correctness.h>
27#include <vclib/concepts/space/bit_set.h>
28#include <vclib/types/base.h>
29
30#include <concepts>
31
32namespace vcl::comp {
33
41template<typename T>
42concept HasBitFlags = requires (T&& obj) {
43 { obj.deleted() } -> std::same_as<bool>;
44 { obj.selected() } -> std::convertible_to<bool>;
45 { obj.onBorder() } -> std::convertible_to<bool>;
46 { obj.selected() } -> std::convertible_to<bool>;
47 { obj.userBit(uint()) } -> std::convertible_to<bool>;
48
49 { obj.exportFlagsToVCGFormat() } -> std::same_as<int>;
50
51 // non const requirements
52 requires IsConst<T> || requires {
53 { obj.selected() } -> BitProxyConcept;
54 { obj.onBorder() } -> BitProxyConcept;
55 { obj.selected() } -> BitProxyConcept;
56 { obj.userBit(uint()) } -> BitProxyConcept;
57 { obj.resetBitFlags() } -> std::same_as<void>;
58 { obj.importFlagsFromVCGFormat(int()) } -> std::same_as<void>;
59 };
60};
61
62namespace detail {
63
69template<typename T>
70concept FaceBitFlagsConcept = HasBitFlags<T> && requires (T&& obj) {
71 { obj.edgeOnBorder(uint()) } -> std::convertible_to<bool>;
72 { obj.edgeSelected(uint()) } -> std::convertible_to<bool>;
73 { obj.edgeVisited(uint()) } -> std::convertible_to<bool>;
74 { obj.edgeFaux(uint()) } -> std::convertible_to<bool>;
75
76 // non const requirements
77 requires IsConst<T> || requires {
78 { obj.edgeOnBorder(uint()) } -> BitProxyConcept;
79 { obj.edgeSelected(uint()) } -> BitProxyConcept;
80 { obj.edgeVisited(uint()) } -> BitProxyConcept;
81 { obj.edgeFaux(uint()) } -> BitProxyConcept;
82 };
83};
84
85} // namespace detail
86
95template<typename T>
97 detail::FaceBitFlagsConcept<T> && requires (T&& obj) {
98 { obj.__polygonBitFlags() } -> std::same_as<void>;
99 };
100
109template<typename T>
111 detail::FaceBitFlagsConcept<T> && requires (T&& obj) {
112 { obj.__triangleBitFlags() } -> std::same_as<void>;
113 };
114
123template<typename T>
125
126} // namespace vcl::comp
127
128#endif // VCL_CONCEPTS_MESH_COMPONENTS_BIT_FLAGS_H
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
BitProxyConcept is satisfied only if a class provides the member functions specified in this concept....
Definition bit_set.h:40
The IsConst concept is satisfied if T satisfies one of the following conditions:
Definition const_correctness.h:43
HasBitFlags concept is satisfied only if a Element class provides the member functions specified in t...
Definition bit_flags.h:42
HasFaceBitFlags concept is satisfied if one between vcl::comp::HasPolygonBitFlags and vcl::comp::HasT...
Definition bit_flags.h:124
HasPolygonBitFlags concept is satisfied only if a Element class (that should be a Face) provides the ...
Definition bit_flags.h:96
HasTriangleBitFlags concept is satisfied only if a Element class (that should be a Face) provides the...
Definition bit_flags.h:110