GEOS 3.9.1
SegmentNodeList.h
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#pragma once
20
21#include <geos/export.h>
22
23#include <geos/inline.h>
24
25#include <cassert>
26#include <iostream>
27#include <vector>
28#include <set>
29#include <memory>
30
31#include <geos/noding/SegmentNode.h> // 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
39namespace geos {
40namespace geom {
41class CoordinateSequence;
42}
43namespace noding {
44class SegmentString;
45class NodedSegmentString;
46}
47}
48
49namespace geos {
50namespace noding { // geos::noding
51
56class GEOS_DLL SegmentNodeList {
57private:
58 std::set<SegmentNode*, SegmentNodeLT> nodeMap;
59 std::deque<SegmentNode> nodeQue;
60
61 // the parent edge
62 const NodedSegmentString& edge;
63
70 void checkSplitEdgesCorrectness(const std::vector<SegmentString*>& splitEdges) const;
71
80 std::unique_ptr<SegmentString> createSplitEdge(const SegmentNode* ei0, const SegmentNode* ei1) const;
81
92 void createSplitEdgePts(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<geom::Coordinate>& pts) const;
93
102 void addCollapsedNodes();
103
108 void findCollapsesFromExistingVertices(
109 std::vector<std::size_t>& collapsedVertexIndexes) const;
110
118 void findCollapsesFromInsertedNodes(
119 std::vector<std::size_t>& collapsedVertexIndexes) const;
120
121 bool findCollapseIndex(const SegmentNode& ei0, const SegmentNode& ei1,
122 size_t& collapsedVertexIndex) const;
123
124 void addEdgeCoordinates(const SegmentNode* ei0, const SegmentNode* ei1, std::vector<geom::Coordinate>& coordList) const;
125
126 // Declare type as noncopyable
127 SegmentNodeList(const SegmentNodeList& other) = delete;
128 SegmentNodeList& operator=(const SegmentNodeList& rhs) = delete;
129
130public:
131
132 friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
133
134 typedef std::set<SegmentNode*, SegmentNodeLT> container;
135 typedef container::iterator iterator;
136 typedef container::const_iterator const_iterator;
137
138 SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
139
140 SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
141
143
144 const NodedSegmentString&
145 getEdge() const
146 {
147 return edge;
148 }
149
160 SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
161
163 add(const geom::Coordinate* intPt, std::size_t segmentIndex)
164 {
165 return add(*intPt, segmentIndex);
166 }
167
168 /*
169 * returns the set of SegmentNodes
170 */
171 //replaces iterator()
172 // TODO: obsolete this function
173 std::set<SegmentNode*, SegmentNodeLT>*
174 getNodes()
175 {
176 return &nodeMap;
177 }
178
180 size_t
181 size() const
182 {
183 return nodeMap.size();
184 }
185
186 container::iterator
187 begin()
188 {
189 return nodeMap.begin();
190 }
191 container::const_iterator
192 begin() const
193 {
194 return nodeMap.begin();
195 }
196 container::iterator
197 end()
198 {
199 return nodeMap.end();
200 }
201 container::const_iterator
202 end() const
203 {
204 return nodeMap.end();
205 }
206
211
218 void addSplitEdges(std::vector<SegmentString*>& edgeList);
219
220 void
221 addSplitEdges(std::vector<SegmentString*>* edgeList)
222 {
223 assert(edgeList);
224 addSplitEdges(*edgeList);
225 }
226
236 std::unique_ptr<std::vector<geom::Coordinate>> getSplitCoordinates();
237
238
239};
240
241std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
242
243} // namespace geos::noding
244} // namespace geos
245
246#ifdef _MSC_VER
247#pragma warning(pop)
248#endif
249
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a list of contiguous line segments, and supports noding the segments.
Definition: NodedSegmentString.h:57
A list of the SegmentNode present along a NodedSegmentString.
Definition: SegmentNodeList.h:56
SegmentNode * add(const geom::Coordinate &intPt, std::size_t segmentIndex)
void addSplitEdges(std::vector< SegmentString * > &edgeList)
size_t size() const
Return the number of nodes in this list.
Definition: SegmentNodeList.h:181
std::unique_ptr< std::vector< geom::Coordinate > > getSplitCoordinates()
Represents an intersection point between two NodedSegmentString.
Definition: SegmentNode.h:47
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26