# geos::planargraph::DirectedEdge Class Reference

Represents a directed edge in a PlanarGraph. More...

`#include <DirectedEdge.h>`

Inheritance diagram for geos::planargraph::DirectedEdge:

List of all members.

## Public Types

typedef std::list< DirectedEdge * > | NonConstList
typedef std::list< const DirectedEdge * > | ConstList
typedef std::vector < DirectedEdge * > | NonConstVect
typedef std::vector< const DirectedEdge * > | ConstVect
typedef std::vector < DirectedEdge * > | Vect

## Public Member Functions

| DirectedEdge (Node *newFrom, Node *newTo, const geom::Coordinate &directionPt, bool newEdgeDirection)
| Constructs a DirectedEdge connecting the `from` node to the `to` node.
Edge * | getEdge () const
| Returns this DirectedEdge's parent Edge, or null if it has none.
void | setEdge (Edge *newParentEdge)
| Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).
int | getQuadrant () const
| Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.
const geom::Coordinate & | getDirectionPt () const
| Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's orientation.
bool | getEdgeDirection () const
| Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge.
Node * | getFromNode () const
| Returns the node from which this DirectedEdge leaves.
Node * | getToNode () const
| Returns the node to which this DirectedEdge goes.
geom::Coordinate & | getCoordinate () const
| Returns the coordinate of the from-node.
double | getAngle () const
| Returns the angle that the start of this DirectedEdge makes with the positive x-axis, in radians.
DirectedEdge * | getSym () const
| Returns the symmetric DirectedEdge -- the other DirectedEdge associated with this DirectedEdge's parent Edge.
void | setSym (DirectedEdge *newSym)
| Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.
int | compareTo (const DirectedEdge *obj) const
| Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
int | compareDirection (const DirectedEdge *e) const
| Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
std::string | print () const
| Prints a detailed string representation of this DirectedEdge to the given PrintStream.

## Static Public Member Functions

static std::vector< Edge * > * | toEdges (std::vector< DirectedEdge * > &dirEdges)
| Returns a List containing the parent Edge (possibly null) for each of the given DirectedEdges.
static void | toEdges (std::vector< DirectedEdge * > &dirEdges, std::vector< Edge * > &parentEdges)
| Add parent Edge (possibly null) of each of the given DirectedEdges to the given parentEdges vector.

## Protected Attributes

Edge * | parentEdge
Node * | from
Node * | to
geom::Coordinate | p0
geom::Coordinate | p1
DirectedEdge * | sym
bool | edgeDirection
int | quadrant
double | angle

## Detailed Description

Represents a directed edge in a PlanarGraph.

A DirectedEdge may or may not have a reference to a parent Edge (some applications of planar graphs may not require explicit Edge objects to be created). Usually a client using a PlanarGraph will subclass DirectedEdge to add its own application-specific data and methods.

## Constructor & Destructor Documentation

geos::planargraph::DirectedEdge::DirectedEdge | ( | Node * | newFrom,
|  | Node * | newTo,
|  | const geom::Coordinate & | directionPt,
|  | bool | newEdgeDirection
| ) |  |

Constructs a DirectedEdge connecting the `from` node to the `to` node.

Parameters:

  directionPt | specifies this DirectedEdge's direction (given by an imaginary line from the `from` node to `directionPt`)
  edgeDirection | whether this DirectedEdge's direction is the same as or opposite to that of the parent Edge (if any)

## Member Function Documentation

int geos::planargraph::DirectedEdge::compareDirection | ( | const DirectedEdge * | e ) | const

Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.

Using the obvious algorithm of simply computing the angle is not robust, since the angle calculation is susceptible to roundoff. A robust algorithm is:

- first compare the quadrants. If the quadrants are different, it it trivial to determine which std::vector is "greater".
- if the vectors lie in the same quadrant, the robust RobustCGAlgorithms::computeOrientation(Coordinate, Coordinate, Coordinate) function can be used to decide the relative orientation of the vectors.

int geos::planargraph::DirectedEdge::compareTo | ( | const DirectedEdge * | obj ) | const

Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.

Using the obvious algorithm of simply computing the angle is not robust, since the angle calculation is susceptible to roundoff. A robust algorithm is:

- first compare the quadrants. If the quadrants are different, it it trivial to determine which std::vector is "greater".
- if the vectors lie in the same quadrant, the robust RobustCGAlgorithms::computeOrientation(Coordinate, Coordinate, Coordinate) function can be used to decide the relative orientation of the vectors.

static std::vector<Edge*>* geos::planargraph::DirectedEdge::toEdges | ( | std::vector< DirectedEdge * > & | dirEdges ) | `[static]`

Returns a List containing the parent Edge (possibly null) for each of the given DirectedEdges.

NOTE: ownership of the returned vector is left to the caller, see the equivalent function taking a vector reference to avoid this.

static void geos::planargraph::DirectedEdge::toEdges | ( | std::vector< DirectedEdge * > & | dirEdges,
|  | std::vector< Edge * > & | parentEdges
| ) |  | `[static]`

Add parent Edge (possibly null) of each of the given DirectedEdges to the given parentEdges vector.

NOTE: parents are pushed to the parentEdges vector, make sure it is empty if index-based corrispondence is important.

The documentation for this class was generated from the following file:

- planargraph/DirectedEdge.h