line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/********************************************************************** |
2
|
|
|
|
|
|
|
* |
3
|
|
|
|
|
|
|
* GEOS - Geometry Engine Open Source |
4
|
|
|
|
|
|
|
* http://geos.osgeo.org |
5
|
|
|
|
|
|
|
* |
6
|
|
|
|
|
|
|
* Copyright (C) 2006 Refractions Research Inc. |
7
|
|
|
|
|
|
|
* |
8
|
|
|
|
|
|
|
* This is free software; you can redistribute and/or modify it under |
9
|
|
|
|
|
|
|
* the terms of the GNU Lesser General Public Licence as published |
10
|
|
|
|
|
|
|
* by the Free Software Foundation. |
11
|
|
|
|
|
|
|
* See the COPYING file for more information. |
12
|
|
|
|
|
|
|
* |
13
|
|
|
|
|
|
|
* |
14
|
|
|
|
|
|
|
**********************************************************************/ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#ifndef GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H |
17
|
|
|
|
|
|
|
#define GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#include |
20
|
|
|
|
|
|
|
#include |
21
|
|
|
|
|
|
|
#include |
22
|
|
|
|
|
|
|
#include |
23
|
|
|
|
|
|
|
#include |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
using namespace geos::algorithm; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
namespace geos { |
28
|
|
|
|
|
|
|
namespace noding { // geos::noding |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
/** \brief |
31
|
|
|
|
|
|
|
* Detects and records an intersection between two {@link SegmentString}s, |
32
|
|
|
|
|
|
|
* if one exists. |
33
|
|
|
|
|
|
|
* |
34
|
|
|
|
|
|
|
* This strategy can be configured to search for proper intersections. |
35
|
|
|
|
|
|
|
* In this case, the presence of any intersection will still be recorded, |
36
|
|
|
|
|
|
|
* but searching will continue until either a proper intersection has been found |
37
|
|
|
|
|
|
|
* or no intersections are detected. |
38
|
|
|
|
|
|
|
* |
39
|
|
|
|
|
|
|
* Only a single intersection is recorded. |
40
|
|
|
|
|
|
|
* |
41
|
|
|
|
|
|
|
* @version 1.7 |
42
|
|
|
|
|
|
|
*/ |
43
|
|
|
|
|
|
|
class SegmentIntersectionDetector : public SegmentIntersector |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
private: |
46
|
|
|
|
|
|
|
LineIntersector * li; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
bool findProper; |
49
|
|
|
|
|
|
|
bool findAllTypes; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
bool _hasIntersection; |
52
|
|
|
|
|
|
|
bool _hasProperIntersection; |
53
|
|
|
|
|
|
|
bool _hasNonProperIntersection; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
const geom::Coordinate * intPt; |
56
|
|
|
|
|
|
|
geom::CoordinateSequence * intSegments; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
protected: |
59
|
|
|
|
|
|
|
public: |
60
|
2
|
|
|
|
|
|
SegmentIntersectionDetector( LineIntersector * li) |
61
|
|
|
|
|
|
|
: |
62
|
|
|
|
|
|
|
li( li), |
63
|
|
|
|
|
|
|
findProper(false), |
64
|
|
|
|
|
|
|
findAllTypes(false), |
65
|
|
|
|
|
|
|
_hasIntersection(false), |
66
|
|
|
|
|
|
|
_hasProperIntersection(false), |
67
|
|
|
|
|
|
|
_hasNonProperIntersection(false), |
68
|
|
|
|
|
|
|
intPt( nullptr), |
69
|
2
|
|
|
|
|
|
intSegments( nullptr) |
70
|
2
|
|
|
|
|
|
{ } |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
~SegmentIntersectionDetector() override |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
//delete intPt; |
75
|
|
|
|
|
|
|
delete intSegments; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
void setFindProper( bool findProper) |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
|
|
|
this->findProper = findProper; |
82
|
0
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
void setFindAllIntersectionTypes( bool findAllTypes) |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
|
this->findAllTypes = findAllTypes; |
87
|
0
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
/** |
90
|
|
|
|
|
|
|
* Tests whether an intersection was found. |
91
|
|
|
|
|
|
|
* |
92
|
|
|
|
|
|
|
* @return true if an intersection was found |
93
|
|
|
|
|
|
|
*/ |
94
|
0
|
|
|
|
|
|
bool hasIntersection() const |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
|
|
|
return _hasIntersection; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
/** |
100
|
|
|
|
|
|
|
* Tests whether a proper intersection was found. |
101
|
|
|
|
|
|
|
* |
102
|
|
|
|
|
|
|
* @return true if a proper intersection was found |
103
|
|
|
|
|
|
|
*/ |
104
|
1
|
|
|
|
|
|
bool hasProperIntersection() const |
105
|
|
|
|
|
|
|
{ |
106
|
1
|
|
|
|
|
|
return _hasProperIntersection; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
/** |
110
|
|
|
|
|
|
|
* Tests whether a non-proper intersection was found. |
111
|
|
|
|
|
|
|
* |
112
|
|
|
|
|
|
|
* @return true if a non-proper intersection was found |
113
|
|
|
|
|
|
|
*/ |
114
|
1
|
|
|
|
|
|
bool hasNonProperIntersection() const |
115
|
|
|
|
|
|
|
{ |
116
|
1
|
|
|
|
|
|
return _hasNonProperIntersection; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
/** |
120
|
|
|
|
|
|
|
* Gets the computed location of the intersection. |
121
|
|
|
|
|
|
|
* Due to round-off, the location may not be exact. |
122
|
|
|
|
|
|
|
* |
123
|
|
|
|
|
|
|
* @return the coordinate for the intersection location |
124
|
|
|
|
|
|
|
*/ |
125
|
1
|
|
|
|
|
|
const geom::Coordinate * getIntersection() const |
126
|
|
|
|
|
|
|
{ |
127
|
1
|
|
|
|
|
|
return intPt; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
/** |
132
|
|
|
|
|
|
|
* Gets the endpoints of the intersecting segments. |
133
|
|
|
|
|
|
|
* |
134
|
|
|
|
|
|
|
* @return an array of the segment endpoints (p00, p01, p10, p11) |
135
|
|
|
|
|
|
|
*/ |
136
|
1
|
|
|
|
|
|
const geom::CoordinateSequence * getIntersectionSegments() const |
137
|
|
|
|
|
|
|
{ |
138
|
1
|
|
|
|
|
|
return intSegments; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
bool isDone() const override |
142
|
|
|
|
|
|
|
{ |
143
|
|
|
|
|
|
|
// If finding all types, we can stop |
144
|
|
|
|
|
|
|
// when both possible types have been found. |
145
|
|
|
|
|
|
|
if (findAllTypes) |
146
|
|
|
|
|
|
|
return _hasProperIntersection && _hasNonProperIntersection; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
// If searching for a proper intersection, only stop if one is found |
149
|
|
|
|
|
|
|
if (findProper) |
150
|
|
|
|
|
|
|
return _hasProperIntersection; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
return _hasIntersection; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
/** |
156
|
|
|
|
|
|
|
* This method is called by clients |
157
|
|
|
|
|
|
|
* of the {@link SegmentIntersector} class to process |
158
|
|
|
|
|
|
|
* intersections for two segments of the {@link SegmentStrings} being intersected. |
159
|
|
|
|
|
|
|
* Note that some clients (such as {@link MonotoneChain}s) may optimize away |
160
|
|
|
|
|
|
|
* this call for segment pairs which they have determined do not intersect |
161
|
|
|
|
|
|
|
* (e.g. by an disjoint envelope test). |
162
|
|
|
|
|
|
|
*/ |
163
|
|
|
|
|
|
|
void processIntersections( noding::SegmentString * e0, int segIndex0, |
164
|
|
|
|
|
|
|
noding::SegmentString * e1, int segIndex1 ) override; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
} // namespace geos::noding |
169
|
|
|
|
|
|
|
} // namespace geos |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
#endif // GEOS_GEOM_PREP_SEGMENTINTERSECTIONDETECTOR_H |