Visual Computing Library
Loading...
Searching...
No Matches
polygon.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_SPACE_POLYGON_H
24#define VCL_CONCEPTS_SPACE_POLYGON_H
25
26#include "point.h"
27
28#include <vclib/concepts/iterators.h>
29#include <vclib/concepts/ranges/range.h>
30#include <vclib/types.h>
31
32namespace vcl {
33
34template<typename T>
35concept PolygonConcept = requires (
36 T&& obj,
37 typename RemoveRef<T>::PointType p,
38 typename RemoveRef<T>::PointType& pR,
39 typename RemoveRef<T>::ScalarType s,
40 std::vector<typename RemoveRef<T>::PointType> vecP,
41 std::vector<typename RemoveRef<T>::ScalarType> vecS) {
42 // type requirements
43 typename RemoveRef<T>::ScalarType;
44 typename RemoveRef<T>::PointType;
45 typename RemoveRef<T>::Iterator;
46 typename RemoveRef<T>::ConstIterator;
47
48 obj.DIM;
49
50 // constructors
51 RemoveRef<T>();
52 RemoveRef<T>(vecP.begin(), vecP.end());
53 RemoveRef<T>(vecP);
54
55 { obj.size() } -> std::same_as<uint>;
56 { obj.point(uint()) } -> PointConcept;
57 { obj.sideLength(uint()) } -> std::same_as<decltype(s)>;
58 { obj.barycenter() } -> PointConcept;
59 { obj.weightedBarycenter(vecS) } -> PointConcept;
60 { obj.perimeter() } -> std::same_as<decltype(s)>;
61 { obj.area() } -> std::same_as<decltype(s)>;
62 { obj.begin() } -> InputIterator<decltype(p)>;
63 { obj.end() } -> InputIterator<decltype(p)>;
64
65 requires InputRange<T, decltype(p)>;
66
67 // non const requirements
68 requires IsConst<T> || requires {
69 { obj.resize(uint()) } -> std::same_as<void>;
70 { obj.reserve(uint()) } -> std::same_as<void>;
71 { obj.clear() } -> std::same_as<void>;
72 { obj.pushBack(p) } -> std::same_as<void>;
73 { obj.point(uint()) } -> std::same_as<decltype(pR)>;
74 { obj.begin() } -> OutputIterator<decltype(p)>;
75 { obj.end() } -> OutputIterator<decltype(p)>;
76
77 requires OutputRange<T, decltype(p)>;
78 };
79};
80
81template<typename T>
82concept Polygon2Concept = PolygonConcept<T> && RemoveRef<T>::DIM == 2;
83
84template<typename T>
86 PolygonConcept<T> && RemoveRef<T>::DIM == 3 && requires (T&& obj) {
87 { obj.normal() } -> Point3Concept;
88 };
89
90} // namespace vcl
91
92#endif // VCL_CONCEPTS_SPACE_POLYGON_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
The OutputIterator concept is satisfied if T is an output iterator that implements the operator* retu...
Definition iterators.h:60
Utility concept that is evaluated true the Range R is an Output Range and has a value_type that is T.
Definition range.h:113
Concept for points in three-dimensional space.
Definition point.h:130
Concept for types representing points in Euclidean space.
Definition point.h:40
Definition polygon.h:82
Definition polygon.h:85
Definition polygon.h:35