GEOS: Edge.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# Edge.h

    00001 /**********************************************************************
    00002  * $Id: Edge.h 2557 2009-06-08 09:30:55Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    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/Edge.java rev. 1.4 (JTS-1.10)
    00018  *
    00019  **********************************************************************/
    00020
    00021
    00022 #ifndef GEOS_GEOMGRAPH_EDGE_H
    00023 #define GEOS_GEOMGRAPH_EDGE_H
    00024
    00025 #include <geos/export.h>
    00026 #include <string>
    00027 #include <cassert>
    00028
    00029 #include <geos/geomgraph/GraphComponent.h> // for inheritance
    00030 #include <geos/geomgraph/Depth.h> // for member
    00031 #include <geos/geomgraph/EdgeIntersectionList.h> // for composition
    00032 #include <geos/geom/CoordinateSequence.h> // for inlines
    00033
    00034 #include <geos/inline.h>
    00035
    00036 // Forward declarations
    00037 namespace geos {
    00038         namespace geom {
    00039                 class Envelope;
    00040                 class IntersectionMatrix;
    00041                 class Coordinate;
    00042         }
    00043         namespace algorithm {
    00044                 class LineIntersector;
    00045         }
    00046         namespace geomgraph {
    00047                 class Node;
    00048                 class EdgeEndStar;
    00049                 class Label;
    00050                 class NodeFactory;
    00051                 namespace index {
    00052                         class MonotoneChainEdge;
    00053                 }
    00054         }
    00055 }
    00056
    00057 namespace geos {
    00058 namespace geomgraph { // geos.geomgraph
    00059
    00060 class GEOS_DLL Edge: public GraphComponent{
    00061 using GraphComponent::updateIM;
    00062
    00063 private:
    00064
    00065         std::string name;
    00066
    00068         index::MonotoneChainEdge *mce;
    00069
    00071         geom::Envelope *env;
    00072
    00073         bool isIsolatedVar;
    00074
    00075         Depth depth;
    00076
    00077         int depthDelta;   // the change in area depth from the R to L side of this edge
    00078
    00079 public:
    00080
    00081         void testInvariant() const {
    00082                 assert(pts);
    00083                 assert(pts->size() > 1);
    00084         }
    00085
    00086
    00087         friend std::ostream& operator<< (std::ostream& os, const Edge& el);
    00088
    00089         static void updateIM(Label *lbl,geom::IntersectionMatrix *im);
    00090
    00092         geom::CoordinateSequence* pts;
    00093
    00094         EdgeIntersectionList eiList;
    00095
    00096         //Edge();
    00097
    00098         Edge(geom::CoordinateSequence* newPts, Label *newLabel);
    00099
    00100         Edge(geom::CoordinateSequence* newPts);
    00101
    00102         virtual ~Edge();
    00103
    00104         virtual int getNumPoints() const {
    00105                 return static_cast<int>(pts->getSize());
    00106         }
    00107
    00108         virtual void setName(const std::string &newName) {
    00109                 name=newName;
    00110         }
    00111
    00112         virtual const geom::CoordinateSequence* getCoordinates() const {
    00113                 testInvariant();
    00114                 return pts;
    00115         }
    00116
    00117         virtual const geom::Coordinate& getCoordinate(int i) const {
    00118                 testInvariant();
    00119                 return pts->getAt(i);
    00120         }
    00121
    00122         virtual const geom::Coordinate& getCoordinate() const {
    00123                 testInvariant();
    00124                 return pts->getAt(0);
    00125         }
    00126
    00127
    00128         virtual Depth &getDepth() {
    00129                 testInvariant();
    00130                 return depth;
    00131         }
    00132
    00138         virtual int getDepthDelta() const {
    00139                 testInvariant();
    00140                 return depthDelta;
    00141         }
    00142
    00143         virtual void setDepthDelta(int newDepthDelta) {
    00144                 depthDelta=newDepthDelta;
    00145                 testInvariant();
    00146         }
    00147
    00148         virtual int getMaximumSegmentIndex() const {
    00149                 testInvariant();
    00150                 return getNumPoints()-1;
    00151         }
    00152
    00153         virtual EdgeIntersectionList& getEdgeIntersectionList() {
    00154                 testInvariant();
    00155                 return eiList;
    00156         }
    00157
    00162         virtual index::MonotoneChainEdge* getMonotoneChainEdge();
    00163
    00164         virtual bool isClosed() const {
    00165                 testInvariant();
    00166                 return pts->getAt(0)==pts->getAt(getNumPoints()-1);
    00167         }
    00168
    00173         virtual bool isCollapsed() const;
    00174
    00175         virtual Edge* getCollapsedEdge();
    00176
    00177         virtual void setIsolated(bool newIsIsolated) {
    00178                 isIsolatedVar=newIsIsolated;
    00179                 testInvariant();
    00180         }
    00181
    00182         virtual bool isIsolated() const {
    00183                 testInvariant();
    00184                 return isIsolatedVar;
    00185         }
    00186
    00191         virtual void addIntersections(algorithm::LineIntersector *li, int segmentIndex,
    00192                 int geomIndex);
    00193
    00195         //
    00199         virtual void addIntersection(algorithm::LineIntersector *li, int segmentIndex,
    00200                 int geomIndex, int intIndex);
    00201
    00203         //
    00206         virtual void computeIM(geom::IntersectionMatrix *im) {
    00207                 updateIM(label, im);
    00208                 testInvariant();
    00209         }
    00210
    00212         virtual bool isPointwiseEqual(const Edge *e) const;
    00213
    00214         virtual std::string print() const;
    00215
    00216         virtual std::string printReverse() const;
    00217
    00225         virtual bool equals(const Edge& e) const;
    00226
    00227         virtual bool equals(const Edge* e) const {
    00228                 assert(e);
    00229                 return equals(*e);
    00230         }
    00231
    00232         virtual geom::Envelope* getEnvelope();
    00233 };
    00234
    00235
    00236 //Operators
    00237 inline bool operator==(const Edge &a, const Edge &b) {
    00238         return a.equals(b);
    00239 }
    00240
    00241 std::ostream& operator<< (std::ostream& os, const Edge& el);
    00242
    00243
    00244 } // namespace geos.geomgraph
    00245 } // namespace geos
    00246
    00247 //#ifdef GEOS_INLINE
    00248 //# include "geos/geomgraph/Edge.inl"
    00249 //#endif
    00250
    00251 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
    00252
    00253 /**********************************************************************
    00254  * $Log$
    00255  * Revision 1.4  2006/04/05 18:28:42  strk
    00256  * Moved testInvariant() methods from private to public, added
    00257  * some comments about them.
    00258  *
    00259  * Revision 1.3  2006/03/24 09:52:41  strk
    00260  * USE_INLINE => GEOS_INLINE
    00261  *
    00262  * Revision 1.2  2006/03/14 11:03:14  strk
    00263  * Added operator<< for Edge and EdgeList
    00264  *
    00265  * Revision 1.1  2006/03/09 16:46:49  strk
    00266  * geos::geom namespace definition, first pass at headers split
    00267  *
    00268  **********************************************************************/
    00269