geomgraph/Edge.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/Edge.java r428 (JTS-1.12+)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <string>
#include <cassert>
#include <geos/geomgraph/GraphComponent.h> // for inheritance
#include <geos/geomgraph/Depth.h> // for member
#include <geos/geomgraph/EdgeIntersectionList.h> // for composition
#include <geos/geom/CoordinateSequence.h> // for inlines
#include <geos/geom/Envelope.h>
#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;
class Coordinate;
}
namespace algorithm {
class LineIntersector;
}
namespace geomgraph {
class Node;
class EdgeEndStar;
class Label;
class NodeFactory;
namespace index {
class MonotoneChainEdge;
}
}
}
namespace geos {
namespace geomgraph { // geos.geomgraph
class GEOS_DLL Edge final: public GraphComponent {
using GraphComponent::updateIM;
private:
std::unique_ptr<index::MonotoneChainEdge> mce;
geom::Envelope env;
Depth depth;
int depthDelta; // the change in area depth from the R to L side of this edge
bool isIsolatedVar;
public:
void
testInvariant() const
{
assert(pts);
assert(pts->size() > 1);
}
friend std::ostream& operator<< (std::ostream& os, const Edge& el);
static void updateIM(const Label& lbl, geom::IntersectionMatrix& im);
std::unique_ptr<geom::CoordinateSequence> pts;
EdgeIntersectionList eiList;
Edge(geom::CoordinateSequence* newPts, const Label& newLabel);
Edge(geom::CoordinateSequence* newPts);
~Edge() override;
size_t
getNumPoints() const
{
return pts->getSize();
}
const geom::CoordinateSequence*
getCoordinates() const
{
testInvariant();
return pts.get();
}
const geom::Coordinate&
getCoordinate(std::size_t i) const
{
testInvariant();
return pts->getAt(i);
}
const geom::Coordinate&
getCoordinate() const
{
testInvariant();
return pts->getAt(0);
}
const Depth&
getDepth() const
{
testInvariant();
return depth;
}
int
getDepthDelta() const
{
testInvariant();
return depthDelta;
}
void
setDepthDelta(int newDepthDelta)
{
depthDelta = newDepthDelta;
testInvariant();
}
size_t
getMaximumSegmentIndex() const
{
testInvariant();
return getNumPoints() - 1;
}
EdgeIntersectionList&
getEdgeIntersectionList()
{
testInvariant();
return eiList;
}
const EdgeIntersectionList&
getEdgeIntersectionList() const
{
testInvariant();
return eiList;
}
index::MonotoneChainEdge* getMonotoneChainEdge();
bool
isClosed() const
{
testInvariant();
return pts->getAt(0) == pts->getAt(getNumPoints() - 1);
}
bool isCollapsed() const;
Edge* getCollapsedEdge();
void
setIsolated(bool newIsIsolated)
{
isIsolatedVar = newIsIsolated;
testInvariant();
}
bool
isIsolated() const override
{
testInvariant();
return isIsolatedVar;
}
void addIntersections(algorithm::LineIntersector* li, std::size_t segmentIndex,
std::size_t geomIndex);
//
void addIntersection(algorithm::LineIntersector* li, std::size_t segmentIndex,
std::size_t geomIndex, std::size_t intIndex);
//
void
computeIM(geom::IntersectionMatrix& im) override
{
updateIM(label, im);
testInvariant();
}
bool isPointwiseEqual(const Edge* e) const;
std::string print() const;
std::string printReverse() const;
bool equals(const Edge& e) const;
bool
equals(const Edge* e) const
{
assert(e);
return equals(*e);
}
const geom::Envelope* getEnvelope();
};
//Operators
inline bool
operator==(const Edge& a, const Edge& b)
{
return a.equals(b);
}
std::ostream& operator<< (std::ostream& os, const Edge& el);
} // namespace geos.geomgraph
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::algorithm::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::IntersectionMatrix
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition IntersectionMatrix.h:51
geos::geomgraph::Depth
A Depth object records the topological depth of the sides of an Edge for up to two Geometries.
Definition Depth.h:41
geos::geomgraph::EdgeEndStar
A EdgeEndStar is an ordered list of EdgeEnds around a node.
Definition EdgeEndStar.h:63
geos::geomgraph::EdgeIntersectionList
A list of edge intersections along an Edge.
Definition EdgeIntersectionList.h:57
geos::geomgraph::Edge::isPointwiseEqual
bool isPointwiseEqual(const Edge *e) const
return true if the coordinate sequences of the Edges are identical
geos::geomgraph::Edge::getDepthDelta
int getDepthDelta() const
The depthDelta is the change in depth as an edge is crossed from R to L.
Definition geomgraph/Edge.h:146
geos::geomgraph::Edge::equals
bool equals(const Edge &e) const
geos::geomgraph::Edge::isCollapsed
bool isCollapsed() const
An Edge is collapsed if it is an Area edge and it consists of two segments which are equal and opposi...
geos::geomgraph::Edge::Edge
Edge(geom::CoordinateSequence *newPts, const Label &newLabel)
Takes ownership of CoordinateSequence.
geos::geomgraph::Edge::addIntersections
void addIntersections(algorithm::LineIntersector *li, std::size_t segmentIndex, std::size_t geomIndex)
Adds EdgeIntersections for one or both intersections found for a segment of an edge to the edge inter...
geos::geomgraph::Edge::computeIM
void computeIM(geom::IntersectionMatrix &im) override
Update the IM with the contribution for this component.
Definition geomgraph/Edge.h:236
geos::geomgraph::Edge::pts
std::unique_ptr< geom::CoordinateSequence > pts
Externally-set, owned by Edge. FIXME: refuse ownership.
Definition geomgraph/Edge.h:93
geos::geomgraph::Edge::Edge
Edge(geom::CoordinateSequence *newPts)
Takes ownership of CoordinateSequence.
geos::geomgraph::Edge::getMonotoneChainEdge
index::MonotoneChainEdge * getMonotoneChainEdge()
Return this Edge's index::MonotoneChainEdge, ownership is retained by this object.
geos::geomgraph::Edge::addIntersection
void addIntersection(algorithm::LineIntersector *li, std::size_t segmentIndex, std::size_t geomIndex, std::size_t intIndex)
Add an EdgeIntersection for intersection intIndex.
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::index::MonotoneChainEdge
MonotoneChains are a way of partitioning the segments of an edge to allow for fast searching of inter...
Definition MonotoneChainEdge.h:45
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::geomgraph::index
Contains classes that implement indexes for performing noding on geometry graph edges.
Definition geomgraph/Edge.h:53
geos::geomgraph
Contains classes that implement topology graphs.
Definition Depth.h:31
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38