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_CONCEPTS_WITHIN_CONCEPT_HPP Chris@16: #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP Chris@16: Chris@16: Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry { namespace concept Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Checks strategy for within (point-in-polygon) Chris@16: \ingroup within Chris@16: */ Chris@16: template Chris@16: class WithinStrategyPolygonal Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: Chris@16: // 1) must define state_type Chris@16: typedef typename Strategy::state_type state_type; Chris@16: Chris@16: struct checker Chris@16: { Chris@16: template Chris@16: static void apply(ApplyMethod const&, ResultMethod const& ) Chris@16: { Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 0 Chris@16: >::type point_type; Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 1 Chris@16: >::type segment_point_type; Chris@16: Chris@16: // CHECK: apply-arguments should both fulfill point concept Chris@16: BOOST_CONCEPT_ASSERT Chris@16: ( Chris@16: (concept::ConstPoint) Chris@16: ); Chris@16: Chris@16: BOOST_CONCEPT_ASSERT Chris@16: ( Chris@16: (concept::ConstPoint) Chris@16: ); Chris@16: Chris@16: // CHECK: return types (result: int, apply: bool) Chris@16: BOOST_MPL_ASSERT_MSG Chris@16: ( Chris@16: (boost::is_same Chris@16: < Chris@16: bool, typename boost::function_types::result_type::type Chris@16: >::type::value), Chris@16: WRONG_RETURN_TYPE_OF_APPLY Chris@16: , (bool) Chris@16: ); Chris@16: BOOST_MPL_ASSERT_MSG Chris@16: ( Chris@16: (boost::is_same Chris@16: < Chris@16: int, typename boost::function_types::result_type::type Chris@16: >::type::value), Chris@16: WRONG_RETURN_TYPE_OF_RESULT Chris@16: , (int) Chris@16: ); Chris@16: Chris@16: Chris@16: // CHECK: calling method apply and result Chris@16: Strategy const* str = 0; Chris@16: state_type* st = 0; Chris@16: point_type const* p = 0; Chris@16: segment_point_type const* sp = 0; Chris@16: Chris@16: bool b = str->apply(*p, *sp, *sp, *st); Chris@16: int r = str->result(*st); Chris@16: Chris@16: boost::ignore_unused_variable_warning(r); Chris@16: boost::ignore_unused_variable_warning(b); Chris@16: boost::ignore_unused_variable_warning(str); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: public : Chris@16: BOOST_CONCEPT_USAGE(WithinStrategyPolygonal) Chris@16: { Chris@16: checker::apply(&Strategy::apply, &Strategy::result); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: template Chris@16: class WithinStrategyPointBox Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: Chris@16: struct checker Chris@16: { Chris@16: template Chris@16: static void apply(ApplyMethod const&) Chris@16: { Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 0 Chris@16: >::type point_type; Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 1 Chris@16: >::type box_type; Chris@16: Chris@16: // CHECK: apply-arguments should fulfill point/box concept Chris@16: BOOST_CONCEPT_ASSERT Chris@16: ( Chris@16: (concept::ConstPoint) Chris@16: ); Chris@16: Chris@16: BOOST_CONCEPT_ASSERT Chris@16: ( Chris@16: (concept::ConstBox) Chris@16: ); Chris@16: Chris@16: // CHECK: return types (apply: bool) Chris@16: BOOST_MPL_ASSERT_MSG Chris@16: ( Chris@16: (boost::is_same Chris@16: < Chris@101: bool, Chris@16: typename boost::function_types::result_type::type Chris@16: >::type::value), Chris@16: WRONG_RETURN_TYPE Chris@16: , (bool) Chris@16: ); Chris@16: Chris@16: Chris@16: // CHECK: calling method apply Chris@16: Strategy const* str = 0; Chris@16: point_type const* p = 0; Chris@16: box_type const* bx = 0; Chris@16: Chris@16: bool b = str->apply(*p, *bx); Chris@16: Chris@16: boost::ignore_unused_variable_warning(b); Chris@16: boost::ignore_unused_variable_warning(str); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: public : Chris@16: BOOST_CONCEPT_USAGE(WithinStrategyPointBox) Chris@16: { Chris@16: checker::apply(&Strategy::apply); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: template Chris@16: class WithinStrategyBoxBox Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: Chris@16: struct checker Chris@16: { Chris@16: template Chris@16: static void apply(ApplyMethod const&) Chris@16: { Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 0 Chris@16: >::type box_type1; Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 1 Chris@16: >::type box_type2; Chris@16: Chris@16: // CHECK: apply-arguments should both fulfill box concept Chris@16: BOOST_CONCEPT_ASSERT Chris@16: ( Chris@16: (concept::ConstBox) Chris@16: ); Chris@16: Chris@16: BOOST_CONCEPT_ASSERT Chris@16: ( Chris@16: (concept::ConstBox) Chris@16: ); Chris@16: Chris@16: // CHECK: return types (apply: bool) Chris@16: BOOST_MPL_ASSERT_MSG Chris@16: ( Chris@16: (boost::is_same Chris@16: < Chris@101: bool, Chris@16: typename boost::function_types::result_type::type Chris@16: >::type::value), Chris@16: WRONG_RETURN_TYPE Chris@16: , (bool) Chris@16: ); Chris@16: Chris@16: Chris@16: // CHECK: calling method apply Chris@16: Strategy const* str = 0; Chris@16: box_type1 const* b1 = 0; Chris@16: box_type2 const* b2 = 0; Chris@16: Chris@16: bool b = str->apply(*b1, *b2); Chris@16: Chris@16: boost::ignore_unused_variable_warning(b); Chris@16: boost::ignore_unused_variable_warning(str); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: public : Chris@16: BOOST_CONCEPT_USAGE(WithinStrategyBoxBox) Chris@16: { Chris@16: checker::apply(&Strategy::apply); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: // So now: boost::geometry::concept::within Chris@101: namespace within Chris@101: { Chris@16: Chris@16: #ifndef DOXYGEN_NO_DISPATCH Chris@16: namespace dispatch Chris@16: { Chris@16: Chris@16: template Chris@16: struct check_within Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct check_within Chris@16: { Chris@16: BOOST_CONCEPT_ASSERT( (WithinStrategyPolygonal) ); Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: struct check_within Chris@16: { Chris@16: BOOST_CONCEPT_ASSERT( (WithinStrategyPointBox) ); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct check_within Chris@16: { Chris@16: BOOST_CONCEPT_ASSERT( (WithinStrategyBoxBox) ); Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace dispatch Chris@16: #endif Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Checks, in compile-time, the concept of any within-strategy Chris@16: \ingroup concepts Chris@16: */ Chris@16: template Chris@16: inline void check() Chris@16: { Chris@16: dispatch::check_within c; Chris@16: boost::ignore_unused_variable_warning(c); Chris@16: } Chris@16: Chris@16: Chris@16: }}}} // namespace boost::geometry::concept::within Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP