]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/geometries/concepts/point_concept.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / geometries / concepts / point_concept.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2//
3// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
4// Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands.
5// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
6
20effc67
TL
7// This file was modified by Oracle on 2014-2020.
8// Modifications copyright (c) 2014-2020, Oracle and/or its affiliates.
7c673cae
FG
9
10// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
20effc67 11// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7c673cae
FG
12
13// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15
16// Use, modification and distribution is subject to the Boost Software License,
17// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18// http://www.boost.org/LICENSE_1_0.txt)
19
20#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
21#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
22
23#include <cstddef>
24
25#include <boost/concept_check.hpp>
26#include <boost/core/ignore_unused.hpp>
27
28#include <boost/geometry/core/access.hpp>
29#include <boost/geometry/core/coordinate_dimension.hpp>
30#include <boost/geometry/core/coordinate_system.hpp>
31
32
33
34namespace boost { namespace geometry { namespace concepts
35{
36
37/*!
38\brief Point concept.
39\ingroup concepts
40
41\par Formal definition:
42The point concept is defined as following:
43- there must be a specialization of traits::tag defining point_tag as type
44- there must be a specialization of traits::coordinate_type defining the type
45 of its coordinates
46- there must be a specialization of traits::coordinate_system defining its
47 coordinate system (cartesian, spherical, etc)
48- there must be a specialization of traits::dimension defining its number
49 of dimensions (2, 3, ...) (derive it conveniently
20effc67 50 from std::integral_constant&lt;std::size_t, X&gt; for X-D)
7c673cae
FG
51- there must be a specialization of traits::access, per dimension,
52 with two functions:
53 - \b get to get a coordinate value
54 - \b set to set a coordinate value (this one is not checked for ConstPoint)
55- for non-Cartesian coordinate systems, the coordinate system's units
56 must either be boost::geometry::degree or boost::geometry::radian
57
58
59\par Example:
60
61A legacy point, defining the necessary specializations to fulfil to the concept.
62
63Suppose that the following point is defined:
64\dontinclude doxygen_5.cpp
65\skip legacy_point1
66\until };
67
68It can then be adapted to the concept as following:
69\dontinclude doxygen_5.cpp
70\skip adapt legacy_point1
71\until }}
72
73Note that it is done like above to show the system. Users will normally use the registration macro.
74
75\par Example:
76
77A read-only legacy point, using a macro to fulfil to the ConstPoint concept.
78It cannot be modified by the library but can be used in all algorithms where
79points are not modified.
80
81The point looks like the following:
82
83\dontinclude doxygen_5.cpp
84\skip legacy_point2
85\until };
86
87It uses the macro as following:
88\dontinclude doxygen_5.cpp
89\skip adapt legacy_point2
90\until end adaptation
91
92*/
93
94template <typename Geometry>
95class Point
96{
97#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
98
99 typedef typename coordinate_type<Geometry>::type ctype;
100 typedef typename coordinate_system<Geometry>::type csystem;
101
102 // The following enum is used to fully instantiate the coordinate
103 // system class; this is needed in order to check the units passed
104 // to it for non-Cartesian coordinate systems.
105 enum { cs_check = sizeof(csystem) };
106
107 enum { ccount = dimension<Geometry>::value };
108
109 template <typename P, std::size_t Dimension, std::size_t DimensionCount>
110 struct dimension_checker
111 {
112 static void apply()
113 {
114 P* p = 0;
115 geometry::set<Dimension>(*p, geometry::get<Dimension>(*p));
116 dimension_checker<P, Dimension+1, DimensionCount>::apply();
117 }
118 };
119
120
121 template <typename P, std::size_t DimensionCount>
122 struct dimension_checker<P, DimensionCount, DimensionCount>
123 {
124 static void apply() {}
125 };
126
127public:
128
129 /// BCCL macro to apply the Point concept
130 BOOST_CONCEPT_USAGE(Point)
131 {
132 dimension_checker<Geometry, 0, ccount>::apply();
133 }
134#endif
135};
136
137
138/*!
139\brief point concept (const version).
140
141\ingroup const_concepts
142
143\details The ConstPoint concept apply the same as the Point concept,
144but does not apply write access.
145
146*/
147template <typename Geometry>
148class ConstPoint
149{
150#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
151
152 typedef typename coordinate_type<Geometry>::type ctype;
153 typedef typename coordinate_system<Geometry>::type csystem;
154
155 // The following enum is used to fully instantiate the coordinate
156 // system class; this is needed in order to check the units passed
157 // to it for non-Cartesian coordinate systems.
158 enum { cs_check = sizeof(csystem) };
159
160 enum { ccount = dimension<Geometry>::value };
161
162 template <typename P, std::size_t Dimension, std::size_t DimensionCount>
163 struct dimension_checker
164 {
165 static void apply()
166 {
167 const P* p = 0;
168 ctype coord(geometry::get<Dimension>(*p));
169 boost::ignore_unused(p, coord);
170 dimension_checker<P, Dimension+1, DimensionCount>::apply();
171 }
172 };
173
174
175 template <typename P, std::size_t DimensionCount>
176 struct dimension_checker<P, DimensionCount, DimensionCount>
177 {
178 static void apply() {}
179 };
180
181public:
182
183 /// BCCL macro to apply the ConstPoint concept
184 BOOST_CONCEPT_USAGE(ConstPoint)
185 {
186 dimension_checker<Geometry, 0, ccount>::apply();
187 }
188#endif
189};
190
191}}} // namespace boost::geometry::concepts
192
193#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP