GEOS 3.9.1
geomgraph/Node.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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
45namespace geos {
46namespace geom {
47class IntersectionMatrix;
48}
49namespace geomgraph {
50class Node;
51class EdgeEndStar;
52class EdgeEnd;
53class Label;
54class NodeFactory;
55}
56}
57
58namespace geos {
59namespace geomgraph { // geos.geomgraph
60
62class GEOS_DLL Node: public GraphComponent {
63 using GraphComponent::setLabel;
64
65public:
66
67 friend std::ostream& operator<< (std::ostream& os, const Node& node);
68
69 Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
70
71 ~Node() override;
72
73 virtual const geom::Coordinate& getCoordinate() const;
74
75 virtual EdgeEndStar* getEdges();
76
77 bool isIsolated() const override;
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, geom::Location onLocation);
96
101 virtual void setLabelBoundary(int argIndex);
102
111 virtual geom::Location 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
132protected:
133
134 void testInvariant() const;
135
136 geom::Coordinate coord;
137
138 EdgeEndStar* edges;
139
143 void
145
146private:
147
148 std::vector<double> zvals;
149
150 double ztot;
151
152};
153
154std::ostream& operator<< (std::ostream& os, const Node& node);
155
156inline void
157Node::testInvariant() const
158{
159#ifndef NDEBUG
160 if(edges) {
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 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 ztot_check += *i;
180 }
181 assert(ztot_check == ztot);
182#endif // 0
183
184#endif
185}
186
187
188} // namespace geos.geomgraph
189} // namespace geos
190
191//#ifdef GEOS_INLINE
192//# include "geos/geomgraph/Node.inl"
193//#endif
194
195#ifdef _MSC_VER
196#pragma warning(pop)
197#endif
198
199#endif // ifndef GEOS_GEOMGRAPH_NODE_H
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition IntersectionMatrix.h:54
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition EdgeEndStar.h:65
Models the end of an edge incident on a node.
Definition EdgeEnd.h:56
A GraphComponent is the parent class for the objects' that form a graph.
Definition geomgraph/GraphComponent.h:47
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:59
The node component of a geometry graph.
Definition geomgraph/Node.h:62
virtual void setLabelBoundary(int argIndex)
Updates the label of a node to BOUNDARY, obeying the mod-2 boundaryDetermination rule.
virtual void mergeLabel(const Label &label2)
To merge labels for two nodes, the merged location for each LabelElement is computed.
virtual geom::Location computeMergedLocation(const Label &label2, int eltIndex)
virtual void add(EdgeEnd *e)
Add the edge to the list of edges at this node.
virtual bool isIncidentEdgeInResult() const
Tests whether any incident edge is flagged as being in the result.
void computeIM(geom::IntersectionMatrix &) override
Basic nodes do not compute IMs.
Definition geomgraph/Node.h:144
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:34
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26