• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
11 
12 
13 #if defined(BOOST_GEOMETRY_DEBUG_IDENTIFIER)
14 #include <iostream>
15 #endif
16 
17 
18 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
19 
20 
21 namespace boost { namespace geometry
22 {
23 
24 
25 // Ring Identifier. It is currently: source,multi,ring
26 struct ring_identifier
27 {
28 
ring_identifierboost::geometry::ring_identifier29     inline ring_identifier()
30         : source_index(-1)
31         , multi_index(-1)
32         , ring_index(-1)
33     {}
34 
ring_identifierboost::geometry::ring_identifier35     inline ring_identifier(signed_size_type src,
36                            signed_size_type mul,
37                            signed_size_type rin)
38         : source_index(src)
39         , multi_index(mul)
40         , ring_index(rin)
41     {}
42 
operator <boost::geometry::ring_identifier43     inline bool operator<(ring_identifier const& other) const
44     {
45         return source_index != other.source_index ? source_index < other.source_index
46             : multi_index !=other.multi_index ? multi_index < other.multi_index
47             : ring_index < other.ring_index
48             ;
49     }
50 
operator ==boost::geometry::ring_identifier51     inline bool operator==(ring_identifier const& other) const
52     {
53         return source_index == other.source_index
54             && ring_index == other.ring_index
55             && multi_index == other.multi_index
56             ;
57     }
58 
operator !=boost::geometry::ring_identifier59     inline bool operator!=(ring_identifier const& other) const
60     {
61         return ! operator==(other);
62     }
63 
64 #if defined(BOOST_GEOMETRY_DEBUG_IDENTIFIER)
operator <<(std::ostream & os,ring_identifier const & ring_id)65     friend std::ostream& operator<<(std::ostream &os, ring_identifier const& ring_id)
66     {
67         os << "(s:" << ring_id.source_index;
68         if (ring_id.ring_index >= 0) os << ", r:" << ring_id.ring_index;
69         if (ring_id.multi_index >= 0) os << ", m:" << ring_id.multi_index;
70         os << ")";
71         return os;
72     }
73 #endif
74 
75 
76     signed_size_type source_index;
77     signed_size_type multi_index;
78     signed_size_type ring_index;
79 };
80 
81 
82 }} // namespace boost::geometry
83 
84 
85 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
86