GEOS: SegmentNodeList.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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);
113 SegmentNodeList& operator=(const SegmentNodeList& rhs);
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& getEdge() const { return edge; }
128
129 // TODO: Is this a final class ?
130 // Should remove the virtual in that case
131 virtual ~SegmentNodeList();
132
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<SegmentNode*,SegmentNodeLT>* getNodes() { return &nodeMap; }
155
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
167 void addEndpoints();
168
175 void addSplitEdges(std::vector<SegmentString*>& edgeList);
176
177 void addSplitEdges(std::vector<SegmentString*>* 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
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:46
geos::noding::NodedSegmentString
Represents a list of contiguous line segments, and supports noding the segments.
Definition: NodedSegmentString.h:57
geos::geom::operator<<
GEOS_DLL std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::noding::SegmentNodeList::size
size_t size() const
Return the number of nodes in this list.
Definition: SegmentNodeList.h:157
geos::noding::SegmentNodeList
A list of the SegmentNode present along a NodedSegmentString.
Definition: SegmentNodeList.h:56
geos::noding::SegmentNode
Represents an intersection point between two NodedSegmentString.
Definition: SegmentNode.h:45