visit_info.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_VISIT_INFO_HPP
  7. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP
  8. namespace boost { namespace geometry
  9. {
  10. #ifndef DOXYGEN_NO_DETAIL
  11. namespace detail { namespace overlay
  12. {
  13. class visit_info
  14. {
  15. private :
  16. static const int NONE = 0;
  17. static const int STARTED = 1;
  18. static const int VISITED = 2;
  19. static const int FINISHED = 3;
  20. static const int REJECTED = 4;
  21. int m_visit_code;
  22. bool m_rejected;
  23. bool m_final;
  24. public:
  25. inline visit_info()
  26. : m_visit_code(0)
  27. , m_rejected(false)
  28. , m_final(false)
  29. {}
  30. inline void set_visited() { m_visit_code = VISITED; }
  31. inline void set_started() { m_visit_code = STARTED; }
  32. inline void set_finished() { m_visit_code = FINISHED; }
  33. inline void set_rejected()
  34. {
  35. m_visit_code = REJECTED;
  36. m_rejected = true;
  37. }
  38. inline bool none() const { return m_visit_code == NONE; }
  39. inline bool visited() const { return m_visit_code == VISITED; }
  40. inline bool started() const { return m_visit_code == STARTED; }
  41. inline bool finished() const { return m_visit_code == FINISHED; }
  42. inline bool rejected() const { return m_rejected; }
  43. inline bool finalized() const { return m_final; }
  44. inline void clear()
  45. {
  46. if (! m_rejected && ! m_final)
  47. {
  48. m_visit_code = NONE;
  49. }
  50. }
  51. inline void reset()
  52. {
  53. *this = visit_info();
  54. }
  55. inline void finalize()
  56. {
  57. if (visited() || started() || finished() )
  58. {
  59. m_final = true;
  60. }
  61. }
  62. #ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
  63. friend std::ostream& operator<<(std::ostream &os, visit_info const& v)
  64. {
  65. if (v.m_visit_code != 0)
  66. {
  67. os << " VIS: " << int(v.m_visit_code);
  68. }
  69. return os;
  70. }
  71. #endif
  72. };
  73. }} // namespace detail::overlay
  74. #endif //DOXYGEN_NO_DETAIL
  75. }} // namespace boost::geometry
  76. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP