annotate DEPENDENCIES/generic/include/boost/geometry/index/detail/bounded_view.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry Index
Chris@102 2 //
Chris@102 3 // This view makes possible to treat some simple primitives as its bounding geometry
Chris@102 4 // e.g. box, nsphere, etc.
Chris@102 5 //
Chris@102 6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
Chris@102 7 //
Chris@102 8 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 10 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 11
Chris@102 12 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_BOUNDED_VIEW_HPP
Chris@102 13 #define BOOST_GEOMETRY_INDEX_DETAIL_BOUNDED_VIEW_HPP
Chris@102 14
Chris@102 15 namespace boost { namespace geometry {
Chris@102 16
Chris@102 17 namespace index { namespace detail {
Chris@102 18
Chris@102 19 template <typename Geometry,
Chris@102 20 typename BoundingGeometry,
Chris@102 21 typename Tag = typename geometry::tag<Geometry>::type,
Chris@102 22 typename BoundingTag = typename geometry::tag<BoundingGeometry>::type>
Chris@102 23 struct bounded_view
Chris@102 24 {
Chris@102 25 BOOST_MPL_ASSERT_MSG(
Chris@102 26 (false),
Chris@102 27 NOT_IMPLEMENTED_FOR_THOSE_GEOMETRIES,
Chris@102 28 (BoundingTag, Tag));
Chris@102 29 };
Chris@102 30
Chris@102 31
Chris@102 32 // Segment -> Box
Chris@102 33
Chris@102 34 template <typename Segment, typename Box>
Chris@102 35 struct bounded_view<Segment, Box, segment_tag, box_tag>
Chris@102 36 {
Chris@102 37 public:
Chris@102 38 typedef typename geometry::coordinate_type<Box>::type coordinate_type;
Chris@102 39
Chris@102 40 explicit bounded_view(Segment const& segment)
Chris@102 41 : m_segment(segment)
Chris@102 42 {}
Chris@102 43
Chris@102 44 template <std::size_t Dimension>
Chris@102 45 inline coordinate_type get_min() const
Chris@102 46 {
Chris@102 47 return boost::numeric_cast<coordinate_type>(
Chris@102 48 (std::min)( geometry::get<0, Dimension>(m_segment),
Chris@102 49 geometry::get<1, Dimension>(m_segment) ) );
Chris@102 50 }
Chris@102 51
Chris@102 52 template <std::size_t Dimension>
Chris@102 53 inline coordinate_type get_max() const
Chris@102 54 {
Chris@102 55 return boost::numeric_cast<coordinate_type>(
Chris@102 56 (std::max)( geometry::get<0, Dimension>(m_segment),
Chris@102 57 geometry::get<1, Dimension>(m_segment) ) );
Chris@102 58 }
Chris@102 59
Chris@102 60 private:
Chris@102 61 Segment const& m_segment;
Chris@102 62 };
Chris@102 63
Chris@102 64 // Box -> Box
Chris@102 65
Chris@102 66 template <typename BoxIn, typename Box>
Chris@102 67 struct bounded_view<BoxIn, Box, box_tag, box_tag>
Chris@102 68 {
Chris@102 69 public:
Chris@102 70 typedef typename geometry::coordinate_type<Box>::type coordinate_type;
Chris@102 71
Chris@102 72 explicit bounded_view(BoxIn const& box)
Chris@102 73 : m_box(box)
Chris@102 74 {}
Chris@102 75
Chris@102 76 template <std::size_t Dimension>
Chris@102 77 inline coordinate_type get_min() const
Chris@102 78 {
Chris@102 79 return boost::numeric_cast<coordinate_type>(
Chris@102 80 geometry::get<min_corner, Dimension>(m_box) );
Chris@102 81 }
Chris@102 82
Chris@102 83 template <std::size_t Dimension>
Chris@102 84 inline coordinate_type get_max() const
Chris@102 85 {
Chris@102 86 return boost::numeric_cast<coordinate_type>(
Chris@102 87 geometry::get<max_corner, Dimension>(m_box) );
Chris@102 88 }
Chris@102 89
Chris@102 90 private:
Chris@102 91 BoxIn const& m_box;
Chris@102 92 };
Chris@102 93
Chris@102 94 // Point -> Box
Chris@102 95
Chris@102 96 template <typename Point, typename Box>
Chris@102 97 struct bounded_view<Point, Box, point_tag, box_tag>
Chris@102 98 {
Chris@102 99 public:
Chris@102 100 typedef typename geometry::coordinate_type<Box>::type coordinate_type;
Chris@102 101
Chris@102 102 explicit bounded_view(Point const& point)
Chris@102 103 : m_point(point)
Chris@102 104 {}
Chris@102 105
Chris@102 106 template <std::size_t Dimension>
Chris@102 107 inline coordinate_type get_min() const
Chris@102 108 {
Chris@102 109 return boost::numeric_cast<coordinate_type>(
Chris@102 110 geometry::get<Dimension>(m_point) );
Chris@102 111 }
Chris@102 112
Chris@102 113 template <std::size_t Dimension>
Chris@102 114 inline coordinate_type get_max() const
Chris@102 115 {
Chris@102 116 return boost::numeric_cast<coordinate_type>(
Chris@102 117 geometry::get<Dimension>(m_point) );
Chris@102 118 }
Chris@102 119
Chris@102 120 private:
Chris@102 121 Point const& m_point;
Chris@102 122 };
Chris@102 123
Chris@102 124 }} // namespace index::detail
Chris@102 125
Chris@102 126 // XXX -> Box
Chris@102 127
Chris@102 128 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 129 namespace traits
Chris@102 130 {
Chris@102 131
Chris@102 132 template <typename Geometry, typename Box, typename Tag>
Chris@102 133 struct tag< index::detail::bounded_view<Geometry, Box, Tag, box_tag> >
Chris@102 134 {
Chris@102 135 typedef box_tag type;
Chris@102 136 };
Chris@102 137
Chris@102 138 template <typename Segment, typename Box, typename Tag>
Chris@102 139 struct point_type< index::detail::bounded_view<Segment, Box, Tag, box_tag> >
Chris@102 140 {
Chris@102 141 typedef typename point_type<Box>::type type;
Chris@102 142 };
Chris@102 143
Chris@102 144 template <typename Segment, typename Box, typename Tag, std::size_t Dimension>
Chris@102 145 struct indexed_access<index::detail::bounded_view<Segment, Box, Tag, box_tag>,
Chris@102 146 min_corner, Dimension>
Chris@102 147 {
Chris@102 148 typedef index::detail::bounded_view<Segment, Box, Tag, box_tag> box_type;
Chris@102 149 typedef typename geometry::coordinate_type<Box>::type coordinate_type;
Chris@102 150
Chris@102 151 static inline coordinate_type get(box_type const& b)
Chris@102 152 {
Chris@102 153 return b.template get_min<Dimension>();
Chris@102 154 }
Chris@102 155
Chris@102 156 //static inline void set(box_type & b, coordinate_type const& value)
Chris@102 157 //{
Chris@102 158 // BOOST_GEOMETRY_INDEX_ASSERT(false, "unable to modify a box through view");
Chris@102 159 //}
Chris@102 160 };
Chris@102 161
Chris@102 162 template <typename Segment, typename Box, typename Tag, std::size_t Dimension>
Chris@102 163 struct indexed_access<index::detail::bounded_view<Segment, Box, Tag, box_tag>,
Chris@102 164 max_corner, Dimension>
Chris@102 165 {
Chris@102 166 typedef index::detail::bounded_view<Segment, Box, Tag, box_tag> box_type;
Chris@102 167 typedef typename geometry::coordinate_type<Box>::type coordinate_type;
Chris@102 168
Chris@102 169 static inline coordinate_type get(box_type const& b)
Chris@102 170 {
Chris@102 171 return b.template get_max<Dimension>();
Chris@102 172 }
Chris@102 173
Chris@102 174 //static inline void set(box_type & b, coordinate_type const& value)
Chris@102 175 //{
Chris@102 176 // BOOST_GEOMETRY_INDEX_ASSERT(false, "unable to modify a box through view");
Chris@102 177 //}
Chris@102 178 };
Chris@102 179
Chris@102 180 } // namespace traits
Chris@102 181 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 182
Chris@102 183 }} // namespace boost::geometry
Chris@102 184
Chris@102 185 #endif // BOOST_GEOMETRY_INDEX_DETAIL_BOUNDED_VIEW_HPP