traverse.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Use, modification and distribution is subject to the Boost Software License,
  4. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
  7. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
  8. #include <cstddef>
  9. #include <boost/range/size.hpp>
  10. #include <boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
  11. #include <boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp>
  12. #include <boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. #ifndef DOXYGEN_NO_DETAIL
  16. namespace detail { namespace overlay
  17. {
  18. /*!
  19. \brief Traverses through intersection points / geometries
  20. \ingroup overlay
  21. */
  22. template
  23. <
  24. bool Reverse1, bool Reverse2,
  25. typename Geometry1,
  26. typename Geometry2,
  27. overlay_type OverlayType,
  28. typename Backtrack = backtrack_check_self_intersections<Geometry1, Geometry2>
  29. >
  30. class traverse
  31. {
  32. template <typename Turns>
  33. static void reset_visits(Turns& turns)
  34. {
  35. for (auto& turn : turns)
  36. {
  37. for (auto& op : turn.operations)
  38. {
  39. op.visited.reset();
  40. }
  41. }
  42. }
  43. public :
  44. template
  45. <
  46. typename IntersectionStrategy,
  47. typename RobustPolicy,
  48. typename Turns,
  49. typename Rings,
  50. typename TurnInfoMap,
  51. typename Clusters,
  52. typename Visitor
  53. >
  54. static inline void apply(Geometry1 const& geometry1,
  55. Geometry2 const& geometry2,
  56. IntersectionStrategy const& intersection_strategy,
  57. RobustPolicy const& robust_policy,
  58. Turns& turns, Rings& rings,
  59. TurnInfoMap& turn_info_map,
  60. Clusters& clusters,
  61. Visitor& visitor)
  62. {
  63. traversal_switch_detector
  64. <
  65. Reverse1, Reverse2, OverlayType,
  66. Geometry1, Geometry2,
  67. Turns, Clusters,
  68. RobustPolicy, Visitor
  69. > switch_detector(geometry1, geometry2, turns, clusters,
  70. robust_policy, visitor);
  71. switch_detector.iterate();
  72. reset_visits(turns);
  73. traversal_ring_creator
  74. <
  75. Reverse1, Reverse2, OverlayType,
  76. Geometry1, Geometry2,
  77. Turns, TurnInfoMap, Clusters,
  78. IntersectionStrategy,
  79. RobustPolicy, Visitor,
  80. Backtrack
  81. > trav(geometry1, geometry2, turns, turn_info_map, clusters,
  82. intersection_strategy, robust_policy, visitor);
  83. std::size_t finalized_ring_size = boost::size(rings);
  84. typename Backtrack::state_type state;
  85. trav.iterate(rings, finalized_ring_size, state);
  86. }
  87. };
  88. }} // namespace detail::overlay
  89. #endif // DOXYGEN_NO_DETAIL
  90. }} // namespace boost::geometry
  91. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP