get_intersection_points.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2017-2020.
  4. // Modifications copyright (c) 2017-2020 Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
  10. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
  11. #include <cstddef>
  12. #include <type_traits>
  13. #include <boost/range/value_type.hpp>
  14. #include <boost/geometry/algorithms/convert.hpp>
  15. #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
  16. #include <boost/geometry/policies/robustness/rescale_policy_tags.hpp>
  17. #include <boost/geometry/geometries/segment.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. #ifndef DOXYGEN_NO_DETAIL
  21. namespace detail { namespace get_intersection_points
  22. {
  23. template
  24. <
  25. typename Point1,
  26. typename Point2,
  27. typename TurnInfo
  28. >
  29. struct get_turn_without_info
  30. {
  31. template
  32. <
  33. typename UniqueSubRange1,
  34. typename UniqueSubRange2,
  35. typename Strategy,
  36. typename RobustPolicy,
  37. typename OutputIterator
  38. >
  39. static inline OutputIterator apply(UniqueSubRange1 const& range_p,
  40. UniqueSubRange2 const& range_q,
  41. TurnInfo const& ,
  42. Strategy const& strategy,
  43. RobustPolicy const& ,
  44. OutputIterator out)
  45. {
  46. // Make sure this is only called with no rescaling
  47. BOOST_STATIC_ASSERT((std::is_same
  48. <
  49. no_rescale_policy_tag,
  50. typename rescale_policy_type<RobustPolicy>::type
  51. >::value));
  52. typedef typename TurnInfo::point_type turn_point_type;
  53. typedef policies::relate::segments_intersection_points
  54. <
  55. segment_intersection_points<turn_point_type>
  56. > policy_type;
  57. typename policy_type::return_type const result
  58. = strategy.relate().apply(range_p, range_q, policy_type());
  59. for (std::size_t i = 0; i < result.count; i++)
  60. {
  61. TurnInfo tp;
  62. geometry::convert(result.intersections[i], tp.point);
  63. *out++ = tp;
  64. }
  65. return out;
  66. }
  67. };
  68. }} // namespace detail::get_intersection_points
  69. #endif // DOXYGEN_NO_DETAIL
  70. template
  71. <
  72. typename Geometry1,
  73. typename Geometry2,
  74. typename RobustPolicy,
  75. typename Turns,
  76. typename Strategy
  77. >
  78. inline void get_intersection_points(Geometry1 const& geometry1,
  79. Geometry2 const& geometry2,
  80. RobustPolicy const& robust_policy,
  81. Turns& turns,
  82. Strategy const& strategy)
  83. {
  84. concepts::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>();
  85. typedef detail::get_intersection_points::get_turn_without_info
  86. <
  87. typename point_type<Geometry1>::type,
  88. typename point_type<Geometry2>::type,
  89. typename boost::range_value<Turns>::type
  90. > TurnPolicy;
  91. detail::get_turns::no_interrupt_policy interrupt_policy;
  92. std::conditional_t
  93. <
  94. reverse_dispatch<Geometry1, Geometry2>::type::value,
  95. dispatch::get_turns_reversed
  96. <
  97. typename tag<Geometry1>::type,
  98. typename tag<Geometry2>::type,
  99. Geometry1, Geometry2,
  100. false, false,
  101. TurnPolicy
  102. >,
  103. dispatch::get_turns
  104. <
  105. typename tag<Geometry1>::type,
  106. typename tag<Geometry2>::type,
  107. Geometry1, Geometry2,
  108. false, false,
  109. TurnPolicy
  110. >
  111. >::apply(0, geometry1,
  112. 1, geometry2,
  113. strategy,
  114. robust_policy,
  115. turns, interrupt_policy);
  116. }
  117. }} // namespace boost::geometry
  118. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP