1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014-2015, Oracle and/or its affiliates.
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP
15 #include <boost/core/ignore_unused.hpp>
16 #include <boost/range.hpp>
18 #include <boost/geometry/core/assert.hpp>
19 #include <boost/geometry/core/point_type.hpp>
21 #include <boost/geometry/policies/predicate_based_interrupt_policy.hpp>
22 #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
23 #include <boost/geometry/policies/robustness/get_rescale_policy.hpp>
25 #include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
26 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
27 #include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
29 #include <boost/geometry/algorithms/detail/is_valid/is_acceptable_turn.hpp>
31 namespace boost
{ namespace geometry
35 #ifndef DOXYGEN_NO_DETAIL
36 namespace detail
{ namespace is_valid
43 typename IsAcceptableTurn
= is_acceptable_turn
<Geometry
>
45 class has_valid_self_turns
48 typedef typename point_type
<Geometry
>::type point_type
;
50 typedef typename
geometry::rescale_policy_type
53 >::type rescale_policy_type
;
55 typedef detail::overlay::get_turn_info
57 detail::overlay::assign_null_policy
61 typedef detail::overlay::turn_info
64 typename
geometry::segment_ratio_type
71 // returns true if all turns are valid
72 template <typename Turns
, typename VisitPolicy
>
73 static inline bool apply(Geometry
const& geometry
,
77 boost::ignore_unused(visitor
);
79 rescale_policy_type robust_policy
80 = geometry::get_rescale_policy
<rescale_policy_type
>(geometry
);
82 detail::overlay::stateless_predicate_based_interrupt_policy
87 geometry::self_turns
<turn_policy
>(geometry
,
92 if (interrupt_policy
.has_intersections
)
94 BOOST_GEOMETRY_ASSERT(! boost::empty(turns
));
95 return visitor
.template apply
<failure_self_intersections
>(turns
);
99 return visitor
.template apply
<no_failure
>();
103 // returns true if all turns are valid
104 template <typename VisitPolicy
>
105 static inline bool apply(Geometry
const& geometry
, VisitPolicy
& visitor
)
107 std::vector
<turn_type
> turns
;
108 return apply(geometry
, turns
, visitor
);
113 }} // namespace detail::is_valid
114 #endif // DOXYGEN_NO_DETAIL
116 }} // namespace boost::geometry
118 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP