File indexing completed on 2025-01-18 09:36:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
0021 #define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
0022
0023 #include <iterator>
0024 #include <type_traits>
0025 #include <vector>
0026
0027 #include <boost/concept_check.hpp>
0028 #include <boost/core/ignore_unused.hpp>
0029
0030 #include <boost/geometry/core/static_assert.hpp>
0031
0032 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0033 #include <boost/geometry/geometries/segment.hpp>
0034 #include <boost/geometry/geometries/point.hpp>
0035
0036 #include <boost/geometry/strategies/distance.hpp>
0037 #include <boost/geometry/strategies/tags.hpp>
0038
0039 #include <boost/geometry/util/parameter_type_of.hpp>
0040
0041
0042 namespace boost { namespace geometry { namespace concepts
0043 {
0044
0045
0046
0047
0048
0049
0050 template <typename Strategy, typename Point1, typename Point2>
0051 struct PointDistanceStrategy
0052 {
0053 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0054 private :
0055
0056 struct checker
0057 {
0058 template <typename ApplyMethod>
0059 static void apply(ApplyMethod)
0060 {
0061
0062 typedef typename parameter_type_of
0063 <
0064 ApplyMethod, 0
0065 >::type ptype1;
0066
0067 typedef typename parameter_type_of
0068 <
0069 ApplyMethod, 1
0070 >::type ptype2;
0071
0072
0073 typedef typename strategy::distance::services::return_type
0074 <
0075 Strategy, ptype1, ptype2
0076 >::type rtype;
0077
0078
0079 typedef typename strategy::distance::services::comparable_type
0080 <
0081 Strategy
0082 >::type ctype;
0083
0084
0085 typedef typename strategy::distance::services::tag
0086 <
0087 Strategy
0088 >::type tag;
0089
0090 static const bool is_correct_strategy_tag =
0091 std::is_same<tag, strategy_tag_distance_point_point>::value
0092 || std::is_same<tag, strategy_tag_distance_point_box>::value
0093 || std::is_same<tag, strategy_tag_distance_box_box>::value;
0094
0095 BOOST_GEOMETRY_STATIC_ASSERT(
0096 is_correct_strategy_tag,
0097 "Incorrect Strategy tag.",
0098 Strategy, tag);
0099
0100
0101 Strategy* str = 0;
0102 ptype1 *p1 = 0;
0103 ptype2 *p2 = 0;
0104 rtype r = str->apply(*p1, *p2);
0105
0106
0107 ctype c = strategy::distance::services::get_comparable
0108 <
0109 Strategy
0110 >::apply(*str);
0111
0112
0113 r = strategy::distance::services::result_from_distance
0114 <
0115 Strategy,
0116 ptype1, ptype2
0117 >::apply(*str, 1.0);
0118
0119 boost::ignore_unused<tag>();
0120 boost::ignore_unused(str, c, r);
0121 }
0122 };
0123
0124
0125
0126 public :
0127 BOOST_CONCEPT_USAGE(PointDistanceStrategy)
0128 {
0129 checker::apply(&Strategy::template apply<Point1, Point2>);
0130 }
0131 #endif
0132 };
0133
0134
0135
0136
0137
0138
0139 template <typename Strategy, typename Point, typename PointOfSegment>
0140 struct PointSegmentDistanceStrategy
0141 {
0142 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
0143 private :
0144
0145 struct checker
0146 {
0147 template <typename ApplyMethod>
0148 static void apply(ApplyMethod)
0149 {
0150
0151 typedef typename parameter_type_of
0152 <
0153 ApplyMethod, 0
0154 >::type ptype;
0155
0156 typedef typename parameter_type_of
0157 <
0158 ApplyMethod, 1
0159 >::type sptype;
0160
0161 namespace services = strategy::distance::services;
0162
0163 typedef typename services::tag<Strategy>::type tag;
0164
0165 BOOST_GEOMETRY_STATIC_ASSERT(
0166 (std::is_same
0167 <
0168 tag, strategy_tag_distance_point_segment
0169 >::value),
0170 "Incorrect Strategy tag.",
0171 Strategy, tag);
0172
0173
0174 typedef typename services::return_type
0175 <
0176 Strategy, ptype, sptype
0177 >::type rtype;
0178
0179
0180 typedef typename services::comparable_type<Strategy>::type ctype;
0181
0182
0183 Strategy *str = 0;
0184 ptype *p = 0;
0185 sptype *sp1 = 0;
0186 sptype *sp2 = 0;
0187
0188 rtype r = str->apply(*p, *sp1, *sp2);
0189
0190
0191 ctype cstrategy = services::get_comparable<Strategy>::apply(*str);
0192
0193
0194 r = services::result_from_distance
0195 <
0196 Strategy, ptype, sptype
0197 >::apply(*str, rtype(1.0));
0198
0199 boost::ignore_unused(str, r, cstrategy);
0200 }
0201 };
0202
0203 public :
0204 BOOST_CONCEPT_USAGE(PointSegmentDistanceStrategy)
0205 {
0206 checker::apply(&Strategy::template apply<Point, PointOfSegment>);
0207 }
0208 #endif
0209 };
0210
0211
0212 }}}
0213
0214
0215 #endif