1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2018-2019 Oracle and/or its affiliates.
4 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP
14 #include <boost/geometry/algorithms/detail/distance/segment_to_box.hpp>
16 #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
17 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
18 #include <boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp>
19 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
20 #include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
22 namespace boost { namespace geometry
26 namespace strategy { namespace distance
31 typename CalculationType = void,
32 typename Strategy = pythagoras<CalculationType>
34 struct cartesian_segment_box
36 template <typename PointOfSegment, typename PointOfBox>
37 struct calculation_type
38 : promote_floating_point
40 typename strategy::distance::services::return_type
49 typedef cartesian_tag cs_tag;
51 // point-point strategy getters
52 struct distance_pp_strategy
54 typedef Strategy type;
57 inline typename distance_pp_strategy::type get_distance_pp_strategy() const
59 return typename distance_pp_strategy::type();
61 // point-segment strategy getters
62 struct distance_ps_strategy
64 typedef projected_point<CalculationType, Strategy> type;
67 inline typename distance_ps_strategy::type get_distance_ps_strategy() const
69 return typename distance_ps_strategy::type();
72 struct distance_pb_strategy
74 typedef pythagoras_point_box<CalculationType> type;
77 inline typename distance_pb_strategy::type get_distance_pb_strategy() const
79 return typename distance_pb_strategy::type();
82 typedef side::side_by_triangle<CalculationType> side_strategy_type;
84 static inline side_strategy_type get_side_strategy()
86 return side_strategy_type();
89 typedef within::cartesian_point_point equals_point_point_strategy_type;
91 static inline equals_point_point_strategy_type get_equals_point_point_strategy()
93 return equals_point_point_strategy_type();
96 template <typename LessEqual, typename ReturnType,
97 typename SegmentPoint, typename BoxPoint>
98 inline ReturnType segment_below_of_box(SegmentPoint const& p0,
99 SegmentPoint const& p1,
103 BoxPoint const& bottom_right) const
107 return geometry::detail::distance::segment_to_box_2D
112 cartesian_segment_box<CalculationType, Strategy>
113 >::template call_above_of_box
115 typename LessEqual::other
116 >(p1, p0, bottom_right, *this);
119 template <typename SPoint, typename BPoint>
120 static void mirror(SPoint&,
129 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
133 template <typename CalculationType, typename Strategy>
134 struct tag<cartesian_segment_box<CalculationType, Strategy> >
136 typedef strategy_tag_distance_segment_box type;
139 template <typename CalculationType, typename Strategy, typename PS, typename PB>
140 struct return_type<cartesian_segment_box<CalculationType, Strategy>, PS, PB>
141 : cartesian_segment_box<CalculationType, Strategy>::template calculation_type<PS, PB>
144 template <typename CalculationType, typename Strategy>
145 struct comparable_type<cartesian_segment_box<CalculationType, Strategy> >
147 // Define a cartesian_segment_box strategy with its underlying point-point
148 // strategy being comparable
149 typedef cartesian_segment_box
152 typename comparable_type<Strategy>::type
157 template <typename CalculationType, typename Strategy>
158 struct get_comparable<cartesian_segment_box<CalculationType, Strategy> >
160 typedef typename comparable_type
162 cartesian_segment_box<CalculationType, Strategy>
163 >::type comparable_type;
165 static inline comparable_type apply(cartesian_segment_box<CalculationType, Strategy> const& )
167 return comparable_type();
171 template <typename CalculationType, typename Strategy, typename PS, typename PB>
172 struct result_from_distance<cartesian_segment_box<CalculationType, Strategy>, PS, PB>
175 typedef typename return_type<
176 cartesian_segment_box
185 template <typename T>
186 static inline return_type apply(cartesian_segment_box<CalculationType,
191 return result_from_distance<Strategy, PS, PB>::apply(s, value);
195 template <typename Segment, typename Box>
196 struct default_strategy
198 segment_tag, box_tag, Segment, Box,
199 cartesian_tag, cartesian_tag
202 typedef cartesian_segment_box<> type;
205 template <typename Box, typename Segment>
206 struct default_strategy
208 box_tag, segment_tag, Box, Segment,
209 cartesian_tag, cartesian_tag
212 typedef typename default_strategy
214 segment_tag, box_tag, Segment, Box,
215 cartesian_tag, cartesian_tag
222 }} // namespace strategy::distance
224 }} // namespace boost::geometry
225 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_SEGMENT_BOX_HPP