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_SINGLE_GEOMETRY_HPP Chris@102: #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { namespace geometry { Chris@102: Chris@102: #ifndef DOXYGEN_NO_DISPATCH Chris@102: namespace detail_dispatch { Chris@102: Chris@102: // Returns single geometry by Id Chris@102: // for single geometries returns the geometry itself Chris@102: template ::type Chris@102: >::value Chris@102: > Chris@102: struct single_geometry Chris@102: { Chris@102: typedef Geometry & return_type; Chris@102: Chris@102: template Chris@102: static inline return_type apply(Geometry & g, Id const& ) { return g; } Chris@102: }; Chris@102: Chris@102: // for multi geometries returns one of the stored single geometries Chris@102: template Chris@102: struct single_geometry Chris@102: { Chris@102: typedef typename boost::mpl::if_c Chris@102: < Chris@102: boost::is_const::value, Chris@102: typename boost::range_value::type const&, Chris@102: typename boost::range_value::type Chris@102: >::type return_type; Chris@102: Chris@102: template Chris@102: static inline return_type apply(Geometry & g, Id const& id) Chris@102: { Chris@102: BOOST_ASSERT(id.multi_index >= 0); Chris@102: typedef typename boost::range_size::type size_type; Chris@102: return range::at(g, static_cast(id.multi_index)); Chris@102: } Chris@102: }; Chris@102: Chris@102: } // namespace detail_dispatch Chris@102: #endif // DOXYGEN_NO_DISPATCH Chris@102: Chris@102: #ifndef DOXYGEN_NO_DETAIL Chris@102: namespace detail { Chris@102: Chris@102: template Chris@102: struct single_geometry_return_type Chris@102: { Chris@102: typedef typename detail_dispatch::single_geometry::return_type type; Chris@102: }; Chris@102: Chris@102: template Chris@102: inline Chris@102: typename single_geometry_return_type::type Chris@102: single_geometry(Geometry & geometry, Id const& id) Chris@102: { Chris@102: return detail_dispatch::single_geometry::apply(geometry, id); Chris@102: } Chris@102: Chris@102: template Chris@102: inline Chris@102: typename single_geometry_return_type::type Chris@102: single_geometry(Geometry const& geometry, Id const& id) Chris@102: { Chris@102: return detail_dispatch::single_geometry::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_SINGLE_GEOMETRY_HPP