| 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
|
|
|
|
|
|
|
* Last port: noding/SegmentNodeList.java rev. 1.8 (JTS-1.10) |
|
16
|
|
|
|
|
|
|
* |
|
17
|
|
|
|
|
|
|
**********************************************************************/ |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#ifndef GEOS_NODING_SEGMENTNODELIST_H |
|
20
|
|
|
|
|
|
|
#define GEOS_NODING_SEGMENTNODELIST_H |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#include |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#include |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#include |
|
27
|
|
|
|
|
|
|
#include |
|
28
|
|
|
|
|
|
|
#include |
|
29
|
|
|
|
|
|
|
#include |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#include // for composition |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#ifdef _MSC_VER |
|
34
|
|
|
|
|
|
|
#pragma warning(push) |
|
35
|
|
|
|
|
|
|
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class |
|
36
|
|
|
|
|
|
|
#endif |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
// Forward declarations |
|
39
|
|
|
|
|
|
|
namespace geos { |
|
40
|
|
|
|
|
|
|
namespace geom { |
|
41
|
|
|
|
|
|
|
class CoordinateSequence; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
namespace noding { |
|
44
|
|
|
|
|
|
|
class SegmentString; |
|
45
|
|
|
|
|
|
|
class NodedSegmentString; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
namespace geos { |
|
50
|
|
|
|
|
|
|
namespace noding { // geos::noding |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
/** \brief |
|
53
|
|
|
|
|
|
|
* A list of the SegmentNode present along a |
|
54
|
|
|
|
|
|
|
* NodedSegmentString. |
|
55
|
|
|
|
|
|
|
*/ |
|
56
|
|
|
|
|
|
|
class GEOS_DLL SegmentNodeList { |
|
57
|
|
|
|
|
|
|
private: |
|
58
|
|
|
|
|
|
|
std::set nodeMap; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
// the parent edge |
|
61
|
|
|
|
|
|
|
const NodedSegmentString& edge; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
/** |
|
64
|
|
|
|
|
|
|
* Checks the correctness of the set of split edges corresponding |
|
65
|
|
|
|
|
|
|
* to this edge |
|
66
|
|
|
|
|
|
|
* |
|
67
|
|
|
|
|
|
|
* @param splitEdges the split edges for this edge (in order) |
|
68
|
|
|
|
|
|
|
*/ |
|
69
|
|
|
|
|
|
|
void checkSplitEdgesCorrectness(std::vector& splitEdges); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
/** |
|
72
|
|
|
|
|
|
|
* Create a new "split edge" with the section of points between |
|
73
|
|
|
|
|
|
|
* (and including) the two intersections. |
|
74
|
|
|
|
|
|
|
* The label for the new edge is the same as the label for the |
|
75
|
|
|
|
|
|
|
* parent edge. |
|
76
|
|
|
|
|
|
|
* |
|
77
|
|
|
|
|
|
|
* ownership of return value is transferred |
|
78
|
|
|
|
|
|
|
*/ |
|
79
|
|
|
|
|
|
|
SegmentString* createSplitEdge(SegmentNode *ei0, SegmentNode *ei1); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
/** |
|
82
|
|
|
|
|
|
|
* Adds nodes for any collapsed edge pairs. |
|
83
|
|
|
|
|
|
|
* Collapsed edge pairs can be caused by inserted nodes, or they |
|
84
|
|
|
|
|
|
|
* can be pre-existing in the edge vertex list. |
|
85
|
|
|
|
|
|
|
* In order to provide the correct fully noded semantics, |
|
86
|
|
|
|
|
|
|
* the vertex at the base of a collapsed pair must also be added |
|
87
|
|
|
|
|
|
|
* as a node. |
|
88
|
|
|
|
|
|
|
*/ |
|
89
|
|
|
|
|
|
|
void addCollapsedNodes(); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
/** |
|
92
|
|
|
|
|
|
|
* Adds nodes for any collapsed edge pairs |
|
93
|
|
|
|
|
|
|
* which are pre-existing in the vertex list. |
|
94
|
|
|
|
|
|
|
*/ |
|
95
|
|
|
|
|
|
|
void findCollapsesFromExistingVertices( |
|
96
|
|
|
|
|
|
|
std::vector& collapsedVertexIndexes); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
/** |
|
99
|
|
|
|
|
|
|
* Adds nodes for any collapsed edge pairs caused by inserted nodes |
|
100
|
|
|
|
|
|
|
* Collapsed edge pairs occur when the same coordinate is inserted |
|
101
|
|
|
|
|
|
|
* as a node both before and after an existing edge vertex. |
|
102
|
|
|
|
|
|
|
* To provide the correct fully noded semantics, |
|
103
|
|
|
|
|
|
|
* the vertex must be added as a node as well. |
|
104
|
|
|
|
|
|
|
*/ |
|
105
|
|
|
|
|
|
|
void findCollapsesFromInsertedNodes( |
|
106
|
|
|
|
|
|
|
std::vector& collapsedVertexIndexes); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1, |
|
109
|
|
|
|
|
|
|
size_t& collapsedVertexIndex); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
// Declare type as noncopyable |
|
112
|
|
|
|
|
|
|
SegmentNodeList(const SegmentNodeList& other) = delete; |
|
113
|
|
|
|
|
|
|
SegmentNodeList& operator=(const SegmentNodeList& rhs) = delete; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
public: |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
typedef std::set container; |
|
120
|
|
|
|
|
|
|
typedef container::iterator iterator; |
|
121
|
|
|
|
|
|
|
typedef container::const_iterator const_iterator; |
|
122
|
|
|
|
|
|
|
|
|
123
|
32
|
|
|
|
|
|
SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
const NodedSegmentString& getEdge() const { return edge; } |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
// TODO: Is this a final class ? |
|
130
|
|
|
|
|
|
|
// Should remove the virtual in that case |
|
131
|
|
|
|
|
|
|
virtual ~SegmentNodeList(); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
/** |
|
134
|
|
|
|
|
|
|
* Adds an intersection into the list, if it isn't already there. |
|
135
|
|
|
|
|
|
|
* The input segmentIndex is expected to be normalized. |
|
136
|
|
|
|
|
|
|
* |
|
137
|
|
|
|
|
|
|
* @return the SegmentIntersection found or added. It will be |
|
138
|
|
|
|
|
|
|
* destroyed at SegmentNodeList destruction time. |
|
139
|
|
|
|
|
|
|
* |
|
140
|
|
|
|
|
|
|
* @param intPt the intersection Coordinate, will be copied |
|
141
|
|
|
|
|
|
|
* @param segmentIndex |
|
142
|
|
|
|
|
|
|
*/ |
|
143
|
|
|
|
|
|
|
SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
SegmentNode* add(const geom::Coordinate *intPt, std::size_t segmentIndex) { |
|
146
|
|
|
|
|
|
|
return add(*intPt, segmentIndex); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
/* |
|
150
|
|
|
|
|
|
|
* returns the set of SegmentNodes |
|
151
|
|
|
|
|
|
|
*/ |
|
152
|
|
|
|
|
|
|
//replaces iterator() |
|
153
|
|
|
|
|
|
|
// TODO: obsolete this function |
|
154
|
|
|
|
|
|
|
std::set* getNodes() { return &nodeMap; } |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
/// Return the number of nodes in this list |
|
157
|
|
|
|
|
|
|
size_t size() const { return nodeMap.size(); } |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
container::iterator begin() { return nodeMap.begin(); } |
|
160
|
|
|
|
|
|
|
container::const_iterator begin() const { return nodeMap.begin(); } |
|
161
|
|
|
|
|
|
|
container::iterator end() { return nodeMap.end(); } |
|
162
|
|
|
|
|
|
|
container::const_iterator end() const { return nodeMap.end(); } |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
/** |
|
165
|
|
|
|
|
|
|
* Adds entries for the first and last points of the edge to the list |
|
166
|
|
|
|
|
|
|
*/ |
|
167
|
|
|
|
|
|
|
void addEndpoints(); |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
/** |
|
170
|
|
|
|
|
|
|
* Creates new edges for all the edges that the intersections in this |
|
171
|
|
|
|
|
|
|
* list split the parent edge into. |
|
172
|
|
|
|
|
|
|
* Adds the edges to the input list (this is so a single list |
|
173
|
|
|
|
|
|
|
* can be used to accumulate all split edges for a Geometry). |
|
174
|
|
|
|
|
|
|
*/ |
|
175
|
|
|
|
|
|
|
void addSplitEdges(std::vector& edgeList); |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
void addSplitEdges(std::vector* edgeList) { |
|
178
|
|
|
|
|
|
|
assert(edgeList); |
|
179
|
|
|
|
|
|
|
addSplitEdges(*edgeList); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
//string print(); |
|
183
|
|
|
|
|
|
|
}; |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l); |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
} // namespace geos::noding |
|
188
|
|
|
|
|
|
|
} // namespace geos |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
#ifdef _MSC_VER |
|
191
|
|
|
|
|
|
|
#pragma warning(pop) |
|
192
|
|
|
|
|
|
|
#endif |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#endif |