GEOS 3.3.4

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

- File List

geomgraph/Node.h
1 /**********************************************************************
2 * $Id: Node.h 2958 2010-03-29 11:29:40Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
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 rev. 1.7 (JTS-1.10)
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
61 class GEOS_DLL Node: public GraphComponent {
62 using GraphComponent::setLabel;
63
64 public:
65
66 friend std::ostream& operator<< (std::ostream& os, const Node& node);
67
68 Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
69
70 virtual ~Node();
71
72 virtual const geom::Coordinate& getCoordinate() const;
73
74 virtual EdgeEndStar* getEdges();
75
76 virtual bool isIsolated() const;
77
81 virtual void add(EdgeEnd *e);
82
83 virtual void mergeLabel(const Node& n);
84
92 virtual void mergeLabel(const Label& label2);
93
94 virtual void setLabel(int argIndex, int onLocation);
95
100 virtual void setLabelBoundary(int argIndex);
101
110 virtual int computeMergedLocation(const Label* label2, int eltIndex);
111
112 virtual std::string print();
113
114 virtual const std::vector<double> &getZ() const;
115
116 virtual void addZ(double);
117
129 virtual bool isIncidentEdgeInResult() const;
130
131 protected:
132
133 void testInvariant() const;
134
135 geom::Coordinate coord;
136
137 EdgeEndStar* edges;
138
142 virtual void computeIM(geom::IntersectionMatrix* /*im*/) {};
143
144 private:
145
146 std::vector<double> zvals;
147
148 double ztot;
149
150 };
151
152 std::ostream& operator<< (std::ostream& os, const Node& node);
153
154 inline void
155 Node::testInvariant() const
156 {
157 #ifndef NDEBUG
158 if (edges)
159 {
160 // Each EdgeEnd in the star has this Node's
161 // coordinate as first coordinate
162 for (EdgeEndStar::iterator
163 it=edges->begin(), itEnd=edges->end();
164 it != itEnd; it++)
165 {
166 EdgeEnd* e=*it;
167 assert(e);
168 assert(e->getCoordinate().equals2D(coord));
169 }
170 }
171
172 #if 0 // We can't rely on numerical stability with FP computations
173 // ztot is the sum of doubnle sin zvals vector
174 double ztot_check=0.0;
175 for (std::vector<double>::const_iterator
176 i = zvals.begin(), e = zvals.end();
177 i != e;
178 i++)
179 {
180 ztot_check += *i;
181 }
182 assert(ztot_check == ztot);
183 #endif // 0
184
185 #endif
186 }
187
188
189 } // namespace geos.geomgraph
190 } // namespace geos
191
192 //#ifdef GEOS_INLINE
193 //# include "geos/geomgraph/Node.inl"
194 //#endif
195
196 #ifdef _MSC_VER
197 #pragma warning(pop)
198 #endif
199
200 #endif // ifndef GEOS_GEOMGRAPH_NODE_H
201
202 /**********************************************************************
203 * $Log$
204 * Revision 1.6 2006/06/01 11:49:36 strk
205 * Reduced installed headers form geomgraph namespace
206 *
207 * Revision 1.5 2006/04/27 15:15:06 strk
208 * Z check removed from invariant tester to avoid aborts due to differences in FP computations.
209 *
210 * Revision 1.4 2006/04/07 16:01:51 strk
211 * Port info, doxygen comments, testInvariant(), many assertionss, handling of
212 * the NULL EdgeEndStar member
213 *
214 * Revision 1.3 2006/03/24 09:52:41 strk
215 * USE_INLINE => GEOS_INLINE
216 *
217 * Revision 1.2 2006/03/15 16:27:54 strk
218 * operator<< for Node class
219 *
220 * Revision 1.1 2006/03/09 16:46:49 strk
221 * geos::geom namespace definition, first pass at headers split
222 *
223 **********************************************************************/
224