GEOS 3.4.2

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

- File List

geomgraph/Node.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geomgraph/Node.java r411 (JTS-1.12+)
18 *
19 **********************************************************************/
20
21
22 #ifndef GEOS_GEOMGRAPH_NODE_H
23 #define GEOS_GEOMGRAPH_NODE_H
24
25 #include <geos/export.h>
26 #include <geos/geomgraph/GraphComponent.h> // for inheritance
27 #include <geos/geom/Coordinate.h> // for member
28
29 #ifndef NDEBUG
30 #include <geos/geomgraph/EdgeEndStar.h> // for testInvariant
31 #include <geos/geomgraph/EdgeEnd.h> // for testInvariant
32 #endif // ndef NDEBUG
33
34 #include <geos/inline.h>
35
36 #include <cassert>
37 #include <string>
38
39 #ifdef _MSC_VER
40 #pragma warning(push)
41 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
42 #endif
43
44 // Forward declarations
45 namespace geos {
46 namespace geom {
47 class IntersectionMatrix;
48 }
49 namespace geomgraph {
50 class Node;
51 class EdgeEndStar;
52 class EdgeEnd;
53 class Label;
54 class NodeFactory;
55 }
56 }
57
58 namespace geos {
59 namespace geomgraph { // geos.geomgraph
60
62 class GEOS_DLL Node: public GraphComponent {
63 using GraphComponent::setLabel;
64
65 public:
66
67 friend std::ostream& operator<< (std::ostream& os, const Node& node);
68
69 Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
70
71 virtual ~Node();
72
73 virtual const geom::Coordinate& getCoordinate() const;
74
75 virtual EdgeEndStar* getEdges();
76
77 virtual bool isIsolated() const;
78
82 virtual void add(EdgeEnd *e);
83
84 virtual void mergeLabel(const Node& n);
85
93 virtual void mergeLabel(const Label& label2);
94
95 virtual void setLabel(int argIndex, int onLocation);
96
101 virtual void setLabelBoundary(int argIndex);
102
111 virtual int computeMergedLocation(const Label& label2, int eltIndex);
112
113 virtual std::string print();
114
115 virtual const std::vector<double> &getZ() const;
116
117 virtual void addZ(double);
118
130 virtual bool isIncidentEdgeInResult() const;
131
132 protected:
133
134 void testInvariant() const;
135
136 geom::Coordinate coord;
137
138 EdgeEndStar* edges;
139
143 virtual void computeIM(geom::IntersectionMatrix& /*im*/) {}
144
145 private:
146
147 std::vector<double> zvals;
148
149 double ztot;
150
151 };
152
153 std::ostream& operator<< (std::ostream& os, const Node& node);
154
155 inline void
156 Node::testInvariant() const
157 {
158 #ifndef NDEBUG
159 if (edges)
160 {
161 // Each EdgeEnd in the star has this Node's
162 // coordinate as first coordinate
163 for (EdgeEndStar::iterator
164 it=edges->begin(), itEnd=edges->end();
165 it != itEnd; it++)
166 {
167 EdgeEnd* e=*it;
168 assert(e);
169 assert(e->getCoordinate().equals2D(coord));
170 }
171 }
172
173 #if 0 // We can't rely on numerical stability with FP computations
174 // ztot is the sum of doubnle sin zvals vector
175 double ztot_check=0.0;
176 for (std::vector<double>::const_iterator
177 i = zvals.begin(), e = zvals.end();
178 i != e;
179 i++)
180 {
181 ztot_check += *i;
182 }
183 assert(ztot_check == ztot);
184 #endif // 0
185
186 #endif
187 }
188
189
190 } // namespace geos.geomgraph
191 } // namespace geos
192
193 //#ifdef GEOS_INLINE
194 //# include "geos/geomgraph/Node.inl"
195 //#endif
196
197 #ifdef _MSC_VER
198 #pragma warning(pop)
199 #endif
200
201 #endif // ifndef GEOS_GEOMGRAPH_NODE_H