GEOS  3.9.1dev
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
geos::planargraph::DirectedEdge Class Reference

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

#include <DirectedEdge.h>

Inheritance diagram for geos::planargraph::DirectedEdge:
[legend]
Collaboration diagram for geos::planargraph::DirectedEdge:
[legend]

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. More...
 
EdgegetEdge () const
 Returns this DirectedEdge's parent Edge, or null if it has none. More...
 
void setEdge (Edge *newParentEdge)
 Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge). More...
 
int getQuadrant () const
 Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies. More...
 
const geom::CoordinategetDirectionPt () const
 Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's orientation. More...
 
bool getEdgeDirection () const
 Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge. More...
 
NodegetFromNode () const
 Returns the node from which this DirectedEdge leaves. More...
 
NodegetToNode () const
 Returns the node to which this DirectedEdge goes. More...
 
geom::CoordinategetCoordinate () const
 Returns the coordinate of the from-node. More...
 
double getAngle () const
 Returns the angle that the start of this DirectedEdge makes with the positive x-axis, in radians. More...
 
DirectedEdgegetSym () const
 Returns the symmetric DirectedEdge – the other DirectedEdge associated with this DirectedEdge's parent Edge. More...
 
void setSym (DirectedEdge *newSym)
 Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction. More...
 
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. More...
 
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. More...
 
std::string print () const
 Prints a detailed string representation of this DirectedEdge to the given PrintStream. More...
 
- Public Member Functions inherited from geos::planargraph::GraphComponent
 GraphComponent ()
 
virtual ~GraphComponent ()
 
virtual bool isVisited () const
 Tests if a component has been visited during the course of a graph algorithm. More...
 
virtual void setVisited (bool p_isVisited)
 Sets the visited flag for this component. More...
 
virtual bool isMarked () const
 Tests if a component has been marked at some point during the processing involving this graph. More...
 
virtual void setMarked (bool p_isMarked)
 Sets the marked flag for this component. More...
 

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. More...
 
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. More...
 
- Static Public Member Functions inherited from geos::planargraph::GraphComponent
template<typename T >
static void setVisited (T start, T end, bool visited)
 Sets the Visited state for the elements of a container, from start to end iterator. More...
 
template<typename T >
static void setVisitedMap (T start, T end, bool visited)
 Sets the Visited state for the values of each map container element, from start to end iterator. More...
 
template<typename T >
static void setMarked (T start, T end, bool marked)
 Sets the Marked state for the elements of a container, from start to end iterator. More...
 
template<typename T >
static void setMarkedMap (T start, T end, bool marked)
 Sets the Marked state for the values of each map container element, from start to end iterator. More...
 

Protected Attributes

EdgeparentEdge
 
Nodefrom
 
Nodeto
 
geom::Coordinate p0
 
geom::Coordinate p1
 
DirectedEdgesym
 
bool edgeDirection
 
int quadrant
 
double angle
 
- Protected Attributes inherited from geos::planargraph::GraphComponent
bool isMarkedVar
 Variable holding ''marked'' status. More...
 
bool isVisitedVar
 Variable holding ''visited'' status. More...
 

Friends

std::ostream & operator<< (std::ostream &, const DirectedEdge &)
 Output operator. More...
 

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.

Definition at line 46 of file planargraph/DirectedEdge.h.

Member Typedef Documentation

Definition at line 53 of file planargraph/DirectedEdge.h.

Definition at line 67 of file planargraph/DirectedEdge.h.

Definition at line 52 of file planargraph/DirectedEdge.h.

Definition at line 54 of file planargraph/DirectedEdge.h.

Definition at line 68 of file planargraph/DirectedEdge.h.

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
newFromfrom node
newToto node
directionPtspecifies this DirectedEdge's direction (given by an imaginary line from the from node to directionPt)
newEdgeDirectionwhether 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 Orientation::index(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 Orientation::index(Coordinate, Coordinate, Coordinate) function can be used to decide the relative orientation of the vectors.
double geos::planargraph::DirectedEdge::getAngle ( ) const

Returns the angle that the start of this DirectedEdge makes with the positive x-axis, in radians.

geom::Coordinate& geos::planargraph::DirectedEdge::getCoordinate ( ) const

Returns the coordinate of the from-node.

const geom::Coordinate& geos::planargraph::DirectedEdge::getDirectionPt ( ) const

Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's orientation.

Edge* geos::planargraph::DirectedEdge::getEdge ( ) const

Returns this DirectedEdge's parent Edge, or null if it has none.

bool geos::planargraph::DirectedEdge::getEdgeDirection ( ) const

Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge.

Node* geos::planargraph::DirectedEdge::getFromNode ( ) const

Returns the node from which this DirectedEdge leaves.

int geos::planargraph::DirectedEdge::getQuadrant ( ) const

Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.

DirectedEdge* geos::planargraph::DirectedEdge::getSym ( ) const

Returns the symmetric DirectedEdge – the other DirectedEdge associated with this DirectedEdge's parent Edge.

Node* geos::planargraph::DirectedEdge::getToNode ( ) const

Returns the node to which this DirectedEdge goes.

std::string geos::planargraph::DirectedEdge::print ( ) const

Prints a detailed string representation of this DirectedEdge to the given PrintStream.

void geos::planargraph::DirectedEdge::setEdge ( Edge newParentEdge)

Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).

void geos::planargraph::DirectedEdge::setSym ( DirectedEdge newSym)

Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.

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.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const DirectedEdge  
)
friend

Output operator.

Member Data Documentation

double geos::planargraph::DirectedEdge::angle
protected

Definition at line 64 of file planargraph/DirectedEdge.h.

bool geos::planargraph::DirectedEdge::edgeDirection
protected

Definition at line 62 of file planargraph/DirectedEdge.h.

Node* geos::planargraph::DirectedEdge::from
protected

Definition at line 58 of file planargraph/DirectedEdge.h.

geom::Coordinate geos::planargraph::DirectedEdge::p0
protected

Definition at line 60 of file planargraph/DirectedEdge.h.

geom::Coordinate geos::planargraph::DirectedEdge::p1
protected

Definition at line 60 of file planargraph/DirectedEdge.h.

Edge* geos::planargraph::DirectedEdge::parentEdge
protected

Definition at line 57 of file planargraph/DirectedEdge.h.

int geos::planargraph::DirectedEdge::quadrant
protected

Definition at line 63 of file planargraph/DirectedEdge.h.

DirectedEdge* geos::planargraph::DirectedEdge::sym
protected

Definition at line 61 of file planargraph/DirectedEdge.h.

Node* geos::planargraph::DirectedEdge::to
protected

Definition at line 59 of file planargraph/DirectedEdge.h.


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