Chris@102: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@102: Chris@102: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@102: Chris@102: // This file was modified by Oracle on 2013, 2014. Chris@102: // Modifications copyright (c) 2013-2014, Oracle and/or its affiliates. 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: // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle Chris@102: Chris@102: #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SUB_RANGE_HPP Chris@102: #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SUB_RANGE_HPP Chris@102: Chris@102: #include Chris@102: Chris@102: namespace boost { namespace geometry { Chris@102: Chris@102: #ifndef DOXYGEN_NO_DETAIL Chris@102: Chris@102: #ifndef DOXYGEN_NO_DISPATCH Chris@102: namespace detail_dispatch { Chris@102: Chris@102: template ::type, Chris@102: bool IsMulti = boost::is_base_of::value> Chris@102: struct sub_range : not_implemented Chris@102: {}; Chris@102: Chris@102: template Chris@102: struct sub_range Chris@102: { Chris@102: typedef Geometry & return_type; Chris@102: Chris@102: template static inline Chris@102: return_type apply(Geometry & geometry, Id const&) Chris@102: { Chris@102: return geometry; Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct sub_range Chris@102: { Chris@102: typedef typename geometry::ring_return_type::type return_type; Chris@102: Chris@102: template static inline Chris@102: return_type apply(Geometry & geometry, Id const& id) Chris@102: { Chris@102: if ( id.ring_index < 0 ) Chris@102: { Chris@102: return geometry::exterior_ring(geometry); Chris@102: } Chris@102: else Chris@102: { Chris@102: typedef typename boost::range_size Chris@102: < Chris@102: typename geometry::interior_type::type Chris@102: >::type size_type; Chris@102: size_type const ri = static_cast(id.ring_index); Chris@102: return range::at(geometry::interior_rings(geometry), ri); Chris@102: } Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct sub_range Chris@102: { Chris@102: typedef typename boost::range_value::type value_type; Chris@102: typedef typename boost::mpl::if_c Chris@102: < Chris@102: boost::is_const::value, Chris@102: typename boost::add_const::type, Chris@102: value_type Chris@102: >::type sub_type; Chris@102: Chris@102: typedef detail_dispatch::sub_range sub_sub_range; Chris@102: Chris@102: // TODO: shouldn't it be return_type? Chris@102: typedef typename sub_sub_range::return_type return_type; Chris@102: Chris@102: template static inline Chris@102: return_type apply(Geometry & geometry, Id const& id) Chris@102: { Chris@102: BOOST_ASSERT(0 <= id.multi_index); Chris@102: typedef typename boost::range_size::type size_type; Chris@102: size_type const mi = static_cast(id.multi_index); Chris@102: return sub_sub_range::apply(range::at(geometry, mi), id); Chris@102: } Chris@102: }; Chris@102: Chris@102: } // namespace detail_dispatch Chris@102: #endif // DOXYGEN_NO_DISPATCH Chris@102: Chris@102: namespace detail { Chris@102: Chris@102: template Chris@102: struct sub_range_return_type Chris@102: { Chris@102: typedef typename detail_dispatch::sub_range::return_type type; Chris@102: }; Chris@102: Chris@102: // This function also works for geometry::segment_identifier Chris@102: Chris@102: template inline Chris@102: typename sub_range_return_type::type Chris@102: sub_range(Geometry & geometry, Id const& id) Chris@102: { Chris@102: return detail_dispatch::sub_range::apply(geometry, id); Chris@102: } Chris@102: Chris@102: } // namespace detail Chris@102: #endif // DOXYGEN_NO_DETAIL Chris@102: Chris@102: }} // namespace boost::geometry Chris@102: Chris@102: #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SUB_RANGE_HPP