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-2017.
9 // Modifications copyright (c) 2013-2017, 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_LINEAR_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP
27 #include <boost/range.hpp>
28 #include <boost/geometry/util/range.hpp>
30 #include <boost/geometry/core/point_type.hpp>
31 #include <boost/geometry/core/tag.hpp>
32 #include <boost/geometry/core/tags.hpp>
34 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
35 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
36 #include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
38 #include <boost/geometry/policies/disjoint_interrupt_policy.hpp>
39 #include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
40 #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
42 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
45 namespace boost { namespace geometry
49 #ifndef DOXYGEN_NO_DETAIL
50 namespace detail { namespace disjoint
53 template <typename Segment1, typename Segment2>
54 struct disjoint_segment
56 template <typename Strategy>
57 static inline bool apply(Segment1 const& segment1, Segment2 const& segment2,
58 Strategy const& strategy)
60 typedef typename point_type<Segment1>::type point_type;
62 // We don't need to rescale to detect disjointness
63 typedef no_rescale_policy rescale_policy_type;
64 rescale_policy_type robust_policy;
66 typedef segment_intersection_points
69 typename segment_ratio_type
74 > intersection_return_type;
76 typedef policies::relate::segments_intersection_points
78 intersection_return_type
79 > intersection_policy;
81 intersection_return_type is = strategy.apply(segment1, segment2,
82 intersection_policy(),
90 struct assign_disjoint_policy
92 // We want to include all points:
93 static bool const include_no_turn = true;
94 static bool const include_degenerate = true;
95 static bool const include_opposite = true;
97 // We don't assign extra info:
103 typename IntersectionInfo
105 static inline void apply(Info& , Point1 const& , Point2 const&,
106 IntersectionInfo const&)
111 template <typename Geometry1, typename Geometry2>
112 struct disjoint_linear
114 template <typename Strategy>
115 static inline bool apply(Geometry1 const& geometry1,
116 Geometry2 const& geometry2,
117 Strategy const& strategy)
119 typedef typename geometry::point_type<Geometry1>::type point_type;
120 typedef detail::no_rescale_policy rescale_policy_type;
121 typedef typename geometry::segment_ratio_type
123 point_type, rescale_policy_type
124 >::type segment_ratio_type;
125 typedef overlay::turn_info
129 typename detail::get_turns::turn_operation_type
131 Geometry1, Geometry2, segment_ratio_type
135 std::deque<turn_info_type> turns;
137 // Specify two policies:
138 // 1) Stop at any intersection
139 // 2) In assignment, include also degenerate points (which are normally skipped)
140 disjoint_interrupt_policy interrupt_policy;
143 typename geometry::tag<Geometry1>::type,
144 typename geometry::tag<Geometry2>::type,
147 overlay::do_reverse<geometry::point_order<Geometry1>::value>::value, // should be false
148 overlay::do_reverse<geometry::point_order<Geometry2>::value>::value, // should be false
149 detail::get_turns::get_turn_info_type
151 Geometry1, Geometry2, assign_disjoint_policy
153 >::apply(0, geometry1, 1, geometry2,
154 strategy, rescale_policy_type(), turns, interrupt_policy);
156 return !interrupt_policy.has_intersections;
161 }} // namespace detail::disjoint
162 #endif // DOXYGEN_NO_DETAIL
167 #ifndef DOXYGEN_NO_DISPATCH
172 template <typename Linear1, typename Linear2>
173 struct disjoint<Linear1, Linear2, 2, linear_tag, linear_tag, false>
174 : detail::disjoint::disjoint_linear<Linear1, Linear2>
178 template <typename Segment1, typename Segment2>
179 struct disjoint<Segment1, Segment2, 2, segment_tag, segment_tag, false>
180 : detail::disjoint::disjoint_segment<Segment1, Segment2>
184 } // namespace dispatch
185 #endif // DOXYGEN_NO_DISPATCH
188 }} // namespace boost::geometry
191 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_LINEAR_HPP