GEOS  3.9.1
planargraph/DirectedEdge.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #ifndef GEOS_PLANARGRAPH_DIRECTEDEDGE_H
17 #define GEOS_PLANARGRAPH_DIRECTEDEDGE_H
18 
19 #include <geos/export.h>
20 #include <geos/planargraph/GraphComponent.h> // for inheritance
21 #include <geos/geom/Coordinate.h> // for composition
22 
23 #include <vector> // for typedefs
24 #include <list> // for typedefs
25 
26 // Forward declarations
27 namespace geos {
28 namespace planargraph {
29 class Edge;
30 class Node;
31 }
32 }
33 
34 namespace geos {
35 namespace planargraph { // geos.planargraph
36 
46 class GEOS_DLL DirectedEdge: public GraphComponent {
47 
48 public:
49 
50  friend std::ostream& operator << (std::ostream&, const DirectedEdge&);
51 
52  typedef std::list<DirectedEdge*> NonConstList;
53  typedef std::list<const DirectedEdge*> ConstList;
54  typedef std::vector<DirectedEdge*> NonConstVect;
55 
56 protected:
57  Edge* parentEdge;
58  Node* from;
59  Node* to;
60  geom::Coordinate p0, p1;
61  DirectedEdge* sym; // optional
62  bool edgeDirection;
63  int quadrant;
64  double angle;
65 public:
66 
67  typedef std::vector<const DirectedEdge*> ConstVect;
68  typedef std::vector<DirectedEdge*> Vect;
69 
79  static std::vector<Edge*>* toEdges(
80  std::vector<DirectedEdge*>& dirEdges);
81 
90  static void toEdges(std::vector<DirectedEdge*>& dirEdges,
91  std::vector<Edge*>& parentEdges);
92 
107  DirectedEdge(Node* newFrom, Node* newTo,
108  const geom::Coordinate& directionPt,
109  bool newEdgeDirection);
110 
115  Edge* getEdge() const;
116 
121  void setEdge(Edge* newParentEdge);
122 
127  int getQuadrant() const;
128 
134 
139  bool getEdgeDirection() const;
140 
144  Node* getFromNode() const;
145 
149  Node* getToNode() const;
150 
156 
162  double getAngle() const;
163 
170 
176  void setSym(DirectedEdge* newSym);
177 
197  int compareTo(const DirectedEdge* obj) const;
198 
218  int compareDirection(const DirectedEdge* e) const;
219 
225  std::string print() const;
226 
227 };
228 
230 bool pdeLessThan(DirectedEdge* first, DirectedEdge* second);
231 
233 std::ostream& operator << (std::ostream&, const DirectedEdge&);
234 
235 
236 } // namespace geos::planargraph
237 } // namespace geos
238 
239 #endif // GEOS_PLANARGRAPH_DIRECTEDEDGE_H
geos::planargraph::DirectedEdge
Represents a directed edge in a PlanarGraph.
Definition: planargraph/DirectedEdge.h:46
geos::planargraph::DirectedEdge::setEdge
void setEdge(Edge *newParentEdge)
Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).
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::compareDirection
int compareDirection(const DirectedEdge *e) const
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b",...
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
geos::planargraph::pdeLessThan
bool pdeLessThan(DirectedEdge *first, DirectedEdge *second)
Strict Weak comparator function for containers.
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::getFromNode
Node * getFromNode() const
Returns the node from which this DirectedEdge leaves.
geos::planargraph::GraphComponent
The base class for all graph component classes.
Definition: planargraph/GraphComponent.h:46
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::getQuadrant
int getQuadrant() const
Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.
geos::planargraph::DirectedEdge::getEdge
Edge * getEdge() const
Returns this DirectedEdge's parent Edge, or null if it has none.
geos::planargraph::DirectedEdge::getAngle
double getAngle() const
Returns the angle that the start of this DirectedEdge makes with the positive x-axis,...
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
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::print
std::string print() const
Prints a detailed string representation of this DirectedEdge to the given PrintStream.
geos::planargraph::operator<<
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
geos::planargraph::Node
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition: planargraph/Node.h:45
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::Edge
Represents an undirected edge of a PlanarGraph.
Definition: planargraph/Edge.h:54
geos::planargraph::DirectedEdge::getCoordinate
geom::Coordinate & getCoordinate() const
Returns the coordinate of the from-node.
geos::planargraph::DirectedEdge::setSym
void setSym(DirectedEdge *newSym)
Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.
geos::planargraph::DirectedEdge::getSym
DirectedEdge * getSym() const
Returns the symmetric DirectedEdge – the other DirectedEdge associated with this DirectedEdge's paren...
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::getToNode
Node * getToNode() const
Returns the node to which this DirectedEdge goes.