Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:23

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2014-2020.
0008 // Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
0009 
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
0018 
0019 
0020 #ifndef BOOST_GEOMETRY_CORE_RADIUS_HPP
0021 #define BOOST_GEOMETRY_CORE_RADIUS_HPP
0022 
0023 
0024 #include <cstddef>
0025 
0026 #include <boost/static_assert.hpp>
0027 
0028 #include <boost/geometry/core/tag.hpp>
0029 #include <boost/geometry/core/tags.hpp>
0030 #include <boost/geometry/util/type_traits_std.hpp>
0031 
0032 
0033 namespace boost { namespace geometry
0034 {
0035 
0036 namespace traits
0037 {
0038 
0039 /*!
0040     \brief Traits class to get/set radius of a circle/sphere/(ellipse)
0041     \details the radius access meta-functions give read/write access to the radius of a circle or a sphere,
0042     or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid.
0043 
0044     It should be specialized per geometry, in namespace core_dispatch. Those specializations should
0045     forward the call via traits to the geometry class, which could be specified by the user.
0046 
0047     There is a corresponding generic radius_get and radius_set function
0048     \par Geometries:
0049         - n-sphere (circle,sphere)
0050         - upcoming ellipse
0051     \par Specializations should provide:
0052         - inline static T get(Geometry const& geometry)
0053         - inline static void set(Geometry& geometry, T const& radius)
0054     \ingroup traits
0055 */
0056 template <typename Geometry, std::size_t Dimension>
0057 struct radius_access {};
0058 
0059 
0060 /*!
0061     \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere
0062     \par Geometries:
0063         - n-sphere (circle,sphere)
0064         - upcoming ellipse
0065     \par Specializations should provide:
0066         - typedef T type (double,float,int,etc)
0067     \ingroup traits
0068 */
0069 template <typename Geometry>
0070 struct radius_type {};
0071 
0072 } // namespace traits
0073 
0074 
0075 #ifndef DOXYGEN_NO_DISPATCH
0076 namespace core_dispatch
0077 {
0078 
0079 template <typename Tag, typename Geometry>
0080 struct radius_type
0081 {
0082     //typedef core_dispatch_specialization_required type;
0083 };
0084 
0085 /*!
0086     \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse.
0087 */
0088 template <typename Tag,
0089           typename Geometry,
0090           std::size_t Dimension,
0091           typename IsPointer>
0092 struct radius_access
0093 {
0094     //static inline CoordinateType get(Geometry const& ) {}
0095     //static inline void set(Geometry& g, CoordinateType const& value) {}
0096 };
0097 
0098 } // namespace core_dispatch
0099 #endif // DOXYGEN_NO_DISPATCH
0100 
0101 
0102 /*!
0103     \brief Metafunction to get the type of radius of a circle / sphere / ellipse / etc.
0104     \ingroup access
0105     \tparam Geometry the type of geometry
0106 */
0107 template <typename Geometry>
0108 struct radius_type
0109 {
0110     typedef typename core_dispatch::radius_type
0111                         <
0112                             typename tag<Geometry>::type,
0113                             typename util::remove_cptrref<Geometry>::type
0114                         >::type type;
0115 };
0116 
0117 /*!
0118     \brief Function to get radius of a circle / sphere / ellipse / etc.
0119     \return radius The radius for a given axis
0120     \ingroup access
0121     \param geometry the geometry to get the radius from
0122     \tparam I index of the axis
0123 */
0124 template <std::size_t I, typename Geometry>
0125 inline typename radius_type<Geometry>::type get_radius(Geometry const& geometry)
0126 {
0127     return core_dispatch::radius_access
0128             <
0129                 typename tag<Geometry>::type,
0130                 typename util::remove_cptrref<Geometry>::type,
0131                 I,
0132                 typename std::is_pointer<Geometry>::type
0133             >::get(geometry);
0134 }
0135 
0136 /*!
0137     \brief Function to set the radius of a circle / sphere / ellipse / etc.
0138     \ingroup access
0139     \tparam I index of the axis
0140     \param geometry the geometry to change
0141     \param radius the radius to set
0142 */
0143 template <std::size_t I, typename Geometry>
0144 inline void set_radius(Geometry& geometry,
0145                        typename radius_type<Geometry>::type const& radius)
0146 {
0147     core_dispatch::radius_access
0148         <
0149             typename tag<Geometry>::type,
0150             typename util::remove_cptrref<Geometry>::type,
0151             I,
0152             typename std::is_pointer<Geometry>::type
0153         >::set(geometry, radius);
0154 }
0155 
0156 
0157 
0158 #ifndef DOXYGEN_NO_DETAIL
0159 namespace detail
0160 {
0161 
0162 template <typename Tag, typename Geometry, std::size_t Dimension>
0163 struct radius_access
0164 {
0165     static inline typename radius_type<Geometry>::type get(Geometry const& geometry)
0166     {
0167         return traits::radius_access<Geometry, Dimension>::get(geometry);
0168     }
0169     static inline void set(Geometry& geometry,
0170                            typename radius_type<Geometry>::type const& value)
0171     {
0172         traits::radius_access<Geometry, Dimension>::set(geometry, value);
0173     }
0174 };
0175 
0176 } // namespace detail
0177 #endif // DOXYGEN_NO_DETAIL
0178 
0179 
0180 #ifndef DOXYGEN_NO_DISPATCH
0181 namespace core_dispatch
0182 {
0183 
0184 template <typename Tag,
0185           typename Geometry,
0186           std::size_t Dimension>
0187 struct radius_access<Tag, Geometry, Dimension, std::true_type>
0188 {
0189     typedef typename geometry::radius_type<Geometry>::type radius_type;
0190 
0191     static inline radius_type get(const Geometry * geometry)
0192     {
0193         return radius_access
0194                 <
0195                     Tag,
0196                     Geometry,
0197                     Dimension,
0198                     typename std::is_pointer<Geometry>::type
0199                 >::get(*geometry);
0200     }
0201 
0202     static inline void set(Geometry * geometry, radius_type const& value)
0203     {
0204         return radius_access
0205                 <
0206                     Tag,
0207                     Geometry,
0208                     Dimension,
0209                     typename std::is_pointer<Geometry>::type
0210                 >::set(*geometry, value);
0211     }
0212 };
0213 
0214 
0215 template <typename Geometry>
0216 struct radius_type<srs_sphere_tag, Geometry>
0217 {
0218     typedef typename traits::radius_type<Geometry>::type type;
0219 };
0220 
0221 template <typename Geometry, std::size_t Dimension>
0222 struct radius_access<srs_sphere_tag, Geometry, Dimension, std::false_type>
0223     : detail::radius_access<srs_sphere_tag, Geometry, Dimension>
0224 {
0225     //BOOST_STATIC_ASSERT(Dimension == 0);
0226     BOOST_STATIC_ASSERT(Dimension < 3);
0227 };
0228 
0229 template <typename Geometry>
0230 struct radius_type<srs_spheroid_tag, Geometry>
0231 {
0232     typedef typename traits::radius_type<Geometry>::type type;
0233 };
0234 
0235 template <typename Geometry, std::size_t Dimension>
0236 struct radius_access<srs_spheroid_tag, Geometry, Dimension, std::false_type>
0237     : detail::radius_access<srs_spheroid_tag, Geometry, Dimension>
0238 {
0239     //BOOST_STATIC_ASSERT(Dimension == 0 || Dimension == 2);
0240     BOOST_STATIC_ASSERT(Dimension < 3);
0241 };
0242 
0243 } // namespace core_dispatch
0244 #endif // DOXYGEN_NO_DISPATCH
0245 
0246 
0247 }} // namespace boost::geometry
0248 
0249 
0250 #endif // BOOST_GEOMETRY_CORE_RADIUS_HPP