]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
4 | // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | ||
1e59de90 TL |
7 | // This file was modified by Oracle on 2021. |
8 | // Modifications copyright (c) 2021 Oracle and/or its affiliates. | |
9 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
10 | ||
7c673cae FG |
11 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
12 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
13 | ||
14 | // Use, modification and distribution is subject to the Boost Software License, | |
15 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
16 | // http://www.boost.org/LICENSE_1_0.txt) | |
17 | ||
18 | #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP | |
19 | #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP | |
20 | ||
1e59de90 | 21 | |
7c673cae | 22 | #include <boost/concept_check.hpp> |
92f5a8d4 | 23 | #include <boost/core/ignore_unused.hpp> |
7c673cae | 24 | |
7c673cae FG |
25 | #include <boost/geometry/core/access.hpp> |
26 | #include <boost/geometry/core/point_type.hpp> | |
27 | ||
1e59de90 TL |
28 | #include <boost/geometry/geometries/concepts/concept_type.hpp> |
29 | #include <boost/geometry/geometries/concepts/point_concept.hpp> | |
30 | ||
7c673cae FG |
31 | |
32 | namespace boost { namespace geometry { namespace concepts | |
33 | { | |
34 | ||
35 | ||
36 | /*! | |
37 | \brief Segment concept. | |
38 | \ingroup concepts | |
39 | \details Formal definition: | |
40 | The segment concept is defined as following: | |
41 | - there must be a specialization of traits::tag defining segment_tag as type | |
42 | - there must be a specialization of traits::point_type to define the | |
43 | underlying point type (even if it does not consist of points, it should define | |
44 | this type, to indicate the points it can work with) | |
45 | - there must be a specialization of traits::indexed_access, per index | |
46 | and per dimension, with two functions: | |
47 | - get to get a coordinate value | |
48 | - set to set a coordinate value (this one is not checked for ConstSegment) | |
49 | ||
50 | \note The segment concept is similar to the box concept, defining another tag. | |
51 | However, the box concept assumes the index as min_corner, max_corner, while | |
52 | for the segment concept there is no assumption. | |
53 | */ | |
54 | template <typename Geometry> | |
55 | class Segment | |
56 | { | |
57 | #ifndef DOXYGEN_NO_CONCEPT_MEMBERS | |
58 | typedef typename point_type<Geometry>::type point_type; | |
59 | ||
60 | BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) ); | |
61 | ||
62 | ||
63 | template <size_t Index, size_t Dimension, size_t DimensionCount> | |
64 | struct dimension_checker | |
65 | { | |
66 | static void apply() | |
67 | { | |
68 | Geometry* s = 0; | |
69 | geometry::set<Index, Dimension>(*s, geometry::get<Index, Dimension>(*s)); | |
70 | dimension_checker<Index, Dimension + 1, DimensionCount>::apply(); | |
71 | } | |
72 | }; | |
73 | ||
74 | template <size_t Index, size_t DimensionCount> | |
75 | struct dimension_checker<Index, DimensionCount, DimensionCount> | |
76 | { | |
77 | static void apply() {} | |
78 | }; | |
79 | ||
80 | public : | |
81 | ||
82 | BOOST_CONCEPT_USAGE(Segment) | |
83 | { | |
84 | static const size_t n = dimension<point_type>::type::value; | |
85 | dimension_checker<0, 0, n>::apply(); | |
86 | dimension_checker<1, 0, n>::apply(); | |
87 | } | |
88 | #endif | |
89 | }; | |
90 | ||
91 | ||
92 | /*! | |
93 | \brief Segment concept (const version). | |
94 | \ingroup const_concepts | |
95 | \details The ConstSegment concept verifies the same as the Segment concept, | |
96 | but does not verify write access. | |
97 | */ | |
98 | template <typename Geometry> | |
99 | class ConstSegment | |
100 | { | |
101 | #ifndef DOXYGEN_NO_CONCEPT_MEMBERS | |
102 | typedef typename point_type<Geometry>::type point_type; | |
103 | typedef typename coordinate_type<Geometry>::type coordinate_type; | |
104 | ||
105 | BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) ); | |
106 | ||
107 | ||
108 | template <size_t Index, size_t Dimension, size_t DimensionCount> | |
109 | struct dimension_checker | |
110 | { | |
111 | static void apply() | |
112 | { | |
113 | const Geometry* s = 0; | |
114 | coordinate_type coord(geometry::get<Index, Dimension>(*s)); | |
92f5a8d4 | 115 | boost::ignore_unused(coord); |
7c673cae FG |
116 | dimension_checker<Index, Dimension + 1, DimensionCount>::apply(); |
117 | } | |
118 | }; | |
119 | ||
120 | template <size_t Index, size_t DimensionCount> | |
121 | struct dimension_checker<Index, DimensionCount, DimensionCount> | |
122 | { | |
123 | static void apply() {} | |
124 | }; | |
125 | ||
126 | public : | |
127 | ||
128 | BOOST_CONCEPT_USAGE(ConstSegment) | |
129 | { | |
130 | static const size_t n = dimension<point_type>::type::value; | |
131 | dimension_checker<0, 0, n>::apply(); | |
132 | dimension_checker<1, 0, n>::apply(); | |
133 | } | |
134 | #endif | |
135 | }; | |
136 | ||
137 | ||
1e59de90 TL |
138 | template <typename Geometry> |
139 | struct concept_type<Geometry, segment_tag> | |
140 | { | |
141 | using type = Segment<Geometry>; | |
142 | }; | |
143 | ||
144 | template <typename Geometry> | |
145 | struct concept_type<Geometry const, segment_tag> | |
146 | { | |
147 | using type = ConstSegment<Geometry>; | |
148 | }; | |
149 | ||
150 | ||
7c673cae FG |
151 | }}} // namespace boost::geometry::concepts |
152 | ||
153 | ||
154 | #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP |