1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 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_POLICIES_IS_VALID_FAILURE_TYPE_POLICY_HPP
11 #define BOOST_GEOMETRY_POLICIES_IS_VALID_FAILURE_TYPE_POLICY_HPP
13 #include <boost/geometry/algorithms/validity_failure_type.hpp>
16 namespace boost { namespace geometry
20 // policy that simply keeps (and can return) the failure type
21 template <bool AllowDuplicates = true, bool AllowSpikes = true>
22 class failure_type_policy
26 validity_failure_type transform_failure_type(validity_failure_type failure)
28 if (AllowDuplicates && failure == failure_duplicate_points)
36 validity_failure_type transform_failure_type(validity_failure_type failure,
39 if (is_linear && AllowSpikes && failure == failure_spikes)
43 return transform_failure_type(failure);
48 : m_failure(no_failure)
51 template <validity_failure_type Failure>
54 m_failure = transform_failure_type(Failure);
55 return m_failure == no_failure;
58 template <validity_failure_type Failure, typename Data>
59 inline bool apply(Data const&)
61 return apply<Failure>();
64 template <validity_failure_type Failure, typename Data1, typename Data2>
65 inline bool apply(Data1 const& data1, Data2 const&)
67 m_failure = transform_failure_type(Failure, data1);
68 return m_failure == no_failure;
71 validity_failure_type failure() const
77 validity_failure_type m_failure;
81 }} // namespace boost::geometry
83 #endif // BOOST_GEOMETRY_POLICIES_IS_VALID_FAILURE_TYPE_POLICY_HPP