Chris@102: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@102: Chris@102: // Copyright (c) 2014, Oracle and/or its affiliates. Chris@102: Chris@102: // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle Chris@102: Chris@102: // Licensed under the Boost Software License version 1.0. Chris@102: // http://www.boost.org/users/license.html Chris@102: Chris@102: #ifndef BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP Chris@102: #define BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP Chris@102: Chris@102: #include Chris@102: Chris@102: #include Chris@102: Chris@102: Chris@102: namespace boost { namespace geometry Chris@102: { Chris@102: Chris@102: Chris@102: #ifndef DOXYGEN_NO_DETAIL Chris@102: namespace detail { namespace overlay Chris@102: { Chris@102: Chris@102: Chris@102: template Chris@102: < Chris@102: typename IsAcceptableTurnPredicate, Chris@102: bool AllowEmptyTurnRange = true // by default, allow an empty turn range Chris@102: > Chris@102: struct stateless_predicate_based_interrupt_policy Chris@102: { Chris@102: static bool const enabled = true; Chris@102: bool has_intersections; // set to true if there is at least one Chris@102: // unacceptable turn Chris@102: Chris@102: inline stateless_predicate_based_interrupt_policy() Chris@102: : has_intersections(false) Chris@102: {} Chris@102: Chris@102: template Chris@102: inline bool apply(Range const& range) Chris@102: { Chris@102: // if there is at least one unacceptable turn in the range, return false Chris@102: has_intersections = !detail::check_iterator_range Chris@102: < Chris@102: IsAcceptableTurnPredicate, Chris@102: AllowEmptyTurnRange Chris@102: >::apply(boost::begin(range), boost::end(range)); Chris@102: Chris@102: return has_intersections; Chris@102: } Chris@102: }; Chris@102: Chris@102: Chris@102: Chris@102: Chris@102: template Chris@102: < Chris@102: typename IsAcceptableTurnPredicate, Chris@102: bool AllowEmptyTurnRange = true // by default, allow an empty turn range Chris@102: > Chris@102: struct predicate_based_interrupt_policy Chris@102: { Chris@102: static bool const enabled = true; Chris@102: bool has_intersections; // set to true if there is at least one Chris@102: // unacceptable turn Chris@102: IsAcceptableTurnPredicate const& m_predicate; Chris@102: Chris@102: inline Chris@102: predicate_based_interrupt_policy(IsAcceptableTurnPredicate const& predicate) Chris@102: : has_intersections(false) Chris@102: , m_predicate(predicate) Chris@102: {} Chris@102: Chris@102: template Chris@102: inline bool apply(Range const& range) Chris@102: { Chris@102: // if there is at least one unacceptable turn in the range, return false Chris@102: has_intersections = !detail::check_iterator_range Chris@102: < Chris@102: IsAcceptableTurnPredicate, Chris@102: AllowEmptyTurnRange Chris@102: >::apply(boost::begin(range), boost::end(range), m_predicate); Chris@102: Chris@102: return has_intersections; Chris@102: } Chris@102: }; Chris@102: Chris@102: Chris@102: Chris@102: Chris@102: }} // namespace detail::overlay Chris@102: #endif // DOXYGEN_NO_DETAIL Chris@102: Chris@102: Chris@102: }} // namespace boost::geometry Chris@102: Chris@102: Chris@102: #endif // BOOST_GEOMETRY_ALGORITHMS_POLICIES_PREDICATE_BASED_INTERRUPT_POLICY_HPP