is_self_turn.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2017-2017 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_IS_SELF_TURN_HPP
  8. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_IS_SELF_TURN_HPP
  9. #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
  10. namespace boost { namespace geometry
  11. {
  12. #ifndef DOXYGEN_NO_DETAIL
  13. namespace detail { namespace overlay
  14. {
  15. template <overlay_type OverlayType>
  16. struct is_self_turn_check
  17. {
  18. template <typename Turn>
  19. static inline bool apply(Turn const& turn)
  20. {
  21. return turn.operations[0].seg_id.source_index
  22. == turn.operations[1].seg_id.source_index;
  23. }
  24. };
  25. template <>
  26. struct is_self_turn_check<overlay_buffer>
  27. {
  28. template <typename Turn>
  29. static inline bool apply(Turn const& /*turn*/)
  30. {
  31. return false;
  32. }
  33. };
  34. template <>
  35. struct is_self_turn_check<overlay_dissolve>
  36. {
  37. template <typename Turn>
  38. static inline bool apply(Turn const& /*turn*/)
  39. {
  40. return false;
  41. }
  42. };
  43. template <overlay_type OverlayType, typename Turn>
  44. bool is_self_turn(Turn const& turn)
  45. {
  46. return is_self_turn_check<OverlayType>::apply(turn);
  47. }
  48. }} // namespace detail::overlay
  49. #endif // DOXYGEN_NO_DETAIL
  50. }} // namespace boost::geometry
  51. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_IS_SELF_TURN_HPP