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

# Edge.h

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