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@101: // Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. 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_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP Chris@16: #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP Chris@16: Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@101: namespace boost { namespace geometry { namespace strategy Chris@16: { Chris@101: Chris@101: Chris@16: namespace within Chris@16: { Chris@16: Chris@16: struct box_within_range Chris@16: { Chris@16: template Chris@16: static inline bool apply(BoxContainedValue const& bed_min Chris@16: , BoxContainedValue const& bed_max Chris@16: , BoxContainingValue const& bing_min Chris@16: , BoxContainingValue const& bing_max) Chris@16: { Chris@101: return bing_min <= bed_min && bed_max <= bing_max // contained in containing Chris@101: && bed_min < bed_max; // interiors overlap Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: struct box_covered_by_range Chris@16: { Chris@16: template Chris@16: static inline bool apply(BoxContainedValue const& bed_min Chris@16: , BoxContainedValue const& bed_max Chris@16: , BoxContainingValue const& bing_min Chris@16: , BoxContainingValue const& bing_max) Chris@16: { Chris@16: return bed_min >= bing_min && bed_max <= bing_max; Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename SubStrategy, Chris@16: typename Box1, Chris@16: typename Box2, Chris@16: std::size_t Dimension, Chris@16: std::size_t DimensionCount Chris@16: > Chris@16: struct relate_box_box_loop Chris@16: { Chris@16: static inline bool apply(Box1 const& b_contained, Box2 const& b_containing) Chris@16: { Chris@16: assert_dimension_equal(); Chris@16: Chris@16: if (! SubStrategy::apply( Chris@101: get(b_contained), Chris@101: get(b_contained), Chris@101: get(b_containing), Chris@16: get(b_containing) Chris@16: ) Chris@16: ) Chris@16: { Chris@16: return false; Chris@16: } Chris@16: Chris@16: return relate_box_box_loop Chris@16: < Chris@16: SubStrategy, Chris@16: Box1, Box2, Chris@16: Dimension + 1, DimensionCount Chris@16: >::apply(b_contained, b_containing); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: < Chris@16: typename SubStrategy, Chris@16: typename Box1, Chris@16: typename Box2, Chris@16: std::size_t DimensionCount Chris@16: > Chris@16: struct relate_box_box_loop Chris@16: { Chris@16: static inline bool apply(Box1 const& , Box2 const& ) Chris@16: { Chris@16: return true; Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: < Chris@16: typename Box1, Chris@16: typename Box2, Chris@16: typename SubStrategy = box_within_range Chris@16: > Chris@16: struct box_in_box Chris@16: { Chris@16: static inline bool apply(Box1 const& box1, Box2 const& box2) Chris@16: { Chris@16: return relate_box_box_loop Chris@16: < Chris@101: SubStrategy, Chris@16: Box1, Box2, 0, dimension::type::value Chris@16: >::apply(box1, box2); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace within Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS Chris@16: Chris@16: Chris@16: namespace within { namespace services Chris@16: { Chris@16: Chris@16: template Chris@16: struct default_strategy Chris@16: < Chris@101: box_tag, box_tag, Chris@101: box_tag, areal_tag, Chris@101: cartesian_tag, cartesian_tag, Chris@16: BoxContained, BoxContaining Chris@16: > Chris@16: { Chris@16: typedef within::box_in_box type; Chris@16: }; Chris@16: Chris@16: Chris@16: }} // namespace within::services Chris@16: Chris@16: namespace covered_by { namespace services Chris@16: { Chris@16: Chris@16: template Chris@16: struct default_strategy Chris@16: < Chris@101: box_tag, box_tag, Chris@101: box_tag, areal_tag, Chris@101: cartesian_tag, cartesian_tag, Chris@16: BoxContained, BoxContaining Chris@16: > Chris@16: { Chris@16: typedef within::box_in_box Chris@16: < Chris@16: BoxContained, BoxContaining, Chris@16: within::box_covered_by_range Chris@16: > type; Chris@16: }; Chris@16: Chris@16: }} // namespace covered_by::services Chris@16: Chris@16: Chris@16: #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS Chris@16: Chris@16: Chris@16: }}} // namespace boost::geometry::strategy Chris@16: Chris@16: #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP