Chris@102: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@102: Chris@102: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@102: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@102: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@102: Chris@102: // This file was modified by Oracle on 2014. Chris@102: // Modifications copyright (c) 2014 Oracle and/or its affiliates. Chris@102: Chris@102: // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle Chris@102: Chris@102: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@102: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@102: Chris@102: // Use, modification and distribution is subject to the Boost Software License, Chris@102: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: Chris@102: Chris@102: #ifndef BOOST_GEOMETRY_CORE_RADIUS_HPP Chris@102: #define BOOST_GEOMETRY_CORE_RADIUS_HPP Chris@102: Chris@102: Chris@102: #include Chris@102: Chris@102: #include Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: Chris@102: namespace boost { namespace geometry Chris@102: { Chris@102: Chris@102: namespace traits Chris@102: { Chris@102: Chris@102: /*! Chris@102: \brief Traits class to get/set radius of a circle/sphere/(ellipse) Chris@102: \details the radius access meta-functions give read/write access to the radius of a circle or a sphere, Chris@102: or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid. Chris@102: Chris@102: It should be specialized per geometry, in namespace core_dispatch. Those specializations should Chris@102: forward the call via traits to the geometry class, which could be specified by the user. Chris@102: Chris@102: There is a corresponding generic radius_get and radius_set function Chris@102: \par Geometries: Chris@102: - n-sphere (circle,sphere) Chris@102: - upcoming ellipse Chris@102: \par Specializations should provide: Chris@102: - inline static T get(Geometry const& geometry) Chris@102: - inline static void set(Geometry& geometry, T const& radius) Chris@102: \ingroup traits Chris@102: */ Chris@102: template Chris@102: struct radius_access {}; Chris@102: Chris@102: Chris@102: /*! Chris@102: \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere Chris@102: \par Geometries: Chris@102: - n-sphere (circle,sphere) Chris@102: - upcoming ellipse Chris@102: \par Specializations should provide: Chris@102: - typedef T type (double,float,int,etc) Chris@102: \ingroup traits Chris@102: */ Chris@102: template Chris@102: struct radius_type {}; Chris@102: Chris@102: } // namespace traits Chris@102: Chris@102: Chris@102: #ifndef DOXYGEN_NO_DISPATCH Chris@102: namespace core_dispatch Chris@102: { Chris@102: Chris@102: template Chris@102: struct radius_type Chris@102: { Chris@102: //typedef core_dispatch_specialization_required type; Chris@102: }; Chris@102: Chris@102: /*! Chris@102: \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse. Chris@102: */ Chris@102: template Chris@102: struct radius_access Chris@102: { Chris@102: //static inline CoordinateType get(Geometry const& ) {} Chris@102: //static inline void set(Geometry& g, CoordinateType const& value) {} Chris@102: }; Chris@102: Chris@102: } // namespace core_dispatch Chris@102: #endif // DOXYGEN_NO_DISPATCH Chris@102: Chris@102: Chris@102: /*! Chris@102: \brief Metafunction to get the type of radius of a circle / sphere / ellipse / etc. Chris@102: \ingroup access Chris@102: \tparam Geometry the type of geometry Chris@102: */ Chris@102: template Chris@102: struct radius_type Chris@102: { Chris@102: typedef typename core_dispatch::radius_type Chris@102: < Chris@102: typename tag::type, Chris@102: typename util::bare_type::type Chris@102: >::type type; Chris@102: }; Chris@102: Chris@102: /*! Chris@102: \brief Function to get radius of a circle / sphere / ellipse / etc. Chris@102: \return radius The radius for a given axis Chris@102: \ingroup access Chris@102: \param geometry the geometry to get the radius from Chris@102: \tparam I index of the axis Chris@102: */ Chris@102: template Chris@102: inline typename radius_type::type get_radius(Geometry const& geometry) Chris@102: { Chris@102: return core_dispatch::radius_access Chris@102: < Chris@102: typename tag::type, Chris@102: typename util::bare_type::type, Chris@102: I, Chris@102: typename boost::is_pointer::type Chris@102: >::get(geometry); Chris@102: } Chris@102: Chris@102: /*! Chris@102: \brief Function to set the radius of a circle / sphere / ellipse / etc. Chris@102: \ingroup access Chris@102: \tparam I index of the axis Chris@102: \param geometry the geometry to change Chris@102: \param radius the radius to set Chris@102: */ Chris@102: template Chris@102: inline void set_radius(Geometry& geometry, Chris@102: typename radius_type::type const& radius) Chris@102: { Chris@102: core_dispatch::radius_access Chris@102: < Chris@102: typename tag::type, Chris@102: typename util::bare_type::type, Chris@102: I, Chris@102: typename boost::is_pointer::type Chris@102: >::set(geometry, radius); Chris@102: } Chris@102: Chris@102: Chris@102: Chris@102: #ifndef DOXYGEN_NO_DETAIL Chris@102: namespace detail Chris@102: { Chris@102: Chris@102: template Chris@102: struct radius_access Chris@102: { Chris@102: static inline typename radius_type::type get(Geometry const& geometry) Chris@102: { Chris@102: return traits::radius_access::get(geometry); Chris@102: } Chris@102: static inline void set(Geometry& geometry, Chris@102: typename radius_type::type const& value) Chris@102: { Chris@102: traits::radius_access::set(geometry, value); Chris@102: } Chris@102: }; Chris@102: Chris@102: } // namespace detail Chris@102: #endif // DOXYGEN_NO_DETAIL Chris@102: Chris@102: Chris@102: #ifndef DOXYGEN_NO_DISPATCH Chris@102: namespace core_dispatch Chris@102: { Chris@102: Chris@102: template Chris@102: struct radius_access Chris@102: { Chris@102: typedef typename geometry::radius_type::type radius_type; Chris@102: Chris@102: static inline radius_type get(const Geometry * geometry) Chris@102: { Chris@102: return radius_access Chris@102: < Chris@102: Tag, Chris@102: Geometry, Chris@102: Dimension, Chris@102: typename boost::is_pointer::type Chris@102: >::get(*geometry); Chris@102: } Chris@102: Chris@102: static inline void set(Geometry * geometry, radius_type const& value) Chris@102: { Chris@102: return radius_access Chris@102: < Chris@102: Tag, Chris@102: Geometry, Chris@102: Dimension, Chris@102: typename boost::is_pointer::type Chris@102: >::set(*geometry, value); Chris@102: } Chris@102: }; Chris@102: Chris@102: Chris@102: template Chris@102: struct radius_type Chris@102: { Chris@102: typedef typename traits::radius_type::type type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_access Chris@102: : detail::radius_access Chris@102: { Chris@102: BOOST_STATIC_ASSERT(Dimension == 0); Chris@102: //BOOST_STATIC_ASSERT(Dimension < 3); Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_type Chris@102: { Chris@102: typedef typename traits::radius_type::type type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_access Chris@102: : detail::radius_access Chris@102: { Chris@102: BOOST_STATIC_ASSERT(Dimension == 0 || Dimension == 2); Chris@102: //BOOST_STATIC_ASSERT(Dimension < 3); Chris@102: }; Chris@102: Chris@102: } // namespace core_dispatch Chris@102: #endif // DOXYGEN_NO_DISPATCH Chris@102: Chris@102: Chris@102: }} // namespace boost::geometry Chris@102: Chris@102: Chris@102: #endif // BOOST_GEOMETRY_CORE_RADIUS_HPP