GEOS  3.6.2
EdgeEnd.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
00007  * Copyright (C) 2005-2006 Refractions Research Inc.
00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: geomgraph/EdgeEnd.java r428 (JTS-1.12+)
00018  *
00019  **********************************************************************/
00020 
00021 
00022 #ifndef GEOS_GEOMGRAPH_EDGEEND_H
00023 #define GEOS_GEOMGRAPH_EDGEEND_H
00024 
00025 #include <geos/export.h>
00026 #include <geos/geom/Coordinate.h>  // for p0,p1
00027 #include <geos/geomgraph/Label.h>  // for composition
00028 #include <geos/inline.h>
00029 
00030 #include <string>
00031 
00032 // Forward declarations
00033 namespace geos {
00034         namespace algorithm {
00035                 class BoundaryNodeRule;
00036         }
00037         namespace geomgraph {
00038                 class Edge;
00039                 class Node;
00040         }
00041 }
00042 
00043 namespace geos {
00044 namespace geomgraph { // geos.geomgraph
00045 
00056 class GEOS_DLL EdgeEnd {
00057 
00058 public:
00059 
00060         friend std::ostream& operator<< (std::ostream&, const EdgeEnd&);
00061 
00062         EdgeEnd();
00063 
00064         virtual ~EdgeEnd() {}
00065 
00073         EdgeEnd(Edge* newEdge, const geom::Coordinate& newP0,
00074                         const geom::Coordinate& newP1,
00075                         const Label& newLabel);
00076 
00083         EdgeEnd(Edge* newEdge, const geom::Coordinate& newP0,
00084                         const geom::Coordinate& newP1);
00085 
00086         Edge* getEdge() { return edge; }
00087         //virtual Edge* getEdge() { return edge; }
00088 
00089         Label& getLabel() { return label; }
00090 
00091         const Label& getLabel() const { return label; }
00092 
00093         virtual geom::Coordinate& getCoordinate();
00094 
00095         const geom::Coordinate& getCoordinate() const { return p0; }
00096 
00097         virtual geom::Coordinate& getDirectedCoordinate();
00098 
00099         virtual int getQuadrant();
00100 
00101         virtual double getDx();
00102 
00103         virtual double getDy();
00104 
00105         virtual void setNode(Node* newNode);
00106 
00107         virtual Node* getNode();
00108 
00109         virtual int compareTo(const EdgeEnd *e) const;
00110 
00127         virtual int compareDirection(const EdgeEnd *e) const;
00128 
00129         virtual void computeLabel(const algorithm::BoundaryNodeRule& bnr);
00130 
00131         virtual std::string print() const;
00132 
00133 protected:
00134 
00135         Edge* edge;// the parent edge of this edge end
00136 
00137         Label label;
00138 
00139         EdgeEnd(Edge* newEdge);
00140 
00141         virtual void init(const geom::Coordinate& newP0,
00142                         const geom::Coordinate& newP1);
00143 
00144 private:
00145 
00147         Node* node;         
00148 
00150         geom::Coordinate p0, p1; 
00151 
00153         double dx, dy;     
00154 
00155         int quadrant;
00156 };
00157 
00158 std::ostream& operator<< (std::ostream&, const EdgeEnd&);
00159 
00160 struct GEOS_DLL  EdgeEndLT {
00161         bool operator()(const EdgeEnd *s1, const EdgeEnd *s2) const {
00162                 return s1->compareTo(s2)<0;
00163         }
00164 };
00165 
00166 } // namespace geos.geomgraph
00167 } // namespace geos
00168 
00169 //#ifdef GEOS_INLINE
00170 //# include "geos/geomgraph/EdgeEnd.inl"
00171 //#endif
00172 
00173 #endif // ifndef GEOS_GEOMGRAPH_EDGEEND_H