]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / overlay / segment_identifier.hpp
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_OVERLAY_SEGMENT_IDENTIFIER_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP
11
12
13 #if defined(BOOST_GEOMETRY_DEBUG_OVERLAY)
14 # define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
15 #endif
16
17 #if defined(BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER)
18 #include <iostream>
19 #endif
20
21
22 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
23
24
25 namespace boost { namespace geometry
26 {
27
28
29
30 // Internal struct to uniquely identify a segment
31 // on a linestring,ring
32 // or polygon (needs ring_index)
33 // or multi-geometry (needs multi_index)
34 struct segment_identifier
35 {
36 inline segment_identifier()
37 : source_index(-1)
38 , multi_index(-1)
39 , ring_index(-1)
40 , segment_index(-1)
41 , piece_index(-1)
42 {}
43
44 inline segment_identifier(signed_size_type src,
45 signed_size_type mul,
46 signed_size_type rin,
47 signed_size_type seg)
48 : source_index(src)
49 , multi_index(mul)
50 , ring_index(rin)
51 , segment_index(seg)
52 , piece_index(-1)
53 {}
54
55 inline bool operator<(segment_identifier const& other) const
56 {
57 return source_index != other.source_index ? source_index < other.source_index
58 : multi_index !=other.multi_index ? multi_index < other.multi_index
59 : ring_index != other.ring_index ? ring_index < other.ring_index
60 : piece_index != other.piece_index ? piece_index < other.piece_index
61 : segment_index < other.segment_index
62 ;
63 }
64
65 inline bool operator==(segment_identifier const& other) const
66 {
67 return source_index == other.source_index
68 && segment_index == other.segment_index
69 && ring_index == other.ring_index
70 && piece_index == other.piece_index
71 && multi_index == other.multi_index
72 ;
73 }
74
75 #if defined(BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER)
76 friend std::ostream& operator<<(std::ostream &os, segment_identifier const& seg_id)
77 {
78 os
79 << "s:" << seg_id.source_index
80 << ", v:" << seg_id.segment_index // v:vertex because s is used for source
81 ;
82 if (seg_id.ring_index >= 0) os << ", r:" << seg_id.ring_index;
83 if (seg_id.multi_index >= 0) os << ", m:" << seg_id.multi_index;
84 if (seg_id.piece_index >= 0) os << ", p:" << seg_id.piece_index;
85 return os;
86 }
87 #endif
88
89 signed_size_type source_index;
90 signed_size_type multi_index;
91 signed_size_type ring_index;
92 signed_size_type segment_index;
93
94 // For buffer - todo: move this to buffer-only
95 signed_size_type piece_index;
96 };
97
98
99
100 }} // namespace boost::geometry
101
102 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP