GEOS: SegmentNodeList.h Source File

GEOS 3.3.8

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

- File List

SegmentNodeList.h
1 /**********************************************************************
2 * $Id: SegmentNodeList.h 3255 2011-03-01 17:56:10Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: noding/SegmentNodeList.java rev. 1.8 (JTS-1.10)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_NODING_SEGMENTNODELIST_H
21 #define GEOS_NODING_SEGMENTNODELIST_H
22
23 #include <geos/export.h>
24
25 #include <geos/inline.h>
26
27 #include <cassert>
28 #include <iostream>
29 #include <vector>
30 #include <set>
31
32 #include <geos/noding/SegmentNode.h> // for composition
33
34 #ifdef _MSC_VER
35 #pragma warning(push)
36 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37 #endif
38
39 // Forward declarations
40 namespace geos {
41 namespace geom {
42 class CoordinateSequence;
43 }
44 namespace noding {
45 class SegmentString;
46 class NodedSegmentString;
47 }
48 }
49
50 namespace geos {
51 namespace noding { // geos::noding
52
57 class GEOS_DLL SegmentNodeList {
58 private:
59 std::set<SegmentNode*,SegmentNodeLT> nodeMap;
60
61 // the parent edge
62 const NodedSegmentString& edge;
63
64 // This vector is here to keep track of created splitEdges
65 std::vector<SegmentString*> splitEdges;
66
67 // This vector is here to keep track of created Coordinates
68 std::vector<geom::CoordinateSequence*> splitCoordLists;
69
76 void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
77
84 SegmentString* createSplitEdge(SegmentNode *ei0, SegmentNode *ei1);
85
94 void addCollapsedNodes();
95
100 void findCollapsesFromExistingVertices(
101 std::vector<std::size_t>& collapsedVertexIndexes);
102
110 void findCollapsesFromInsertedNodes(
111 std::vector<std::size_t>& collapsedVertexIndexes);
112
113 bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
114 size_t& collapsedVertexIndex);
115
116 // Declare type as noncopyable
117 SegmentNodeList(const SegmentNodeList& other);
118 SegmentNodeList& operator=(const SegmentNodeList& rhs);
119
120 public:
121
122 friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
123
124 typedef std::set<SegmentNode*,SegmentNodeLT> container;
125 typedef container::iterator iterator;
126 typedef container::const_iterator const_iterator;
127
128 SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
129
130 SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
131
132 const NodedSegmentString& getEdge() const { return edge; }
133
134 // TODO: Is this a final class ?
135 // Should remove the virtual in that case
136 virtual ~SegmentNodeList();
137
148 SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
149
150 SegmentNode* add(const geom::Coordinate *intPt, std::size_t segmentIndex) {
151 return add(*intPt, segmentIndex);
152 }
153
154 /*
155 * returns the set of SegmentNodes
156 */
157 //replaces iterator()
158 // TODO: obsolete this function
159 std::set<SegmentNode*,SegmentNodeLT>* getNodes() { return &nodeMap; }
160
162 size_t size() const { return nodeMap.size(); }
163
164 container::iterator begin() { return nodeMap.begin(); }
165 container::const_iterator begin() const { return nodeMap.begin(); }
166 container::iterator end() { return nodeMap.end(); }
167 container::const_iterator end() const { return nodeMap.end(); }
168
172 void addEndpoints();
173
180 void addSplitEdges(std::vector<SegmentString*>& edgeList);
181
182 void addSplitEdges(std::vector<SegmentString*>* edgeList) {
183 assert(edgeList);
184 addSplitEdges(*edgeList);
185 }
186
187 //string print();
188 };
189
190 std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
191
192 } // namespace geos::noding
193 } // namespace geos
194
195 #ifdef _MSC_VER
196 #pragma warning(pop)
197 #endif
198
199 //#ifdef GEOS_INLINE
200 //# include "geos/noding/SegmentNodeList.inl"
201 //#endif
202
203 #endif
204
205 /**********************************************************************
206 * $Log$
207 * Revision 1.4 2006/06/12 11:29:23 strk
208 * unsigned int => size_t
209 *
210 * Revision 1.3 2006/05/04 07:41:56 strk
211 * const-correct size() method for SegmentNodeList
212 *
213 * Revision 1.2 2006/03/24 09:52:41 strk
214 * USE_INLINE => GEOS_INLINE
215 *
216 * Revision 1.1 2006/03/09 16:46:49 strk
217 * geos::geom namespace definition, first pass at headers split
218 *
219 **********************************************************************/
220