Project revived from Feb2017
[EroSomnia.git] / deps / boost_1_63_0 / boost / geometry / algorithms / detail / is_valid / has_valid_self_turns.hpp
blob0a8121374369816a04ee33699f4bb92800d02b22
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
13 #include <vector>
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
40 template
42 typename Geometry,
43 typename IsAcceptableTurn = is_acceptable_turn<Geometry>
45 class has_valid_self_turns
47 private:
48 typedef typename point_type<Geometry>::type point_type;
50 typedef typename geometry::rescale_policy_type
52 point_type
53 >::type rescale_policy_type;
55 typedef detail::overlay::get_turn_info
57 detail::overlay::assign_null_policy
58 > turn_policy;
60 public:
61 typedef detail::overlay::turn_info
63 point_type,
64 typename geometry::segment_ratio_type
66 point_type,
67 rescale_policy_type
68 >::type
69 > turn_type;
71 // returns true if all turns are valid
72 template <typename Turns, typename VisitPolicy>
73 static inline bool apply(Geometry const& geometry,
74 Turns& turns,
75 VisitPolicy& visitor)
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
84 IsAcceptableTurn
85 > interrupt_policy;
87 geometry::self_turns<turn_policy>(geometry,
88 robust_policy,
89 turns,
90 interrupt_policy);
92 if (interrupt_policy.has_intersections)
94 BOOST_GEOMETRY_ASSERT(! boost::empty(turns));
95 return visitor.template apply<failure_self_intersections>(turns);
97 else
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