GEOS 3.11.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#pragma once
23
24#include <geos/export.h>
25#include <geos/geomgraph/GraphComponent.h> // for inheritance
26#include <geos/geom/Coordinate.h> // for member
27
28#ifndef NDEBUG
29#include <geos/geomgraph/EdgeEndStar.h> // for testInvariant
30#include <geos/geomgraph/EdgeEnd.h> // for testInvariant
31#endif // ndef NDEBUG
32
33#include <cassert>
34#include <string>
35
36#ifdef _MSC_VER
37#pragma warning(push)
38#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
39#endif
40
41// Forward declarations
42namespace geos {
43namespace geom {
44class IntersectionMatrix;
45}
46namespace geomgraph {
47class Node;
48class EdgeEndStar;
49class EdgeEnd;
50class Label;
51class NodeFactory;
52}
53}
54
55namespace geos {
56namespace geomgraph { // geos.geomgraph
57
59class GEOS_DLL Node: public GraphComponent {
60 using GraphComponent::setLabel;
61
62public:
63
64 friend std::ostream& operator<< (std::ostream& os, const Node& node);
65
66 Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
67
68 ~Node() override;
69
70 virtual const geom::Coordinate& getCoordinate() const;
71
72 virtual EdgeEndStar* getEdges();
73
74 bool isIsolated() const override;
75
79 virtual void add(EdgeEnd* e);
80
81 virtual void mergeLabel(const Node& n);
82
90 virtual void mergeLabel(const Label& label2);
91
92 virtual void setLabel(uint8_t argIndex, geom::Location onLocation);
93
98 virtual void setLabelBoundary(uint8_t argIndex);
99
108 virtual geom::Location computeMergedLocation(const Label& label2, uint8_t eltIndex);
109
110 virtual std::string print();
111
112 virtual const std::vector<double>& getZ() const;
113
114 virtual void addZ(double);
115
127 virtual bool isIncidentEdgeInResult() const;
128
129protected:
130
131 void testInvariant() const;
132
133 geom::Coordinate coord;
134
135 EdgeEndStar* edges;
136
140 void
142
143private:
144
145 std::vector<double> zvals;
146
147 double ztot;
148
149};
150
151std::ostream& operator<< (std::ostream& os, const Node& node);
152
153inline void
154Node::testInvariant() const
155{
156#ifndef NDEBUG
157 if(edges) {
158 // Each EdgeEnd in the star has this Node's
159 // coordinate as first coordinate
160 for(EdgeEndStar::iterator
161 it = edges->begin(), itEnd = edges->end();
162 it != itEnd; it++) {
163 EdgeEnd* e = *it;
164 assert(e);
165 assert(e->getCoordinate().equals2D(coord));
166 }
167 }
168
169#if 0
170 // We can't rely on numerical stability with FP computations
171 // ztot is the sum of doubnle sin zvals vector
172 double ztot_check = 0.0;
173 for(std::vector<double>::const_iterator
174 i = zvals.begin(), e = zvals.end();
175 i != e;
176 i++) {
177 ztot_check += *i;
178 }
179 assert(ztot_check == ztot);
180#endif // 0
181
182#endif
183}
184
185
186} // namespace geos.geomgraph
187} // namespace geos
188
189#ifdef _MSC_VER
190#pragma warning(pop)
191#endif
192
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition: IntersectionMatrix.h:51
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition: EdgeEndStar.h:62
Models the end of an edge incident on a node.
Definition: EdgeEnd.h:54
A GraphComponent is the parent class for the objects' that form a graph.
Definition: geomgraph/GraphComponent.h:45
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition: Label.h:57
The node component of a geometry graph.
Definition: geomgraph/Node.h:59
virtual void mergeLabel(const Label &label2)
To merge labels for two nodes, the merged location for each LabelElement is computed.
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.
virtual void setLabelBoundary(uint8_t argIndex)
Updates the label of a node to BOUNDARY, obeying the mod-2 boundaryDetermination rule.
virtual geom::Location computeMergedLocation(const Label &label2, uint8_t eltIndex)
void computeIM(geom::IntersectionMatrix &) override
Basic nodes do not compute IMs.
Definition: geomgraph/Node.h:141
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:32
Basic namespace for all GEOS functionalities.
Definition: geos.h:39