annotate DEPENDENCIES/generic/include/boost/geometry/strategies/cartesian/box_in_box.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 c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@101 6 // Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
Chris@16 7
Chris@16 8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 10
Chris@16 11 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 13 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 14
Chris@16 15 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
Chris@16 16 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
Chris@16 17
Chris@16 18
Chris@16 19 #include <boost/geometry/core/access.hpp>
Chris@16 20 #include <boost/geometry/core/coordinate_dimension.hpp>
Chris@16 21 #include <boost/geometry/strategies/covered_by.hpp>
Chris@16 22 #include <boost/geometry/strategies/within.hpp>
Chris@16 23
Chris@16 24
Chris@101 25 namespace boost { namespace geometry { namespace strategy
Chris@16 26 {
Chris@101 27
Chris@101 28
Chris@16 29 namespace within
Chris@16 30 {
Chris@16 31
Chris@16 32 struct box_within_range
Chris@16 33 {
Chris@16 34 template <typename BoxContainedValue, typename BoxContainingValue>
Chris@16 35 static inline bool apply(BoxContainedValue const& bed_min
Chris@16 36 , BoxContainedValue const& bed_max
Chris@16 37 , BoxContainingValue const& bing_min
Chris@16 38 , BoxContainingValue const& bing_max)
Chris@16 39 {
Chris@101 40 return bing_min <= bed_min && bed_max <= bing_max // contained in containing
Chris@101 41 && bed_min < bed_max; // interiors overlap
Chris@16 42 }
Chris@16 43 };
Chris@16 44
Chris@16 45
Chris@16 46 struct box_covered_by_range
Chris@16 47 {
Chris@16 48 template <typename BoxContainedValue, typename BoxContainingValue>
Chris@16 49 static inline bool apply(BoxContainedValue const& bed_min
Chris@16 50 , BoxContainedValue const& bed_max
Chris@16 51 , BoxContainingValue const& bing_min
Chris@16 52 , BoxContainingValue const& bing_max)
Chris@16 53 {
Chris@16 54 return bed_min >= bing_min && bed_max <= bing_max;
Chris@16 55 }
Chris@16 56 };
Chris@16 57
Chris@16 58
Chris@16 59 template
Chris@16 60 <
Chris@16 61 typename SubStrategy,
Chris@16 62 typename Box1,
Chris@16 63 typename Box2,
Chris@16 64 std::size_t Dimension,
Chris@16 65 std::size_t DimensionCount
Chris@16 66 >
Chris@16 67 struct relate_box_box_loop
Chris@16 68 {
Chris@16 69 static inline bool apply(Box1 const& b_contained, Box2 const& b_containing)
Chris@16 70 {
Chris@16 71 assert_dimension_equal<Box1, Box2>();
Chris@16 72
Chris@16 73 if (! SubStrategy::apply(
Chris@101 74 get<min_corner, Dimension>(b_contained),
Chris@101 75 get<max_corner, Dimension>(b_contained),
Chris@101 76 get<min_corner, Dimension>(b_containing),
Chris@16 77 get<max_corner, Dimension>(b_containing)
Chris@16 78 )
Chris@16 79 )
Chris@16 80 {
Chris@16 81 return false;
Chris@16 82 }
Chris@16 83
Chris@16 84 return relate_box_box_loop
Chris@16 85 <
Chris@16 86 SubStrategy,
Chris@16 87 Box1, Box2,
Chris@16 88 Dimension + 1, DimensionCount
Chris@16 89 >::apply(b_contained, b_containing);
Chris@16 90 }
Chris@16 91 };
Chris@16 92
Chris@16 93 template
Chris@16 94 <
Chris@16 95 typename SubStrategy,
Chris@16 96 typename Box1,
Chris@16 97 typename Box2,
Chris@16 98 std::size_t DimensionCount
Chris@16 99 >
Chris@16 100 struct relate_box_box_loop<SubStrategy, Box1, Box2, DimensionCount, DimensionCount>
Chris@16 101 {
Chris@16 102 static inline bool apply(Box1 const& , Box2 const& )
Chris@16 103 {
Chris@16 104 return true;
Chris@16 105 }
Chris@16 106 };
Chris@16 107
Chris@16 108 template
Chris@16 109 <
Chris@16 110 typename Box1,
Chris@16 111 typename Box2,
Chris@16 112 typename SubStrategy = box_within_range
Chris@16 113 >
Chris@16 114 struct box_in_box
Chris@16 115 {
Chris@16 116 static inline bool apply(Box1 const& box1, Box2 const& box2)
Chris@16 117 {
Chris@16 118 return relate_box_box_loop
Chris@16 119 <
Chris@101 120 SubStrategy,
Chris@16 121 Box1, Box2, 0, dimension<Box1>::type::value
Chris@16 122 >::apply(box1, box2);
Chris@16 123 }
Chris@16 124 };
Chris@16 125
Chris@16 126
Chris@16 127 } // namespace within
Chris@16 128
Chris@16 129
Chris@16 130 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
Chris@16 131
Chris@16 132
Chris@16 133 namespace within { namespace services
Chris@16 134 {
Chris@16 135
Chris@16 136 template <typename BoxContained, typename BoxContaining>
Chris@16 137 struct default_strategy
Chris@16 138 <
Chris@101 139 box_tag, box_tag,
Chris@101 140 box_tag, areal_tag,
Chris@101 141 cartesian_tag, cartesian_tag,
Chris@16 142 BoxContained, BoxContaining
Chris@16 143 >
Chris@16 144 {
Chris@16 145 typedef within::box_in_box<BoxContained, BoxContaining> type;
Chris@16 146 };
Chris@16 147
Chris@16 148
Chris@16 149 }} // namespace within::services
Chris@16 150
Chris@16 151 namespace covered_by { namespace services
Chris@16 152 {
Chris@16 153
Chris@16 154 template <typename BoxContained, typename BoxContaining>
Chris@16 155 struct default_strategy
Chris@16 156 <
Chris@101 157 box_tag, box_tag,
Chris@101 158 box_tag, areal_tag,
Chris@101 159 cartesian_tag, cartesian_tag,
Chris@16 160 BoxContained, BoxContaining
Chris@16 161 >
Chris@16 162 {
Chris@16 163 typedef within::box_in_box
Chris@16 164 <
Chris@16 165 BoxContained, BoxContaining,
Chris@16 166 within::box_covered_by_range
Chris@16 167 > type;
Chris@16 168 };
Chris@16 169
Chris@16 170 }} // namespace covered_by::services
Chris@16 171
Chris@16 172
Chris@16 173 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
Chris@16 174
Chris@16 175
Chris@16 176 }}} // namespace boost::geometry::strategy
Chris@16 177
Chris@16 178 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP