File indexing completed on 2025-01-18 09:36:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP
0013
0014 #include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
0015
0016 #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
0017 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
0018 #include <boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp>
0019 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
0020
0021 namespace boost { namespace geometry
0022 {
0023
0024
0025 namespace strategy { namespace distance
0026 {
0027
0028 template
0029 <
0030 typename CalculationType = void,
0031 typename Strategy = pythagoras<CalculationType>
0032 >
0033 struct cartesian_segment_box
0034 {
0035 template <typename PointOfSegment, typename PointOfBox>
0036 struct calculation_type
0037 : promote_floating_point
0038 <
0039 typename strategy::distance::services::return_type
0040 <
0041 Strategy,
0042 PointOfSegment,
0043 PointOfBox
0044 >::type
0045 >
0046 {};
0047
0048 typedef cartesian_tag cs_tag;
0049
0050 template
0051 <
0052 typename LessEqual, typename ReturnType,
0053 typename SegmentPoint, typename BoxPoint,
0054 typename Strategies
0055 >
0056 inline ReturnType segment_below_of_box(SegmentPoint const& p0,
0057 SegmentPoint const& p1,
0058 BoxPoint const&,
0059 BoxPoint const&,
0060 BoxPoint const&,
0061 BoxPoint const& bottom_right,
0062 Strategies const& strategies) const
0063 {
0064
0065 return geometry::detail::distance::segment_to_box_2D
0066 <
0067 ReturnType,
0068 SegmentPoint,
0069 BoxPoint,
0070 Strategies
0071 >::template call_above_of_box
0072 <
0073 typename LessEqual::other
0074 >(p1, p0, bottom_right, strategies);
0075 }
0076
0077 template <typename SPoint, typename BPoint>
0078 static void mirror(SPoint&,
0079 SPoint&,
0080 BPoint&,
0081 BPoint&,
0082 BPoint&,
0083 BPoint&)
0084 {}
0085 };
0086
0087 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0088 namespace services
0089 {
0090
0091 template <typename CalculationType, typename Strategy>
0092 struct tag<cartesian_segment_box<CalculationType, Strategy> >
0093 {
0094 typedef strategy_tag_distance_segment_box type;
0095 };
0096
0097 template <typename CalculationType, typename Strategy, typename PS, typename PB>
0098 struct return_type<cartesian_segment_box<CalculationType, Strategy>, PS, PB>
0099 : cartesian_segment_box<CalculationType, Strategy>::template calculation_type<PS, PB>
0100 {};
0101
0102 template <typename CalculationType, typename Strategy>
0103 struct comparable_type<cartesian_segment_box<CalculationType, Strategy> >
0104 {
0105
0106
0107 typedef cartesian_segment_box
0108 <
0109 CalculationType,
0110 typename comparable_type<Strategy>::type
0111 > type;
0112 };
0113
0114
0115 template <typename CalculationType, typename Strategy>
0116 struct get_comparable<cartesian_segment_box<CalculationType, Strategy> >
0117 {
0118 typedef typename comparable_type
0119 <
0120 cartesian_segment_box<CalculationType, Strategy>
0121 >::type comparable_type;
0122 public :
0123 static inline comparable_type apply(cartesian_segment_box<CalculationType, Strategy> const& )
0124 {
0125 return comparable_type();
0126 }
0127 };
0128
0129 template <typename CalculationType, typename Strategy, typename PS, typename PB>
0130 struct result_from_distance<cartesian_segment_box<CalculationType, Strategy>, PS, PB>
0131 {
0132 private :
0133 typedef typename return_type<
0134 cartesian_segment_box
0135 <
0136 CalculationType,
0137 Strategy
0138 >,
0139 PS,
0140 PB
0141 >::type return_type;
0142 public :
0143 template <typename T>
0144 static inline return_type apply(cartesian_segment_box<CalculationType,
0145 Strategy> const& ,
0146 T const& value)
0147 {
0148 Strategy s;
0149 return result_from_distance<Strategy, PS, PB>::apply(s, value);
0150 }
0151 };
0152
0153 template <typename Segment, typename Box>
0154 struct default_strategy
0155 <
0156 segment_tag, box_tag, Segment, Box,
0157 cartesian_tag, cartesian_tag
0158 >
0159 {
0160 typedef cartesian_segment_box<> type;
0161 };
0162
0163 template <typename Box, typename Segment>
0164 struct default_strategy
0165 <
0166 box_tag, segment_tag, Box, Segment,
0167 cartesian_tag, cartesian_tag
0168 >
0169 {
0170 typedef typename default_strategy
0171 <
0172 segment_tag, box_tag, Segment, Box,
0173 cartesian_tag, cartesian_tag
0174 >::type type;
0175 };
0176
0177 }
0178 #endif
0179
0180 }}
0181
0182 }}
0183 #endif