Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2013-2021.
0009 // Modifications copyright (c) 2013-2021, Oracle and/or its affiliates.
0010 
0011 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0012 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0013 
0014 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0015 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0016 
0017 // Use, modification and distribution is subject to the Boost Software License,
0018 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0019 // http://www.boost.org/LICENSE_1_0.txt)
0020 
0021 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
0022 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
0023 
0024 
0025 #include <boost/range/size.hpp>
0026 
0027 #include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
0028 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
0029 #include <boost/geometry/algorithms/not_implemented.hpp>
0030 #include <boost/geometry/core/closure.hpp>
0031 #include <boost/geometry/geometries/segment.hpp>
0032 #include <boost/geometry/util/range.hpp>
0033 #include <boost/geometry/views/closeable_view.hpp>
0034 
0035 
0036 namespace boost { namespace geometry
0037 {
0038 
0039 
0040 #ifndef DOXYGEN_NO_DETAIL
0041 namespace detail { namespace disjoint
0042 {
0043 
0044 
0045 template
0046 <
0047     typename SegmentOrBox,
0048     typename Tag = typename tag<SegmentOrBox>::type
0049 >
0050 struct disjoint_point_segment_or_box
0051     : not_implemented<Tag>
0052 {};
0053 
0054 template <typename Segment>
0055 struct disjoint_point_segment_or_box<Segment, segment_tag>
0056 {
0057     template <typename Point, typename Strategy>
0058     static inline bool apply(Point const& point, Segment const& segment, Strategy const& strategy)
0059     {
0060         return dispatch::disjoint
0061             <
0062                 Point, Segment
0063             >::apply(point, segment, strategy);
0064     }
0065 };
0066 
0067 template <typename Box>
0068 struct disjoint_point_segment_or_box<Box, box_tag>
0069 {
0070     template <typename Point, typename Strategy>
0071     static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
0072     {
0073         return dispatch::disjoint
0074             <
0075                 Point, Box
0076             >::apply(point, box, strategy);
0077     }
0078 };
0079 
0080 
0081 template <typename Range, typename SegmentOrBox>
0082 struct disjoint_range_segment_or_box
0083 {
0084     template <typename Strategy>
0085     static inline bool apply(Range const& range,
0086                              SegmentOrBox const& segment_or_box,
0087                              Strategy const& strategy)
0088     {
0089         using point_type = typename point_type<Range>::type;
0090         using range_segment = typename geometry::model::referring_segment<point_type const>;
0091 
0092         detail::closed_view<Range const> const view(range);
0093 
0094         auto const count = ::boost::size(view);
0095 
0096         if ( count == 0 )
0097         {
0098             return false;
0099         }
0100         else if ( count == 1 )
0101         {
0102             return disjoint_point_segment_or_box
0103                 <
0104                     SegmentOrBox
0105                 >::apply(range::front(view), segment_or_box, strategy);
0106         }
0107         else
0108         {
0109             auto it0 = ::boost::begin(view);
0110             auto it1 = ::boost::begin(view) + 1;
0111             auto const last = ::boost::end(view);
0112 
0113             for ( ; it1 != last ; ++it0, ++it1 )
0114             {
0115                 point_type const& p0 = *it0;
0116                 point_type const& p1 = *it1;
0117                 range_segment rng_segment(p0, p1);
0118                 if ( !dispatch::disjoint
0119                          <
0120                              range_segment, SegmentOrBox
0121                          >::apply(rng_segment, segment_or_box, strategy) )
0122                 {
0123                     return false;
0124                 }
0125             }
0126             return true;
0127         }
0128     }
0129 };
0130 
0131 
0132 
0133 
0134 template
0135 <
0136     typename Linear,
0137     typename SegmentOrBox,
0138     typename Tag = typename tag<Linear>::type
0139 >
0140 struct disjoint_linear_segment_or_box
0141     : not_implemented<Linear, SegmentOrBox>
0142 {};
0143 
0144 
0145 template <typename Linestring, typename SegmentOrBox>
0146 struct disjoint_linear_segment_or_box<Linestring, SegmentOrBox, linestring_tag>
0147     : disjoint_range_segment_or_box<Linestring, SegmentOrBox>
0148 {};
0149 
0150 
0151 template <typename MultiLinestring, typename SegmentOrBox>
0152 struct disjoint_linear_segment_or_box
0153     <
0154         MultiLinestring, SegmentOrBox, multi_linestring_tag
0155     > : multirange_constant_size_geometry<MultiLinestring, SegmentOrBox>
0156 {};
0157 
0158 
0159 }} // namespace detail::disjoint
0160 #endif // DOXYGEN_NO_DETAIL
0161 
0162 
0163 #ifndef DOXYGEN_NO_DISPATCH
0164 namespace dispatch
0165 {
0166 
0167 
0168 template <typename Linear, typename Segment>
0169 struct disjoint<Linear, Segment, 2, linear_tag, segment_tag, false>
0170     : detail::disjoint::disjoint_linear_segment_or_box<Linear, Segment>
0171 {};
0172 
0173 
0174 template <typename Linear, typename Box, std::size_t DimensionCount>
0175 struct disjoint<Linear, Box, DimensionCount, linear_tag, box_tag, false>
0176     : detail::disjoint::disjoint_linear_segment_or_box<Linear, Box>
0177 {};
0178 
0179 
0180 } // namespace dispatch
0181 #endif // DOXYGEN_NO_DISPATCH
0182 
0183 
0184 }} // namespace boost::geometry
0185 
0186 
0187 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP