GEOS 3.11.1
|
#include <HalfEdge.h>
Public Member Functions | |
HalfEdge (const geom::Coordinate &p_orig) | |
void | link (HalfEdge *p_sym) |
const geom::Coordinate & | orig () const |
const geom::Coordinate & | dest () const |
double | directionX () const |
double | directionY () const |
HalfEdge * | sym () const |
HalfEdge * | next () const |
HalfEdge * | prev () const |
HalfEdge * | oNext () const |
void | setNext (HalfEdge *e) |
HalfEdge * | find (const geom::Coordinate &dest) |
bool | equals (const geom::Coordinate &p0, const geom::Coordinate &p1) const |
void | insert (HalfEdge *eAdd) |
bool | isEdgesSorted () const |
int | compareAngularDirection (const HalfEdge *e) const |
int | compareTo (const HalfEdge *e) const |
int | degree () |
HalfEdge * | prevNode () |
Static Public Member Functions | |
static HalfEdge * | create (const geom::Coordinate &p0, const geom::Coordinate &p1) |
static void | toStringNode (const HalfEdge *he, std::ostream &os) |
Protected Member Functions | |
virtual const geom::Coordinate & | directionPt () const |
Friends | |
std::ostream & | operator<< (std::ostream &os, const HalfEdge &el) |
Represents a directed component of an edge in an EdgeGraph
. HalfEdges link vertices whose locations are defined by geom::Coordinate
s. HalfEdges start at an origin vertex, and terminate at a destination vertex. HalfEdges always occur in symmetric pairs, with the sym()
method giving access to the oppositely-oriented component. HalfEdges and the methods on them form an edge algebra, which can be used to traverse and query the topology of the graph formed by the edges.
To support graphs where the edges are sequences of coordinates each edge may also have a direction point supplied. This is used to determine the ordering of the edges around the origin. HalfEdges with the same origin are ordered so that the ring of edges formed by them is oriented CCW.
By design HalfEdges carry minimal information about the actual usage of the graph they represent. They can be subclassed to carry more information if required.
HalfEdges form a complete and consistent data structure by themselves, but an EdgeGraph
is useful to allow retrieving edges by vertex and edge location, as well as ensuring edges are created and linked appropriately.
|
inline |
Creates a half-edge originating from a given coordinate.
p_orig | the origin coordinate |
int geos::edgegraph::HalfEdge::compareAngularDirection | ( | const HalfEdge * | e | ) | const |
Implements the total order relation:
The angle of edge a is greater than the angle of edge b, where the angle of an edge is the angle made by the first segment of the edge with the positive x-axis
When applied to a list of edges originating at the same point, this produces a CCW ordering of the edges around the point.
Using the obvious algorithm of computing the angle is not robust, since the angle calculation is susceptible to roundoff error. A robust algorithm is:
|
static |
int geos::edgegraph::HalfEdge::degree | ( | ) |
Computes the degree of the origin vertex. The degree is the number of edges originating from the vertex.
|
inline |
Gets the destination coordinate of this edge.
|
inlineprotectedvirtual |
Gets the direction point of this edge. In the base case this is the dest coordinate of the edge. Subclasses may override to allow a HalfEdge to represent an edge with more than two coordinates.
Reimplemented in geos::operation::overlayng::OverlayEdge.
|
inline |
The X component of the direction vector.
References geos::geom::Coordinate::x.
|
inline |
The Y component of the direction vector.
References geos::geom::Coordinate::y.
bool geos::edgegraph::HalfEdge::equals | ( | const geom::Coordinate & | p0, |
const geom::Coordinate & | p1 | ||
) | const |
Tests whether this edge has the given orig and dest vertices.
p0 | the origin vertex to test |
p1 | the destination vertex to test |
HalfEdge * geos::edgegraph::HalfEdge::find | ( | const geom::Coordinate & | dest | ) |
Finds the edge starting at the origin of this edge with the given dest vertex, if any.
dest | the dest vertex to search for |
void geos::edgegraph::HalfEdge::insert | ( | HalfEdge * | eAdd | ) |
Inserts an edge into the ring of edges around the origin vertex of this edge, ensuring that the edges remain ordered CCW. The inserted edge must have the same origin as this edge.
eAdd | the edge to insert |
bool geos::edgegraph::HalfEdge::isEdgesSorted | ( | ) | const |
Tests whether the edges around the origin are sorted correctly. Note that edges must be strictly increasing, which implies no two edges can have the same direction point.
void geos::edgegraph::HalfEdge::link | ( | HalfEdge * | p_sym | ) |
Links this edge with its sym (opposite) edge. This must be done for each pair of edges created.
p_sym | the sym edge to link. |
|
inline |
Gets the next edge CCW around the destination vertex of this edge, with the dest vertex as its origin. If the vertex has degree 1 then this is the sym edge.
|
inline |
Gets the next edge CCW around the origin of this edge, with the same origin.
e.oNext() is equal to e.sym().next()
|
inline |
Gets the origin coordinate of this edge.
HalfEdge * geos::edgegraph::HalfEdge::prev | ( | ) | const |
Gets the edge previous to this one (with dest being the same as this orig).
It is always true that e.next().prev() == e
Note that this requires a scan of the origin edges, so may not be efficient for some uses.
HalfEdge * geos::edgegraph::HalfEdge::prevNode | ( | ) |
Finds the first node previous to this edge, if any. A node has degree <> 2. If no such node exists (i.e. the edge is part of a ring) then null is returned.
|
inline |
Sets the next edge CCW around the destination vertex of this edge.
e | the next edge |
|
inline |
Gets the symmetric pair edge of this edge.