GEOS 3.15.0dev
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#pragma once
17
18#include <geos/export.h>
19#include <geos/planargraph/GraphComponent.h> // for inheritance
20#include <geos/geom/Coordinate.h> // for composition
21
22#include <vector> // for typedefs
23#include <list> // for typedefs
24
25// Forward declarations
26namespace geos {
27namespace planargraph {
28class Edge;
29class Node;
30}
31}
32
33namespace geos {
34namespace planargraph { // geos.planargraph
35
45class GEOS_DLL DirectedEdge: public GraphComponent {
46
47public:
48
49 friend std::ostream& operator << (std::ostream&, const DirectedEdge&);
50
51 typedef std::list<DirectedEdge*> NonConstList;
52 typedef std::list<const DirectedEdge*> ConstList;
53 typedef std::vector<DirectedEdge*> NonConstVect;
54
55protected:
56 Edge* parentEdge;
57 Node* const from;
58 Node* const to;
59 const geom::CoordinateXY p0, p1;
60 DirectedEdge* sym; // optional
61 const bool edgeDirection;
62 int quadrant;
63 double angle;
64public:
65
66 typedef std::vector<const DirectedEdge*> ConstVect;
67 typedef std::vector<DirectedEdge*> Vect;
68
78 static std::vector<Edge*>* toEdges(
79 std::vector<DirectedEdge*>& dirEdges);
80
89 static void toEdges(std::vector<DirectedEdge*>& dirEdges,
90 std::vector<Edge*>& parentEdges);
91
106 DirectedEdge(Node* newFrom, Node* newTo,
107 const geom::CoordinateXY& directionPt,
108 bool newEdgeDirection);
109
114 Edge* getEdge() const;
115
120 void setEdge(Edge* newParentEdge);
121
126 int getQuadrant() const;
127
132 const geom::CoordinateXY& getDirectionPt() const;
133
138 bool getEdgeDirection() const;
139
143 const Node* getFromNode() const;
144 Node* getFromNode();
145
149 const Node* getToNode() const;
150 Node* getToNode();
151
156 const geom::CoordinateXY& getCoordinate() const;
157
163 double getAngle() const;
164
171
177 void setSym(DirectedEdge* newSym);
178
198 int compareTo(const DirectedEdge* obj) const;
199
219 int compareDirection(const DirectedEdge* e) const;
220
226 std::string print() const;
227
228};
229
232
234std::ostream& operator << (std::ostream&, const DirectedEdge&);
235
236
237} // namespace geos::planargraph
238} // namespace geos
239
Represents a directed edge in a PlanarGraph.
Definition planargraph/DirectedEdge.h:45
const geom::CoordinateXY & getDirectionPt() const
Returns a point to which an imaginary line is drawn from the from-node to specify this DirectedEdge's...
int compareTo(const DirectedEdge *obj) const
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b",...
const geom::CoordinateXY & getCoordinate() const
Returns the coordinate of the from-node.
Edge * getEdge() const
Returns this DirectedEdge's parent Edge, or null if it has none.
int getQuadrant() const
Returns 0, 1, 2, or 3, indicating the quadrant in which this DirectedEdge's orientation lies.
void setEdge(Edge *newParentEdge)
Associates this DirectedEdge with an Edge (possibly null, indicating no associated Edge).
static std::vector< Edge * > * toEdges(std::vector< DirectedEdge * > &dirEdges)
Returns a List containing the parent Edge (possibly null) for each of the given DirectedEdges.
DirectedEdge(Node *newFrom, Node *newTo, const geom::CoordinateXY &directionPt, bool newEdgeDirection)
Constructs a DirectedEdge connecting the from node to the to node.
DirectedEdge * getSym() const
Returns the symmetric DirectedEdge – the other DirectedEdge associated with this DirectedEdge's paren...
double getAngle() const
Returns the angle that the start of this DirectedEdge makes with the positive x-axis,...
void setSym(DirectedEdge *newSym)
Sets this DirectedEdge's symmetric DirectedEdge, which runs in the opposite direction.
bool getEdgeDirection() const
Returns whether the direction of the parent Edge (if any) is the same as that of this Directed Edge.
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.
std::string print() const
Prints a detailed string representation of this DirectedEdge to the given PrintStream.
const Node * getToNode() const
Returns the node to which this DirectedEdge goes.
int compareDirection(const DirectedEdge *e) const
Returns 1 if this DirectedEdge has a greater angle with the positive x-axis than b",...
const Node * getFromNode() const
Returns the node from which this DirectedEdge leaves.
Represents an undirected edge of a PlanarGraph.
Definition planargraph/Edge.h:55
The base class for all graph component classes.
Definition planargraph/GraphComponent.h:45
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition planargraph/Node.h:44
bool pdeLessThan(DirectedEdge *first, DirectedEdge *second)
Strict Weak comparator function for containers.
std::ostream & operator<<(std::ostream &, const DirectedEdge &)
Output operator.
Basic namespace for all GEOS functionalities.
Definition geos.h:38