Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:07

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP
0013 
0014 #include <vector>
0015 
0016 #include <boost/core/ignore_unused.hpp>
0017 #include <boost/range/empty.hpp>
0018 
0019 #include <boost/geometry/algorithms/detail/is_valid/is_acceptable_turn.hpp>
0020 #include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
0021 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
0022 #include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
0023 #include <boost/geometry/algorithms/validity_failure_type.hpp>
0024 
0025 #include <boost/geometry/core/assert.hpp>
0026 #include <boost/geometry/core/point_type.hpp>
0027 
0028 #include <boost/geometry/policies/predicate_based_interrupt_policy.hpp>
0029 #include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
0030 #include <boost/geometry/policies/robustness/get_rescale_policy.hpp>
0031 
0032 namespace boost { namespace geometry
0033 {
0034 
0035 
0036 #ifndef DOXYGEN_NO_DETAIL
0037 namespace detail { namespace is_valid
0038 {
0039 
0040 
0041 template
0042 <
0043     typename Geometry,
0044     typename CSTag // TODO: remove
0045 >
0046 class has_valid_self_turns
0047 {
0048 private:
0049     typedef typename point_type<Geometry>::type point_type;
0050 
0051     typedef typename geometry::rescale_policy_type
0052         <
0053             point_type,
0054             CSTag
0055         >::type rescale_policy_type;
0056 
0057 public:
0058     typedef detail::overlay::turn_info
0059         <
0060             point_type,
0061             typename segment_ratio_type
0062                 <
0063                     point_type,
0064                     rescale_policy_type
0065                 >::type
0066         > turn_type;
0067 
0068     // returns true if all turns are valid
0069     template <typename Turns, typename VisitPolicy, typename Strategy>
0070     static inline bool apply(Geometry const& geometry,
0071                              Turns& turns,
0072                              VisitPolicy& visitor,
0073                              Strategy const& strategy)
0074     {
0075         boost::ignore_unused(visitor);
0076 
0077         rescale_policy_type robust_policy
0078             = geometry::get_rescale_policy<rescale_policy_type>(geometry, strategy);
0079 
0080         detail::overlay::stateless_predicate_based_interrupt_policy
0081             <
0082                 is_acceptable_turn<Geometry>
0083             > interrupt_policy;
0084 
0085         // Calculate self-turns, skipping adjacent segments
0086         detail::self_get_turn_points::self_turns
0087             <
0088                 false, detail::overlay::assign_null_policy
0089             >(geometry, strategy, robust_policy, turns, interrupt_policy,
0090               0, true);
0091 
0092         if (interrupt_policy.has_intersections)
0093         {
0094             BOOST_GEOMETRY_ASSERT(! boost::empty(turns));
0095             return visitor.template apply<failure_self_intersections>(turns);
0096         }
0097         else
0098         {
0099             return visitor.template apply<no_failure>();
0100         }
0101     }
0102 
0103     // returns true if all turns are valid
0104     template <typename VisitPolicy, typename Strategy>
0105     static inline bool apply(Geometry const& geometry, VisitPolicy& visitor, Strategy const& strategy)
0106     {
0107         std::vector<turn_type> turns;
0108         return apply(geometry, turns, visitor, strategy);
0109     }
0110 };
0111 
0112 
0113 }} // namespace detail::is_valid
0114 #endif // DOXYGEN_NO_DETAIL
0115 
0116 }} // namespace boost::geometry
0117 
0118 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_VALID_SELF_TURNS_HPP