geomgraph/Node.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: geomgraph/Node.java r411 (JTS-1.12+)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geomgraph/GraphComponent.h> // for inheritance
#include <geos/geom/Coordinate.h> // for member
#ifndef NDEBUG
#include <geos/geomgraph/EdgeEndStar.h> // for testInvariant
#include <geos/geomgraph/EdgeEnd.h> // for testInvariant
#endif // ndef NDEBUG
#include <cassert>
#include <string>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class IntersectionMatrix;
}
namespace geomgraph {
class Node;
class EdgeEndStar;
class EdgeEnd;
class Label;
class NodeFactory;
}
}
namespace geos {
namespace geomgraph { // geos.geomgraph
class GEOS_DLL Node /* non-final */: public GraphComponent {
using GraphComponent::setLabel;
public:
friend std::ostream& operator<< (std::ostream& os, const Node& node);
Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
~Node() override;
const geom::Coordinate& getCoordinate() const;
EdgeEndStar* getEdges();
bool isIsolated() const override;
void add(EdgeEnd* e);
void mergeLabel(const Node& n);
void mergeLabel(const Label& label2);
void setLabel(uint8_t argIndex, geom::Location onLocation);
void setLabelBoundary(uint8_t argIndex);
geom::Location computeMergedLocation(const Label& label2, uint8_t eltIndex);
std::string print() const;
const std::vector<double>& getZ() const;
void addZ(double);
bool isIncidentEdgeInResult() const;
protected:
void testInvariant() const;
geom::Coordinate coord;
EdgeEndStar* edges;
void
computeIM(geom::IntersectionMatrix& /*im*/) override {}
private:
std::vector<double> zvals;
double ztot;
};
std::ostream& operator<< (std::ostream& os, const Node& node);
inline void
Node::testInvariant() const
{
#ifndef NDEBUG
if(edges) {
// Each EdgeEnd in the star has this Node's
// coordinate as first coordinate
for(EdgeEndStar::iterator
it = edges->begin(), itEnd = edges->end();
it != itEnd; it++) {
EdgeEnd* e = *it;
assert(e);
assert(e->getCoordinate().equals2D(coord));
}
}
#if 0
// We can't rely on numerical stability with FP computations
// ztot is the sum of doubnle sin zvals vector
double ztot_check = 0.0;
for(std::vector<double>::const_iterator
i = zvals.begin(), e = zvals.end();
i != e;
i++) {
ztot_check += *i;
}
assert(ztot_check == ztot);
#endif // 0
#endif
}
} // namespace geos.geomgraph
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::IntersectionMatrix
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition IntersectionMatrix.h:51
geos::geomgraph::EdgeEndStar
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition EdgeEndStar.h:63
geos::geomgraph::EdgeEnd
Models the end of an edge incident on a node.
Definition EdgeEnd.h:54
geos::geomgraph::Label
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:57
geos::geomgraph::Node
The node component of a geometry graph.
Definition geomgraph/Node.h:59
geos::geomgraph::Node::mergeLabel
void mergeLabel(const Label &label2)
To merge labels for two nodes, the merged location for each LabelElement is computed.
geos::geomgraph::Node::setLabelBoundary
void setLabelBoundary(uint8_t argIndex)
Updates the label of a node to BOUNDARY, obeying the mod-2 boundaryDetermination rule.
geos::geomgraph::Node::isIncidentEdgeInResult
bool isIncidentEdgeInResult() const
Tests whether any incident edge is flagged as being in the result.
geos::geomgraph::Node::add
void add(EdgeEnd *e)
Add the edge to the list of edges at this node.
geos::geomgraph::Node::computeMergedLocation
geom::Location computeMergedLocation(const Label &label2, uint8_t eltIndex)
geos::geomgraph::Node::computeIM
void computeIM(geom::IntersectionMatrix &) override
Basic nodes do not compute IMs.
Definition geomgraph/Node.h:141
geos::geom
Definition Angle.h:26
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
geos::geomgraph
Contains classes that implement topology graphs.
Definition Depth.h:31
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38