00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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>
00025 #include <geos/geomgraph/Depth.h>
00026 #include <geos/geomgraph/EdgeIntersectionList.h>
00027 #include <geos/geom/CoordinateSequence.h>
00028
00029 #include <geos/inline.h>
00030
00031
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 {
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;
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
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
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 }
00240 }
00241
00242
00243
00244
00245
00246 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264