1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
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)
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP
13 #if defined(BOOST_GEOMETRY_DEBUG_OVERLAY)
14 # define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
17 #if defined(BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER)
22 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
25 namespace boost { namespace geometry
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
36 inline segment_identifier()
44 inline segment_identifier(signed_size_type src,
55 inline bool operator<(segment_identifier const& other) const
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 : segment_index < other.segment_index
64 inline bool operator==(segment_identifier const& other) const
66 return source_index == other.source_index
67 && segment_index == other.segment_index
68 && ring_index == other.ring_index
69 && multi_index == other.multi_index
73 #if defined(BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER)
74 friend std::ostream& operator<<(std::ostream &os, segment_identifier const& seg_id)
77 << "s:" << seg_id.source_index
78 << ", v:" << seg_id.segment_index // v:vertex because s is used for source
80 if (seg_id.ring_index >= 0) os << ", r:" << seg_id.ring_index;
81 if (seg_id.multi_index >= 0) os << ", m:" << seg_id.multi_index;
86 signed_size_type source_index;
87 signed_size_type multi_index;
88 signed_size_type ring_index;
89 signed_size_type segment_index;
91 // For buffer - todo: move this to buffer-only
92 signed_size_type piece_index;
97 }} // namespace boost::geometry
99 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP