1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
6 // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
8 // This file was modified by Oracle on 2013-2014.
9 // Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
17 // Use, modification and distribution is subject to the Boost Software License,
18 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
21 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
24 #include <boost/range.hpp>
25 #include <boost/geometry/util/range.hpp>
27 #include <boost/geometry/core/closure.hpp>
29 #include <boost/geometry/geometries/segment.hpp>
31 #include <boost/geometry/algorithms/not_implemented.hpp>
33 #include <boost/geometry/views/closeable_view.hpp>
35 #include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
36 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
39 namespace boost { namespace geometry
43 #ifndef DOXYGEN_NO_DETAIL
44 namespace detail { namespace disjoint
51 closure_selector Closure,
54 struct disjoint_range_segment_or_box
56 template <typename Strategy>
57 static inline bool apply(Range const& range,
58 SegmentOrBox const& segment_or_box,
59 Strategy const& strategy)
61 typedef typename closeable_view<Range const, Closure>::type view_type;
63 typedef typename ::boost::range_value<view_type>::type point_type;
64 typedef typename ::boost::range_iterator
67 >::type const_iterator;
69 typedef typename ::boost::range_size<view_type>::type size_type;
71 typedef typename geometry::model::referring_segment
76 view_type view(range);
78 const size_type count = ::boost::size(view);
84 else if ( count == 1 )
86 return dispatch::disjoint
88 point_type, SegmentOrBox
89 >::apply(geometry::range::front<view_type const>(view),
91 strategy.template get_point_in_geometry_strategy<Range, SegmentOrBox>());
95 const_iterator it0 = ::boost::begin(view);
96 const_iterator it1 = ::boost::begin(view) + 1;
97 const_iterator last = ::boost::end(view);
99 for ( ; it1 != last ; ++it0, ++it1 )
101 range_segment rng_segment(*it0, *it1);
102 if ( !dispatch::disjoint
104 range_segment, SegmentOrBox
105 >::apply(rng_segment, segment_or_box, strategy) )
121 typename SegmentOrBox,
122 typename Tag = typename tag<Linear>::type
124 struct disjoint_linear_segment_or_box
125 : not_implemented<Linear, SegmentOrBox>
129 template <typename Linestring, typename SegmentOrBox>
130 struct disjoint_linear_segment_or_box<Linestring, SegmentOrBox, linestring_tag>
131 : disjoint_range_segment_or_box<Linestring, closed, SegmentOrBox>
135 template <typename MultiLinestring, typename SegmentOrBox>
136 struct disjoint_linear_segment_or_box
138 MultiLinestring, SegmentOrBox, multi_linestring_tag
139 > : multirange_constant_size_geometry<MultiLinestring, SegmentOrBox>
143 }} // namespace detail::disjoint
144 #endif // DOXYGEN_NO_DETAIL
147 #ifndef DOXYGEN_NO_DISPATCH
152 template <typename Linear, typename Segment>
153 struct disjoint<Linear, Segment, 2, linear_tag, segment_tag, false>
154 : detail::disjoint::disjoint_linear_segment_or_box<Linear, Segment>
158 template <typename Linear, typename Box, std::size_t DimensionCount>
159 struct disjoint<Linear, Box, DimensionCount, linear_tag, box_tag, false>
160 : detail::disjoint::disjoint_linear_segment_or_box<Linear, Box>
164 } // namespace dispatch
165 #endif // DOXYGEN_NO_DISPATCH
168 }} // namespace boost::geometry
171 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP