GEOS  3.4.2
DirectedEdge.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00007  * Copyright (C) 2005-2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************/
00015 
00016 #ifndef GEOS_PLANARGRAPH_DIRECTEDEDGE_H
00017 #define GEOS_PLANARGRAPH_DIRECTEDEDGE_H
00018 
00019 #include <geos/export.h>
00020 #include <geos/planargraph/GraphComponent.h> // for inheritance
00021 #include <geos/geom/Coordinate.h> // for composition
00022 
00023 #include <vector> // for typedefs
00024 #include <list> // for typedefs
00025 
00026 // Forward declarations
00027 namespace geos {
00028         namespace planargraph { 
00029                 class Edge;
00030                 class Node;
00031         }
00032 }
00033 
00034 namespace geos {
00035 namespace planargraph { // geos.planargraph
00036 
00046 class GEOS_DLL DirectedEdge: public GraphComponent {
00047 
00048 public:
00049 
00050   friend std::ostream& operator << (std::ostream&, const DirectedEdge&);
00051 
00052         typedef std::list<DirectedEdge *> NonConstList;
00053         typedef std::list<const DirectedEdge *> ConstList;
00054         typedef std::vector<DirectedEdge *> NonConstVect;
00055 
00056 protected:
00057         Edge* parentEdge;
00058         Node* from;
00059         Node* to;
00060         geom::Coordinate p0, p1;
00061         DirectedEdge* sym;  // optional
00062         bool edgeDirection;
00063         int quadrant;
00064         double angle;
00065 public:
00066 
00067         typedef std::vector<const DirectedEdge *> ConstVect;
00068         typedef std::vector<DirectedEdge *> Vect;
00069 
00079         static std::vector<Edge*>* toEdges(
00080                 std::vector<DirectedEdge*>& dirEdges);
00081 
00090         static void toEdges( std::vector<DirectedEdge*>& dirEdges,
00091                         std::vector<Edge*>& parentEdges);
00092 
00105         DirectedEdge(Node *newFrom, Node *newTo,
00106                         const geom::Coordinate &directionPt,
00107                         bool newEdgeDirection);
00108 
00113         Edge* getEdge() const;
00114 
00119         void setEdge(Edge* newParentEdge);
00120 
00125         int getQuadrant() const;
00126 
00131         const geom::Coordinate& getDirectionPt() const;
00132 
00137         bool getEdgeDirection() const;
00138 
00142         Node* getFromNode() const;
00143 
00147         Node* getToNode() const;
00148 
00153         geom::Coordinate& getCoordinate() const;
00154 
00160         double getAngle() const;
00161 
00167         DirectedEdge* getSym() const;
00168 
00174         void setSym(DirectedEdge *newSym);
00175 
00195         int compareTo(const DirectedEdge* obj) const;
00196 
00216         int compareDirection(const DirectedEdge *e) const;
00217 
00223         std::string print() const;
00224 
00225 };
00226 
00228 bool pdeLessThan(DirectedEdge *first, DirectedEdge * second);
00229 
00231 std::ostream& operator << (std::ostream&, const DirectedEdge&);
00232 
00233 
00234 } // namespace geos::planargraph
00235 } // namespace geos
00236 
00237 #endif // GEOS_PLANARGRAPH_DIRECTEDEDGE_H