planargraph/DirectedEdge.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
* Copyright (C) 2005-2006 Refractions Research 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.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/planargraph/GraphComponent.h> // for inheritance
#include <geos/geom/Coordinate.h> // for composition
#include <vector> // for typedefs
#include <list> // for typedefs
// Forward declarations
namespace geos {
namespace planargraph {
class Edge;
class Node;
}
}
namespace geos {
namespace planargraph { // geos.planargraph
class GEOS_DLL DirectedEdge: public GraphComponent {
public:
friend std::ostream& operator << (std::ostream&, const DirectedEdge&);
typedef std::list<DirectedEdge*> NonConstList;
typedef std::list<const DirectedEdge*> ConstList;
typedef std::vector<DirectedEdge*> NonConstVect;
protected:
Edge* parentEdge;
Node* from;
Node* to;
geom::Coordinate p0, p1;
DirectedEdge* sym; // optional
bool edgeDirection;
int quadrant;
double angle;
public:
typedef std::vector<const DirectedEdge*> ConstVect;
typedef std::vector<DirectedEdge*> Vect;
static std::vector<Edge*>* toEdges(
std::vector<DirectedEdge*>& dirEdges);
static void toEdges(std::vector<DirectedEdge*>& dirEdges,
std::vector<Edge*>& parentEdges);
DirectedEdge(Node* newFrom, Node* newTo,
const geom::Coordinate& directionPt,
bool newEdgeDirection);
Edge* getEdge() const;
void setEdge(Edge* newParentEdge);
int getQuadrant() const;
const geom::Coordinate& getDirectionPt() const;
bool getEdgeDirection() const;
Node* getFromNode() const;
Node* getToNode() const;
geom::Coordinate& getCoordinate() const;
double getAngle() const;
DirectedEdge* getSym() const;
void setSym(DirectedEdge* newSym);
int compareTo(const DirectedEdge* obj) const;
int compareDirection(const DirectedEdge* e) const;
std::string print() const;
};
bool pdeLessThan(DirectedEdge* first, DirectedEdge* second);
std::ostream& operator << (std::ostream&, const DirectedEdge&);
} // namespace geos::planargraph
} // namespace geos
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::planargraph::DirectedEdge
Represents a directed edge in a PlanarGraph.
Definition planargraph/DirectedEdge.h:45
geos::planargraph::DirectedEdge::getToNode
Node * getToNode() const
Returns the node to which this DirectedEdge goes.
geos::planargraph::DirectedEdge::getFromNode
Node * getFromNode() const
Returns the node from which this DirectedEdge leaves.
geos::planargraph::DirectedEdge::compareTo
int compareTo(const DirectedEdge *obj) const
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b",...
geos::planargraph::DirectedEdge::DirectedEdge
DirectedEdge(Node *newFrom, Node *newTo, const geom::Coordinate &directionPt, bool newEdgeDirection)
Constructs a DirectedEdge connecting the from node to the to node.
geos::planargraph::DirectedEdge::getDirectionPt
const geom::Coordinate & getDirectionPt() const
Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's...
geos::planargraph::DirectedEdge::getEdge
Edge * getEdge() const
Returns this DirectedEdge's parent Edge, or null if it has none.
geos::planargraph::DirectedEdge::getQuadrant
int getQuadrant() const
Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.
geos::planargraph::DirectedEdge::setEdge
void setEdge(Edge *newParentEdge)
Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).
geos::planargraph::DirectedEdge::toEdges
static std::vector< Edge * > * toEdges(std::vector< DirectedEdge * > &dirEdges)
Returns a List containing the parent Edge (possibly null) for each of the given DirectedEdges.
geos::planargraph::DirectedEdge::getSym
DirectedEdge * getSym() const
Returns the symmetric DirectedEdge – the other DirectedEdge associated with this DirectedEdge's paren...
geos::planargraph::DirectedEdge::getAngle
double getAngle() const
Returns the angle that the start of this DirectedEdge makes with the positive x-axis,...
geos::planargraph::DirectedEdge::setSym
void setSym(DirectedEdge *newSym)
Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.
geos::planargraph::DirectedEdge::getEdgeDirection
bool getEdgeDirection() const
Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge.
geos::planargraph::DirectedEdge::getCoordinate
geom::Coordinate & getCoordinate() const
Returns the coordinate of the from-node.
geos::planargraph::DirectedEdge::toEdges
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.
geos::planargraph::DirectedEdge::print
std::string print() const
Prints a detailed string representation of this DirectedEdge to the given PrintStream.
geos::planargraph::DirectedEdge::compareDirection
int compareDirection(const DirectedEdge *e) const
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b",...
geos::planargraph::Edge
Represents an undirected edge of a PlanarGraph.
Definition planargraph/Edge.h:54
geos::planargraph::Node
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition planargraph/Node.h:44
geos::planargraph
Contains classes to implement a planar graph data structure.
Definition namespaces.h:293
geos::planargraph::pdeLessThan
bool pdeLessThan(DirectedEdge *first, DirectedEdge *second)
Strict Weak comparator function for containers.
geos::planargraph::operator<<
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38