File indexing completed on 2025-01-18 09:35:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_INTERFACE_HPP
0011 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_INTERFACE_HPP
0012
0013 #include <boost/concept_check.hpp>
0014
0015 #include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
0016 #include <boost/geometry/algorithms/detail/closest_points/utilities.hpp>
0017
0018 #include <boost/geometry/algorithms/dispatch/closest_points.hpp>
0019
0020 #include <boost/geometry/algorithms/detail/distance/interface.hpp>
0021
0022 #include <boost/geometry/core/point_type.hpp>
0023
0024 #include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
0025 #include <boost/geometry/geometries/concepts/check.hpp>
0026
0027 #include <boost/geometry/strategies/default_strategy.hpp>
0028 #include <boost/geometry/strategies/detail.hpp>
0029 #include <boost/geometry/strategies/closest_points/services.hpp>
0030
0031
0032 namespace boost { namespace geometry
0033 {
0034
0035
0036 #ifndef DOXYGEN_NO_DISPATCH
0037 namespace dispatch
0038 {
0039
0040
0041
0042
0043 template
0044 <
0045 typename Geometry1,
0046 typename Geometry2,
0047 typename Tag1,
0048 typename Tag2
0049 >
0050 struct closest_points
0051 <
0052 Geometry1, Geometry2,
0053 Tag1, Tag2, true
0054 >
0055 : closest_points<Geometry2, Geometry1, Tag2, Tag1, false>
0056 {
0057 template <typename Segment, typename Strategy>
0058 static inline void apply(Geometry1 const& g1, Geometry2 const& g2,
0059 Segment& shortest_seg, Strategy const& strategy)
0060 {
0061 closest_points
0062 <
0063 Geometry2, Geometry1, Tag2, Tag1, false
0064 >::apply(g2, g1, shortest_seg, strategy);
0065
0066 detail::closest_points::swap_segment_points::apply(shortest_seg);
0067 }
0068 };
0069
0070
0071 }
0072 #endif
0073
0074
0075 namespace resolve_strategy
0076 {
0077
0078 template<typename Strategy>
0079 struct closest_points
0080 {
0081 template <typename Geometry1, typename Geometry2, typename Segment>
0082 static inline void apply(Geometry1 const& geometry1,
0083 Geometry2 const& geometry2,
0084 Segment& shortest_seg,
0085 Strategy const& strategy)
0086 {
0087 dispatch::closest_points
0088 <
0089 Geometry1, Geometry2
0090 >::apply(geometry1, geometry2, shortest_seg, strategy);
0091 }
0092 };
0093
0094 template <>
0095 struct closest_points<default_strategy>
0096 {
0097 template <typename Geometry1, typename Geometry2, typename Segment>
0098 static inline void
0099 apply(Geometry1 const& geometry1,
0100 Geometry2 const& geometry2,
0101 Segment& shortest_seg,
0102 default_strategy)
0103 {
0104 using strategy_type = typename strategies::closest_points::services::default_strategy
0105 <
0106 Geometry1, Geometry2
0107 >::type;
0108
0109 dispatch::closest_points
0110 <
0111 Geometry1, Geometry2
0112 >::apply(geometry1, geometry2, shortest_seg, strategy_type());
0113 }
0114 };
0115
0116 }
0117
0118
0119 namespace resolve_variant
0120 {
0121
0122
0123 template <typename Geometry1, typename Geometry2>
0124 struct closest_points
0125 {
0126 template <typename Segment, typename Strategy>
0127 static inline void apply(Geometry1 const& geometry1,
0128 Geometry2 const& geometry2,
0129 Segment& shortest_seg,
0130 Strategy const& strategy)
0131 {
0132 resolve_strategy::closest_points
0133 <
0134 Strategy
0135 >::apply(geometry1, geometry2, shortest_seg, strategy);
0136 }
0137 };
0138
0139
0140
0141 }
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 template <typename Geometry1, typename Geometry2, typename Segment, typename Strategy>
0174 inline void closest_points(Geometry1 const& geometry1,
0175 Geometry2 const& geometry2,
0176 Segment& shortest_seg,
0177 Strategy const& strategy)
0178 {
0179 concepts::check<Geometry1 const>();
0180 concepts::check<Geometry2 const>();
0181
0182 detail::throw_on_empty_input(geometry1);
0183 detail::throw_on_empty_input(geometry2);
0184
0185 resolve_variant::closest_points
0186 <
0187 Geometry1,
0188 Geometry2
0189 >::apply(geometry1, geometry2, shortest_seg, strategy);
0190 }
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215 template <typename Geometry1, typename Geometry2, typename Segment>
0216 inline void closest_points(Geometry1 const& geometry1,
0217 Geometry2 const& geometry2,
0218 Segment& shortest_seg)
0219 {
0220 closest_points(geometry1, geometry2, shortest_seg, default_strategy());
0221 }
0222
0223 }}
0224
0225 #endif