Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:04

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2018-2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_BOX_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_BOX_HPP
0013 
0014 #include <iterator>
0015 
0016 #include <boost/geometry/algorithms/intersects.hpp>
0017 #include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp>
0018 #include <boost/geometry/algorithms/dispatch/distance.hpp>
0019 
0020 #include <boost/geometry/iterators/segment_iterator.hpp>
0021 
0022 #include <boost/geometry/core/point_type.hpp>
0023 
0024 
0025 namespace boost { namespace geometry
0026 {
0027 
0028 #ifndef DOXYGEN_NO_DETAIL
0029 namespace detail { namespace distance
0030 {
0031 
0032 template <typename Linear, typename Box, typename Strategies>
0033 struct linear_to_box
0034 {
0035     typedef distance::return_t<Linear, Box, Strategies> return_type;
0036 
0037     template <typename Iterator>
0038     static inline return_type apply(Box const& box,
0039                                     Iterator begin,
0040                                     Iterator end,
0041                                     Strategies const& strategies)
0042     {
0043         bool first = true;
0044         return_type d_min(0);
0045         for (Iterator it = begin; it != end; ++it, first = false)
0046         {
0047             typedef typename std::iterator_traits<Iterator>::value_type
0048                     Segment;
0049 
0050             return_type d = dispatch::distance<Segment, Box, Strategies>
0051                                     ::apply(*it, box, strategies);
0052 
0053             if ( first || d < d_min )
0054             {
0055                 d_min = d;
0056             }
0057         }
0058         return d_min;
0059     }
0060 
0061     static inline return_type apply(Linear const& linear,
0062                                     Box const& box,
0063                                     Strategies const& strategies)
0064     {
0065         if ( geometry::intersects(linear, box) )
0066         {
0067             return return_type(0);
0068         }
0069 
0070         return apply(box,
0071                      geometry::segments_begin(linear),
0072                      geometry::segments_end(linear),
0073                      strategies);
0074     }
0075 
0076 
0077     static inline return_type apply(Box const& box,
0078                                     Linear const& linear,
0079                                     Strategies const& strategies)
0080     {
0081         return apply(linear, box, strategies);
0082     }
0083 };
0084 
0085 }} // namespace detail::distance
0086 #endif // DOXYGEN_NO_DETAIL
0087 
0088 
0089 #ifndef DOXYGEN_NO_DISPATCH
0090 namespace dispatch
0091 {
0092 
0093 template <typename Linear, typename Box, typename Strategy>
0094 struct distance
0095     <
0096         Linear, Box, Strategy,
0097         linear_tag, box_tag,
0098         strategy_tag_distance_segment_box, false
0099     >
0100     : detail::distance::linear_to_box
0101         <
0102             Linear, Box, Strategy
0103         >
0104 {};
0105 
0106 
0107 template <typename Areal, typename Box, typename Strategy>
0108 struct distance
0109     <
0110         Areal, Box, Strategy,
0111         areal_tag, box_tag,
0112         strategy_tag_distance_segment_box, false
0113     >
0114     : detail::distance::linear_to_box
0115         <
0116             Areal, Box, Strategy
0117         >
0118 {};
0119 
0120 
0121 } // namespace dispatch
0122 #endif // DOXYGEN_NO_DISPATCH
0123 
0124 }} // namespace boost::geometry
0125 
0126 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_TO_BOX_HPP