traverse.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
  10. #include <boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp>
  11. #include <boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. #ifndef DOXYGEN_NO_DETAIL
  15. namespace detail { namespace overlay
  16. {
  17. /*!
  18. \brief Traverses through intersection points / geometries
  19. \ingroup overlay
  20. */
  21. template
  22. <
  23. bool Reverse1, bool Reverse2,
  24. typename Geometry1,
  25. typename Geometry2,
  26. overlay_type OverlayType,
  27. typename Backtrack = backtrack_check_self_intersections<Geometry1, Geometry2>
  28. >
  29. class traverse
  30. {
  31. template <typename Turns>
  32. static void reset_visits(Turns& turns)
  33. {
  34. for (typename boost::range_iterator<Turns>::type
  35. it = boost::begin(turns);
  36. it != boost::end(turns);
  37. ++it)
  38. {
  39. for (int i = 0; i < 2; i++)
  40. {
  41. it->operations[i].visited.reset();
  42. }
  43. }
  44. }
  45. public :
  46. template
  47. <
  48. typename IntersectionStrategy,
  49. typename RobustPolicy,
  50. typename Turns,
  51. typename Rings,
  52. typename TurnInfoMap,
  53. typename Clusters,
  54. typename Visitor
  55. >
  56. static inline void apply(Geometry1 const& geometry1,
  57. Geometry2 const& geometry2,
  58. IntersectionStrategy const& intersection_strategy,
  59. RobustPolicy const& robust_policy,
  60. Turns& turns, Rings& rings,
  61. TurnInfoMap& turn_info_map,
  62. Clusters& clusters,
  63. Visitor& visitor)
  64. {
  65. traversal_switch_detector
  66. <
  67. Reverse1, Reverse2, OverlayType,
  68. Geometry1, Geometry2,
  69. Turns, Clusters,
  70. RobustPolicy, Visitor
  71. > switch_detector(geometry1, geometry2, turns, clusters,
  72. robust_policy, visitor);
  73. switch_detector.iterate();
  74. reset_visits(turns);
  75. traversal_ring_creator
  76. <
  77. Reverse1, Reverse2, OverlayType,
  78. Geometry1, Geometry2,
  79. Turns, TurnInfoMap, Clusters,
  80. IntersectionStrategy,
  81. RobustPolicy, Visitor,
  82. Backtrack
  83. > trav(geometry1, geometry2, turns, turn_info_map, clusters,
  84. intersection_strategy, robust_policy, visitor);
  85. std::size_t finalized_ring_size = boost::size(rings);
  86. typename Backtrack::state_type state;
  87. trav.iterate(rings, finalized_ring_size, state);
  88. }
  89. };
  90. }} // namespace detail::overlay
  91. #endif // DOXYGEN_NO_DETAIL
  92. }} // namespace boost::geometry
  93. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP