diff options
Diffstat (limited to 'boost/geometry/index/detail/bounded_view.hpp')
-rw-r--r-- | boost/geometry/index/detail/bounded_view.hpp | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/boost/geometry/index/detail/bounded_view.hpp b/boost/geometry/index/detail/bounded_view.hpp index 0cd882fc94..e5f489d76b 100644 --- a/boost/geometry/index/detail/bounded_view.hpp +++ b/boost/geometry/index/detail/bounded_view.hpp @@ -3,7 +3,7 @@ // This view makes possible to treat some simple primitives as its bounding geometry // e.g. box, nsphere, etc. // -// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. // // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -12,6 +12,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_BOUNDED_VIEW_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_BOUNDED_VIEW_HPP +#include <boost/geometry/algorithms/envelope.hpp> + namespace boost { namespace geometry { namespace index { namespace detail { @@ -19,7 +21,8 @@ namespace index { namespace detail { template <typename Geometry, typename BoundingGeometry, typename Tag = typename geometry::tag<Geometry>::type, - typename BoundingTag = typename geometry::tag<BoundingGeometry>::type> + typename BoundingTag = typename geometry::tag<BoundingGeometry>::type, + typename CSystem = typename geometry::coordinate_system<Geometry>::type> struct bounded_view { BOOST_MPL_ASSERT_MSG( @@ -32,7 +35,7 @@ struct bounded_view // Segment -> Box template <typename Segment, typename Box> -struct bounded_view<Segment, Box, segment_tag, box_tag> +struct bounded_view<Segment, Box, segment_tag, box_tag, cs::cartesian> { public: typedef typename geometry::coordinate_type<Box>::type coordinate_type; @@ -61,10 +64,37 @@ private: Segment const& m_segment; }; +template <typename Segment, typename Box, typename CSystem> +struct bounded_view<Segment, Box, segment_tag, box_tag, CSystem> +{ +public: + typedef typename geometry::coordinate_type<Box>::type coordinate_type; + + explicit bounded_view(Segment const& segment) + { + geometry::envelope(segment, m_box); + } + + template <std::size_t Dimension> + inline coordinate_type get_min() const + { + return geometry::get<min_corner, Dimension>(m_box); + } + + template <std::size_t Dimension> + inline coordinate_type get_max() const + { + return geometry::get<max_corner, Dimension>(m_box); + } + +private: + Box m_box; +}; + // Box -> Box -template <typename BoxIn, typename Box> -struct bounded_view<BoxIn, Box, box_tag, box_tag> +template <typename BoxIn, typename Box, typename CSystem> +struct bounded_view<BoxIn, Box, box_tag, box_tag, CSystem> { public: typedef typename geometry::coordinate_type<Box>::type coordinate_type; @@ -93,8 +123,8 @@ private: // Point -> Box -template <typename Point, typename Box> -struct bounded_view<Point, Box, point_tag, box_tag> +template <typename Point, typename Box, typename CSystem> +struct bounded_view<Point, Box, point_tag, box_tag, CSystem> { public: typedef typename geometry::coordinate_type<Box>::type coordinate_type; @@ -129,23 +159,23 @@ private: namespace traits { -template <typename Geometry, typename Box, typename Tag> -struct tag< index::detail::bounded_view<Geometry, Box, Tag, box_tag> > +template <typename Geometry, typename Box, typename Tag, typename CSystem> +struct tag< index::detail::bounded_view<Geometry, Box, Tag, box_tag, CSystem> > { typedef box_tag type; }; -template <typename Segment, typename Box, typename Tag> -struct point_type< index::detail::bounded_view<Segment, Box, Tag, box_tag> > +template <typename Geometry, typename Box, typename Tag, typename CSystem> +struct point_type< index::detail::bounded_view<Geometry, Box, Tag, box_tag, CSystem> > { typedef typename point_type<Box>::type type; }; -template <typename Segment, typename Box, typename Tag, std::size_t Dimension> -struct indexed_access<index::detail::bounded_view<Segment, Box, Tag, box_tag>, +template <typename Geometry, typename Box, typename Tag, typename CSystem, std::size_t Dimension> +struct indexed_access<index::detail::bounded_view<Geometry, Box, Tag, box_tag, CSystem>, min_corner, Dimension> { - typedef index::detail::bounded_view<Segment, Box, Tag, box_tag> box_type; + typedef index::detail::bounded_view<Geometry, Box, Tag, box_tag, CSystem> box_type; typedef typename geometry::coordinate_type<Box>::type coordinate_type; static inline coordinate_type get(box_type const& b) @@ -159,11 +189,11 @@ struct indexed_access<index::detail::bounded_view<Segment, Box, Tag, box_tag>, //} }; -template <typename Segment, typename Box, typename Tag, std::size_t Dimension> -struct indexed_access<index::detail::bounded_view<Segment, Box, Tag, box_tag>, +template <typename Geometry, typename Box, typename Tag, typename CSystem, std::size_t Dimension> +struct indexed_access<index::detail::bounded_view<Geometry, Box, Tag, box_tag, CSystem>, max_corner, Dimension> { - typedef index::detail::bounded_view<Segment, Box, Tag, box_tag> box_type; + typedef index::detail::bounded_view<Geometry, Box, Tag, box_tag, CSystem> box_type; typedef typename geometry::coordinate_type<Box>::type coordinate_type; static inline coordinate_type get(box_type const& b) |