00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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>
00030 #include <geos/geomgraph/Depth.h>
00031 #include <geos/geomgraph/EdgeIntersectionList.h>
00032 #include <geos/geom/CoordinateSequence.h>
00033
00034 #include <geos/inline.h>
00035
00036
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 {
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;
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
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
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 }
00245 }
00246
00247
00248
00249
00250
00251 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269