GEOS  3.9.0dev
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
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 
56 class GEOS_DLL SegmentNodeList {
57 private:
58  std::set<SegmentNode*, SegmentNodeLT> nodeMap;
59  std::deque<SegmentNode> nodeQue;
60 
61  // the parent edge
62  const NodedSegmentString& edge;
63 
70  void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
71 
80  SegmentString* createSplitEdge(SegmentNode* ei0, SegmentNode* ei1);
81 
92  void createSplitEdgePts(SegmentNode* ei0, SegmentNode* ei1, std::vector<geom::Coordinate>& pts);
93 
102  void addCollapsedNodes();
103 
108  void findCollapsesFromExistingVertices(
109  std::vector<std::size_t>& collapsedVertexIndexes);
110 
118  void findCollapsesFromInsertedNodes(
119  std::vector<std::size_t>& collapsedVertexIndexes);
120 
121  bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
122  size_t& collapsedVertexIndex);
123 
124  void addEdgeCoordinates(SegmentNode* ei0, SegmentNode* ei1, std::vector<geom::Coordinate>& coordList);
125 
126  // Declare type as noncopyable
127  SegmentNodeList(const SegmentNodeList& other) = delete;
128  SegmentNodeList& operator=(const SegmentNodeList& rhs) = delete;
129 
130 public:
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 
142  ~SegmentNodeList();
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 
162  SegmentNode*
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 
210  void addEndpoints();
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 
241 std::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
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
Represents a list of contiguous line segments, and supports noding the segments.
Definition: NodedSegmentString.h:57
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
size_t size() const
Return the number of nodes in this list.
Definition: SegmentNodeList.h:181
A list of the SegmentNode present along a NodedSegmentString.
Definition: SegmentNodeList.h:56
Represents an intersection point between two NodedSegmentString.
Definition: SegmentNode.h:47