ring_identifier.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_RING_IDENTIFIER_HPP
  7. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
  8. #if defined(BOOST_GEOMETRY_DEBUG_IDENTIFIER)
  9. #include <iostream>
  10. #endif
  11. #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. // Ring Identifier. It is currently: source,multi,ring
  15. struct ring_identifier
  16. {
  17. inline ring_identifier()
  18. : source_index(-1)
  19. , multi_index(-1)
  20. , ring_index(-1)
  21. {}
  22. inline ring_identifier(signed_size_type src,
  23. signed_size_type mul,
  24. signed_size_type rin)
  25. : source_index(src)
  26. , multi_index(mul)
  27. , ring_index(rin)
  28. {}
  29. inline bool operator<(ring_identifier const& other) const
  30. {
  31. return source_index != other.source_index ? source_index < other.source_index
  32. : multi_index !=other.multi_index ? multi_index < other.multi_index
  33. : ring_index < other.ring_index
  34. ;
  35. }
  36. inline bool operator==(ring_identifier const& other) const
  37. {
  38. return source_index == other.source_index
  39. && ring_index == other.ring_index
  40. && multi_index == other.multi_index
  41. ;
  42. }
  43. inline bool operator!=(ring_identifier const& other) const
  44. {
  45. return ! operator==(other);
  46. }
  47. #if defined(BOOST_GEOMETRY_DEBUG_IDENTIFIER)
  48. friend std::ostream& operator<<(std::ostream &os, ring_identifier const& ring_id)
  49. {
  50. os << "(s:" << ring_id.source_index;
  51. if (ring_id.ring_index >= 0) os << ", r:" << ring_id.ring_index;
  52. if (ring_id.multi_index >= 0) os << ", m:" << ring_id.multi_index;
  53. os << ")";
  54. return os;
  55. }
  56. #endif
  57. signed_size_type source_index;
  58. signed_size_type multi_index;
  59. signed_size_type ring_index;
  60. };
  61. }} // namespace boost::geometry
  62. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP