Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@101: // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. Chris@101: // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. Chris@101: // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. Chris@101: Chris@101: // This file was modified by Oracle on 2014. Chris@101: // Modifications copyright (c) 2014, Oracle and/or its affiliates. Chris@101: Chris@101: // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 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_DISTANCE_CONCEPT_HPP Chris@16: #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@101: #include Chris@101: Chris@16: Chris@16: namespace boost { namespace geometry { namespace concept Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@101: \brief Checks strategy for point-point or point-box or box-box distance Chris@16: \ingroup distance Chris@16: */ Chris@16: template Chris@16: struct PointDistanceStrategy Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: private : Chris@16: Chris@16: struct checker Chris@16: { Chris@16: template Chris@16: static void apply(ApplyMethod) Chris@16: { Chris@16: // 1: inspect and define both arguments of apply Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 0 Chris@16: >::type ptype1; Chris@16: Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 1 Chris@16: >::type ptype2; Chris@16: Chris@101: // 2) must define meta-function "return_type" Chris@16: typedef typename strategy::distance::services::return_type Chris@16: < Chris@16: Strategy, ptype1, ptype2 Chris@16: >::type rtype; Chris@16: Chris@16: // 3) must define meta-function "comparable_type" Chris@16: typedef typename strategy::distance::services::comparable_type Chris@16: < Chris@16: Strategy Chris@16: >::type ctype; Chris@16: Chris@16: // 4) must define meta-function "tag" Chris@16: typedef typename strategy::distance::services::tag Chris@16: < Chris@16: Strategy Chris@16: >::type tag; Chris@16: Chris@101: static const bool is_correct_strategy_tag = Chris@101: boost::is_same::value Chris@101: || boost::is_same::value Chris@101: || boost::is_same::value; Chris@101: Chris@101: BOOST_MPL_ASSERT_MSG Chris@101: ((is_correct_strategy_tag), Chris@101: INCORRECT_STRATEGY_TAG, Chris@101: (types)); Chris@101: Chris@16: // 5) must implement apply with arguments Chris@16: Strategy* str = 0; Chris@16: ptype1 *p1 = 0; Chris@16: ptype2 *p2 = 0; Chris@16: rtype r = str->apply(*p1, *p2); Chris@16: Chris@16: // 6) must define (meta)struct "get_comparable" with apply Chris@16: ctype c = strategy::distance::services::get_comparable Chris@16: < Chris@16: Strategy Chris@16: >::apply(*str); Chris@16: Chris@16: // 7) must define (meta)struct "result_from_distance" with apply Chris@16: r = strategy::distance::services::result_from_distance Chris@16: < Chris@16: Strategy, Chris@16: ptype1, ptype2 Chris@16: >::apply(*str, 1.0); Chris@16: Chris@101: boost::ignore_unused(); Chris@101: boost::ignore_unused(str, c, r); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: public : Chris@16: BOOST_CONCEPT_USAGE(PointDistanceStrategy) Chris@16: { Chris@16: checker::apply(&Strategy::template apply); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: Chris@16: /*! Chris@101: \brief Checks strategy for point-segment distance Chris@16: \ingroup strategy_concepts Chris@16: */ Chris@16: template Chris@16: struct PointSegmentDistanceStrategy Chris@16: { Chris@16: #ifndef DOXYGEN_NO_CONCEPT_MEMBERS Chris@16: private : Chris@16: Chris@16: struct checker Chris@16: { Chris@16: template Chris@16: static void apply(ApplyMethod) Chris@16: { Chris@101: // 1) inspect and define both arguments of apply Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 0 Chris@16: >::type ptype; Chris@16: Chris@16: typedef typename parameter_type_of Chris@16: < Chris@16: ApplyMethod, 1 Chris@16: >::type sptype; Chris@16: Chris@101: namespace services = strategy::distance::services; Chris@101: // 2) must define meta-function "tag" Chris@101: typedef typename services::tag::type tag; Chris@16: Chris@101: BOOST_MPL_ASSERT_MSG Chris@101: ((boost::is_same Chris@101: < Chris@101: tag, strategy_tag_distance_point_segment Chris@101: >::value), Chris@101: INCORRECT_STRATEGY_TAG, Chris@101: (types)); Chris@16: Chris@101: // 3) must define meta-function "return_type" Chris@101: typedef typename services::return_type Chris@101: < Chris@101: Strategy, ptype, sptype Chris@101: >::type rtype; Chris@16: Chris@101: // 4) must define meta-function "comparable_type" Chris@101: typedef typename services::comparable_type::type ctype; Chris@101: Chris@101: // 5) must implement apply with arguments Chris@16: Strategy *str = 0; Chris@16: ptype *p = 0; Chris@16: sptype *sp1 = 0; Chris@16: sptype *sp2 = 0; Chris@16: Chris@16: rtype r = str->apply(*p, *sp1, *sp2); Chris@16: Chris@101: // 6) must define (meta-)struct "get_comparable" with apply Chris@101: ctype cstrategy = services::get_comparable::apply(*str); Chris@101: Chris@101: // 7) must define (meta-)struct "result_from_distance" with apply Chris@101: r = services::result_from_distance Chris@101: < Chris@101: Strategy, ptype, sptype Chris@101: >::apply(*str, rtype(1.0)); Chris@101: Chris@101: boost::ignore_unused(str, r, cstrategy); Chris@16: } Chris@16: }; Chris@16: Chris@16: public : Chris@16: BOOST_CONCEPT_USAGE(PointSegmentDistanceStrategy) Chris@16: { Chris@16: checker::apply(&Strategy::template apply); Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: Chris@16: }}} // namespace boost::geometry::concept Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP