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_STRATEGIES_CARTESIAN_POINT_IN_BOX_HPP Chris@16: #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_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@16: namespace within Chris@16: { Chris@16: Chris@16: Chris@16: struct within_range Chris@16: { Chris@16: template Chris@16: static inline bool apply(Value1 const& value, Value2 const& min_value, Value2 const& max_value) Chris@16: { Chris@16: return value > min_value && value < max_value; Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: struct covered_by_range Chris@16: { Chris@16: template Chris@16: static inline bool apply(Value1 const& value, Value2 const& min_value, Value2 const& max_value) Chris@16: { Chris@16: return value >= min_value && value <= max_value; Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename SubStrategy, Chris@16: typename Point, Chris@16: typename Box, Chris@16: std::size_t Dimension, Chris@16: std::size_t DimensionCount Chris@16: > Chris@16: struct relate_point_box_loop Chris@16: { Chris@16: static inline bool apply(Point const& point, Box const& box) Chris@16: { Chris@101: if (! SubStrategy::apply(get(point), Chris@101: get(box), Chris@16: get(box)) Chris@16: ) Chris@16: { Chris@16: return false; Chris@16: } Chris@101: Chris@16: return relate_point_box_loop Chris@16: < Chris@16: SubStrategy, Chris@16: Point, Box, Chris@16: Dimension + 1, DimensionCount Chris@16: >::apply(point, box); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename SubStrategy, Chris@16: typename Point, Chris@16: typename Box, Chris@16: std::size_t DimensionCount Chris@16: > Chris@16: struct relate_point_box_loop Chris@16: { Chris@16: static inline bool apply(Point const& , Box const& ) Chris@16: { Chris@16: return true; Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: typename Point, Chris@16: typename Box, Chris@16: typename SubStrategy = within_range Chris@16: > Chris@16: struct point_in_box Chris@16: { Chris@101: static inline bool apply(Point const& point, Box const& box) Chris@16: { Chris@16: return relate_point_box_loop Chris@16: < Chris@16: SubStrategy, Chris@101: Point, Box, Chris@16: 0, dimension::type::value Chris@16: >::apply(point, box); 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: point_tag, box_tag, Chris@101: point_tag, areal_tag, Chris@101: cartesian_tag, cartesian_tag, Chris@16: Point, Box Chris@16: > Chris@16: { Chris@101: typedef within::point_in_box type; Chris@16: }; Chris@16: Chris@16: Chris@16: }} // namespace within::services Chris@16: Chris@16: Chris@16: namespace covered_by { namespace services Chris@16: { Chris@16: Chris@16: Chris@16: template Chris@16: struct default_strategy Chris@16: < Chris@101: point_tag, box_tag, Chris@101: point_tag, areal_tag, Chris@101: cartesian_tag, cartesian_tag, Chris@16: Point, Box Chris@16: > Chris@16: { Chris@16: typedef within::point_in_box Chris@16: < Chris@16: Point, Box, Chris@16: within::covered_by_range Chris@16: > type; Chris@16: }; 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: Chris@16: #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_BOX_HPP