1
// Generic Geometry Library
3
// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
4
// Copyright Bruno Lalande 2008, 2009
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 GGL_INTERSECTION_RESULT_HPP
10
#define GGL_INTERSECTION_RESULT_HPP
12
#if defined(HAVE_MATRIX_AS_STRING)
20
\brief Dimensionally Extended 9 Intersection Matrix
23
\see http://gis.hsr.ch/wiki/images/3/3d/9dem_springer.pdf
32
: ii(-1), ib(-1), ie(-1)
33
, bi(-1), bb(-1), be(-1)
34
, ei(-1), eb(-1), ee(-1)
38
inline de9im(int ii0, int ib0, int ie0,
39
int bi0, int bb0, int be0,
40
int ei0, int eb0, int ee0)
41
: ii(ii0), ib(ib0), ie(ie0)
42
, bi(bi0), bb(bb0), be(be0)
43
, ei(ei0), eb(eb0), ee(ee0)
46
inline bool equals() const
48
return ii >= 0 && ie < 0 && be < 0 && ei < 0 && eb < 0;
51
inline bool disjoint() const
53
return ii < 0 && ib < 0 && bi < 0 && bb < 0;
56
inline bool intersects() const
58
return ii >= 0 || bb >= 0 || bi >= 0 || ib >= 0;
61
inline bool touches() const
63
return ii < 0 && (bb >= 0 || bi >= 0 || ib >= 0);
66
inline bool crosses() const
68
return (ii >= 0 && ie >= 0) || (ii == 0);
71
inline bool overlaps() const
73
return ii >= 0 && ie >= 0 && ei >= 0;
76
inline bool within() const
78
return ii >= 0 && ie < 0 && be < 0;
81
inline bool contains() const
83
return ii >= 0 && ei < 0 && eb < 0;
87
static inline char as_char(int v)
89
return v >= 0 && v < 10 ? ('0' + char(v)) : '-';
92
#if defined(HAVE_MATRIX_AS_STRING)
93
inline std::string matrix_as_string(std::string const& tab, std::string const& nl) const
96
ret.reserve(9 + tab.length() * 3 + nl.length() * 3);
97
ret += tab; ret += as_char(ii); ret += as_char(ib); ret += as_char(ie); ret += nl;
98
ret += tab; ret += as_char(bi); ret += as_char(bb); ret += as_char(be); ret += nl;
99
ret += tab; ret += as_char(ei); ret += as_char(eb); ret += as_char(ee);
103
inline std::string matrix_as_string() const
105
return matrix_as_string("", "");
111
struct de9im_segment : public de9im
113
bool collinear; // true if segments are aligned (for equal,overlap,touch)
114
bool opposite; // true if direction is reversed (for equal,overlap,touch)
115
bool parallel; // true if disjoint but parallel
116
bool degenerate; // true for segment(s) of zero length
118
double ra, rb; // temp
120
inline de9im_segment()
128
inline de9im_segment(double a, double b,
129
int ii0, int ib0, int ie0,
130
int bi0, int bb0, int be0,
131
int ei0, int eb0, int ee0,
132
bool c = false, bool o = false, bool p = false, bool d = false)
133
: de9im(ii0, ib0, ie0, bi0, bb0, be0, ei0, eb0, ee0)
142
#if defined(HAVE_MATRIX_AS_STRING)
143
inline std::string as_string() const
145
std::string ret = matrix_as_string();
146
ret += collinear ? "c" : "-";
147
ret += opposite ? "o" : "-";
153
template <typename P>
154
struct segment_intersection_points
159
segment_intersection_points()
167
#endif // GGL_INTERSECTION_RESULT_HPP