123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
- #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
- #include <iterator>
- #include <type_traits>
- #include <vector>
- #include <boost/concept_check.hpp>
- #include <boost/core/ignore_unused.hpp>
- #include <boost/geometry/core/static_assert.hpp>
- #include <boost/geometry/geometries/concepts/point_concept.hpp>
- #include <boost/geometry/geometries/segment.hpp>
- #include <boost/geometry/geometries/point.hpp>
- #include <boost/geometry/strategies/distance.hpp>
- #include <boost/geometry/strategies/tags.hpp>
- #include <boost/geometry/util/parameter_type_of.hpp>
- namespace boost { namespace geometry { namespace concepts
- {
- template <typename Strategy, typename Point1, typename Point2>
- struct PointDistanceStrategy
- {
- #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
- private :
- struct checker
- {
- template <typename ApplyMethod>
- static void apply(ApplyMethod)
- {
-
- typedef typename parameter_type_of
- <
- ApplyMethod, 0
- >::type ptype1;
- typedef typename parameter_type_of
- <
- ApplyMethod, 1
- >::type ptype2;
-
- typedef typename strategy::distance::services::return_type
- <
- Strategy, ptype1, ptype2
- >::type rtype;
-
- typedef typename strategy::distance::services::comparable_type
- <
- Strategy
- >::type ctype;
-
- typedef typename strategy::distance::services::tag
- <
- Strategy
- >::type tag;
- static const bool is_correct_strategy_tag =
- std::is_same<tag, strategy_tag_distance_point_point>::value
- || std::is_same<tag, strategy_tag_distance_point_box>::value
- || std::is_same<tag, strategy_tag_distance_box_box>::value;
- BOOST_GEOMETRY_STATIC_ASSERT(
- is_correct_strategy_tag,
- "Incorrect Strategy tag.",
- Strategy, tag);
-
- Strategy* str = 0;
- ptype1 *p1 = 0;
- ptype2 *p2 = 0;
- rtype r = str->apply(*p1, *p2);
-
- ctype c = strategy::distance::services::get_comparable
- <
- Strategy
- >::apply(*str);
-
- r = strategy::distance::services::result_from_distance
- <
- Strategy,
- ptype1, ptype2
- >::apply(*str, 1.0);
- boost::ignore_unused<tag>();
- boost::ignore_unused(str, c, r);
- }
- };
- public :
- BOOST_CONCEPT_USAGE(PointDistanceStrategy)
- {
- checker::apply(&Strategy::template apply<Point1, Point2>);
- }
- #endif
- };
- template <typename Strategy, typename Point, typename PointOfSegment>
- struct PointSegmentDistanceStrategy
- {
- #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
- private :
- struct checker
- {
- template <typename ApplyMethod>
- static void apply(ApplyMethod)
- {
-
- typedef typename parameter_type_of
- <
- ApplyMethod, 0
- >::type ptype;
- typedef typename parameter_type_of
- <
- ApplyMethod, 1
- >::type sptype;
- namespace services = strategy::distance::services;
-
- typedef typename services::tag<Strategy>::type tag;
- BOOST_GEOMETRY_STATIC_ASSERT(
- (std::is_same
- <
- tag, strategy_tag_distance_point_segment
- >::value),
- "Incorrect Strategy tag.",
- Strategy, tag);
-
- typedef typename services::return_type
- <
- Strategy, ptype, sptype
- >::type rtype;
-
- typedef typename services::comparable_type<Strategy>::type ctype;
-
- Strategy *str = 0;
- ptype *p = 0;
- sptype *sp1 = 0;
- sptype *sp2 = 0;
- rtype r = str->apply(*p, *sp1, *sp2);
-
- ctype cstrategy = services::get_comparable<Strategy>::apply(*str);
-
- r = services::result_from_distance
- <
- Strategy, ptype, sptype
- >::apply(*str, rtype(1.0));
- boost::ignore_unused(str, r, cstrategy);
- }
- };
- public :
- BOOST_CONCEPT_USAGE(PointSegmentDistanceStrategy)
- {
- checker::apply(&Strategy::template apply<Point, PointOfSegment>);
- }
- #endif
- };
- }}}
- #endif
|