Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2013-2020.
0006 // Modifications copyright (c) 2013-2020, Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0008 
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
0014 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
0015 
0016 #include <type_traits>
0017 
0018 #include <boost/geometry/core/assert.hpp>
0019 #include <boost/geometry/core/tag.hpp>
0020 #include <boost/geometry/util/range.hpp>
0021 
0022 namespace boost { namespace geometry {
0023 
0024 #ifndef DOXYGEN_NO_DISPATCH
0025 namespace detail_dispatch {
0026 
0027 // Returns single geometry by Id
0028 // for single geometries returns the geometry itself
0029 template
0030 <
0031     typename Geometry,
0032     bool IsMulti = std::is_base_of
0033                     <
0034                         multi_tag,
0035                         typename geometry::tag<Geometry>::type
0036                     >::value
0037 >
0038 struct single_geometry
0039 {
0040     typedef Geometry & return_type;
0041 
0042     template <typename Id>
0043     static inline return_type apply(Geometry & g, Id const& ) { return g; }
0044 };
0045 
0046 // for multi geometries returns one of the stored single geometries
0047 template <typename Geometry>
0048 struct single_geometry<Geometry, true>
0049 {
0050     typedef typename boost::range_reference<Geometry>::type return_type;
0051 
0052     template <typename Id>
0053     static inline return_type apply(Geometry & g, Id const& id)
0054     {
0055         BOOST_GEOMETRY_ASSERT(id.multi_index >= 0);
0056         typedef typename boost::range_size<Geometry>::type size_type;
0057         return range::at(g, static_cast<size_type>(id.multi_index));
0058     }
0059 };
0060 
0061 } // namespace detail_dispatch
0062 #endif // DOXYGEN_NO_DISPATCH
0063 
0064 #ifndef DOXYGEN_NO_DETAIL
0065 namespace detail {
0066 
0067 template <typename Geometry>
0068 struct single_geometry_return_type
0069 {
0070     typedef typename detail_dispatch::single_geometry<Geometry>::return_type type;
0071 };
0072 
0073 template <typename Geometry, typename Id>
0074 inline
0075 typename single_geometry_return_type<Geometry>::type
0076 single_geometry(Geometry & geometry, Id const& id)
0077 {
0078     return detail_dispatch::single_geometry<Geometry>::apply(geometry, id);
0079 }
0080 
0081 template <typename Geometry, typename Id>
0082 inline
0083 typename single_geometry_return_type<Geometry const>::type
0084 single_geometry(Geometry const& geometry, Id const& id)
0085 {
0086     return detail_dispatch::single_geometry<Geometry const>::apply(geometry, id);
0087 }
0088 
0089 } // namespace detail
0090 #endif // DOXYGEN_NO_DETAIL
0091 
0092 }} // namespace boost::geometry
0093 
0094 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP