diff options
Diffstat (limited to 'boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp')
-rw-r--r-- | boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp b/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp index 220a67bcd1..ecbc4782b2 100644 --- a/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp +++ b/boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -10,6 +10,11 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP +#include <vector> + +#include <boost/assert.hpp> +#include <boost/range.hpp> + #include <boost/geometry/core/point_type.hpp> #include <boost/geometry/policies/predicate_based_interrupt_policy.hpp> @@ -22,7 +27,6 @@ #include <boost/geometry/algorithms/detail/is_valid/is_acceptable_turn.hpp> - namespace boost { namespace geometry { @@ -64,8 +68,10 @@ public: > turn_type; // returns true if all turns are valid - template <typename Turns> - static inline bool apply(Geometry const& geometry, Turns& turns) + template <typename Turns, typename VisitPolicy> + static inline bool apply(Geometry const& geometry, + Turns& turns, + VisitPolicy& visitor) { rescale_policy_type robust_policy = geometry::get_rescale_policy<rescale_policy_type>(geometry); @@ -80,7 +86,23 @@ public: turns, interrupt_policy); - return !interrupt_policy.has_intersections; + if (interrupt_policy.has_intersections) + { + BOOST_ASSERT(! boost::empty(turns)); + return visitor.template apply<failure_self_intersections>(turns); + } + else + { + return visitor.template apply<no_failure>(); + } + } + + // returns true if all turns are valid + template <typename VisitPolicy> + static inline bool apply(Geometry const& geometry, VisitPolicy& visitor) + { + std::vector<turn_type> turns; + return apply(geometry, turns, visitor); } }; |