GEOS  3.8.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 #ifndef GEOS_NODING_SEGMENTNODELIST_H
20 #define GEOS_NODING_SEGMENTNODELIST_H
21 
22 #include <geos/export.h>
23 
24 #include <geos/inline.h>
25 
26 #include <cassert>
27 #include <iostream>
28 #include <vector>
29 #include <set>
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 
60  // the parent edge
61  const NodedSegmentString& edge;
62 
69  void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
70 
79  SegmentString* createSplitEdge(SegmentNode* ei0, SegmentNode* ei1);
80 
89  void addCollapsedNodes();
90 
95  void findCollapsesFromExistingVertices(
96  std::vector<std::size_t>& collapsedVertexIndexes);
97 
105  void findCollapsesFromInsertedNodes(
106  std::vector<std::size_t>& 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<SegmentNode*, SegmentNodeLT> container;
120  typedef container::iterator iterator;
121  typedef container::const_iterator const_iterator;
122 
123  SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
124 
125  SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
126 
127  const NodedSegmentString&
128  getEdge() const
129  {
130  return edge;
131  }
132 
133  // TODO: Is this a final class ?
134  // Should remove the virtual in that case
135  virtual ~SegmentNodeList();
136 
147  SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
148 
149  SegmentNode*
150  add(const geom::Coordinate* intPt, std::size_t segmentIndex)
151  {
152  return add(*intPt, segmentIndex);
153  }
154 
155  /*
156  * returns the set of SegmentNodes
157  */
158  //replaces iterator()
159  // TODO: obsolete this function
160  std::set<SegmentNode*, SegmentNodeLT>*
161  getNodes()
162  {
163  return &nodeMap;
164  }
165 
167  size_t
168  size() const
169  {
170  return nodeMap.size();
171  }
172 
173  container::iterator
174  begin()
175  {
176  return nodeMap.begin();
177  }
178  container::const_iterator
179  begin() const
180  {
181  return nodeMap.begin();
182  }
183  container::iterator
184  end()
185  {
186  return nodeMap.end();
187  }
188  container::const_iterator
189  end() const
190  {
191  return nodeMap.end();
192  }
193 
197  void addEndpoints();
198 
205  void addSplitEdges(std::vector<SegmentString*>& edgeList);
206 
207  void
208  addSplitEdges(std::vector<SegmentString*>* edgeList)
209  {
210  assert(edgeList);
211  addSplitEdges(*edgeList);
212  }
213 
214  //string print();
215 };
216 
217 std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
218 
219 } // namespace geos::noding
220 } // namespace geos
221 
222 #ifdef _MSC_VER
223 #pragma warning(pop)
224 #endif
225 
226 #endif
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:25
size_t size() const
Return the number of nodes in this list.
Definition: SegmentNodeList.h:168
A list of the SegmentNode present along a NodedSegmentString.
Definition: SegmentNodeList.h:56
Represents an intersection point between two NodedSegmentString.
Definition: SegmentNode.h:45