Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP Chris@16: #define BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: #ifndef DOXYGEN_NO_DETAIL Chris@16: namespace detail { namespace envelope Chris@16: { Chris@16: Chris@16: Chris@16: /// Calculate envelope of an 2D or 3D segment Chris@16: struct envelope_expand_one Chris@16: { Chris@16: template Chris@16: static inline void apply(Geometry const& geometry, Box& mbr) Chris@16: { Chris@16: assign_inverse(mbr); Chris@16: geometry::expand(mbr, geometry); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: /// Iterate through range (also used in multi*) Chris@16: template Chris@16: inline void envelope_range_additional(Range const& range, Box& mbr) Chris@16: { Chris@16: typedef typename boost::range_iterator::type iterator_type; Chris@16: Chris@16: for (iterator_type it = boost::begin(range); Chris@16: it != boost::end(range); Chris@16: ++it) Chris@16: { Chris@16: geometry::expand(mbr, *it); Chris@16: } Chris@16: } Chris@16: Chris@16: Chris@16: Chris@16: /// Generic range dispatching struct Chris@16: struct envelope_range Chris@16: { Chris@16: /// Calculate envelope of range using a strategy Chris@16: template Chris@16: static inline void apply(Range const& range, Box& mbr) Chris@16: { Chris@16: assign_inverse(mbr); Chris@16: envelope_range_additional(range, mbr); Chris@16: } Chris@16: }; Chris@16: Chris@16: }} // namespace detail::envelope Chris@16: #endif // DOXYGEN_NO_DETAIL Chris@16: Chris@16: #ifndef DOXYGEN_NO_DISPATCH Chris@16: namespace dispatch Chris@16: { Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename Geometry, Chris@16: typename Tag = typename tag::type Chris@16: > Chris@16: struct envelope: not_implemented Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct envelope Chris@16: : detail::envelope::envelope_expand_one Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct envelope Chris@16: : detail::envelope::envelope_expand_one Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct envelope Chris@16: : detail::envelope::envelope_expand_one Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct envelope Chris@16: : detail::envelope::envelope_range Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct envelope Chris@16: : detail::envelope::envelope_range Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct envelope Chris@16: : detail::envelope::envelope_range Chris@16: { Chris@16: template Chris@16: static inline void apply(Polygon const& poly, Box& mbr) Chris@16: { Chris@16: // For polygon, inspecting outer ring is sufficient Chris@16: detail::envelope::envelope_range::apply(exterior_ring(poly), mbr); Chris@16: } Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace dispatch Chris@16: #endif Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief \brief_calc{envelope} Chris@16: \ingroup envelope Chris@16: \details \details_calc{envelope,\det_envelope}. Chris@16: \tparam Geometry \tparam_geometry Chris@16: \tparam Box \tparam_box Chris@16: \param geometry \param_geometry Chris@16: \param mbr \param_box \param_set{envelope} Chris@16: Chris@16: \qbk{[include reference/algorithms/envelope.qbk]} Chris@16: \qbk{ Chris@16: [heading Example] Chris@16: [envelope] [envelope_output] Chris@16: } Chris@16: */ Chris@16: template Chris@16: inline void envelope(Geometry const& geometry, Box& mbr) Chris@16: { Chris@16: concept::check(); Chris@16: concept::check(); Chris@16: Chris@16: dispatch::envelope::apply(geometry, mbr); Chris@16: } Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief \brief_calc{envelope} Chris@16: \ingroup envelope Chris@16: \details \details_calc{return_envelope,\det_envelope}. \details_return{envelope} Chris@16: \tparam Box \tparam_box Chris@16: \tparam Geometry \tparam_geometry Chris@16: \param geometry \param_geometry Chris@16: \return \return_calc{envelope} Chris@16: Chris@16: \qbk{[include reference/algorithms/envelope.qbk]} Chris@16: \qbk{ Chris@16: [heading Example] Chris@16: [return_envelope] [return_envelope_output] Chris@16: } Chris@16: */ Chris@16: template Chris@16: inline Box return_envelope(Geometry const& geometry) Chris@16: { Chris@16: concept::check(); Chris@16: concept::check(); Chris@16: Chris@16: Box mbr; Chris@16: dispatch::envelope::apply(geometry, mbr); Chris@16: return mbr; Chris@16: } Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: #endif // BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP