annotate DEPENDENCIES/generic/include/boost/geometry/geometries/concepts/point_concept.hpp @ 133:4acb5d8d80b6 tip

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