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 #ifdef _MSC_VER
00037 #pragma warning(push)
00038 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00039 #endif
00040
00041
00042 namespace geos {
00043 namespace geom {
00044 class Envelope;
00045 class IntersectionMatrix;
00046 class Coordinate;
00047 }
00048 namespace algorithm {
00049 class LineIntersector;
00050 }
00051 namespace geomgraph {
00052 class Node;
00053 class EdgeEndStar;
00054 class Label;
00055 class NodeFactory;
00056 namespace index {
00057 class MonotoneChainEdge;
00058 }
00059 }
00060 }
00061
00062 namespace geos {
00063 namespace geomgraph {
00064
00065 class GEOS_DLL Edge: public GraphComponent{
00066 using GraphComponent::updateIM;
00067
00068 private:
00069
00070 std::string name;
00071
00073 index::MonotoneChainEdge *mce;
00074
00076 geom::Envelope *env;
00077
00078 bool isIsolatedVar;
00079
00080 Depth depth;
00081
00082 int depthDelta;
00083
00084 public:
00085
00086 void testInvariant() const {
00087 assert(pts);
00088 assert(pts->size() > 1);
00089 }
00090
00091
00092 friend std::ostream& operator<< (std::ostream& os, const Edge& el);
00093
00094 static void updateIM(Label *lbl,geom::IntersectionMatrix *im);
00095
00097 geom::CoordinateSequence* pts;
00098
00099 EdgeIntersectionList eiList;
00100
00101
00102
00103 Edge(geom::CoordinateSequence* newPts, Label *newLabel);
00104
00105 Edge(geom::CoordinateSequence* newPts);
00106
00107 virtual ~Edge();
00108
00109 virtual int getNumPoints() const {
00110 return static_cast<int>(pts->getSize());
00111 }
00112
00113 virtual void setName(const std::string &newName) {
00114 name=newName;
00115 }
00116
00117 virtual const geom::CoordinateSequence* getCoordinates() const {
00118 testInvariant();
00119 return pts;
00120 }
00121
00122 virtual const geom::Coordinate& getCoordinate(int i) const {
00123 testInvariant();
00124 return pts->getAt(i);
00125 }
00126
00127 virtual const geom::Coordinate& getCoordinate() const {
00128 testInvariant();
00129 return pts->getAt(0);
00130 }
00131
00132
00133 virtual Depth &getDepth() {
00134 testInvariant();
00135 return depth;
00136 }
00137
00143 virtual int getDepthDelta() const {
00144 testInvariant();
00145 return depthDelta;
00146 }
00147
00148 virtual void setDepthDelta(int newDepthDelta) {
00149 depthDelta=newDepthDelta;
00150 testInvariant();
00151 }
00152
00153 virtual int getMaximumSegmentIndex() const {
00154 testInvariant();
00155 return getNumPoints()-1;
00156 }
00157
00158 virtual EdgeIntersectionList& getEdgeIntersectionList() {
00159 testInvariant();
00160 return eiList;
00161 }
00162
00167 virtual index::MonotoneChainEdge* getMonotoneChainEdge();
00168
00169 virtual bool isClosed() const {
00170 testInvariant();
00171 return pts->getAt(0)==pts->getAt(getNumPoints()-1);
00172 }
00173
00178 virtual bool isCollapsed() const;
00179
00180 virtual Edge* getCollapsedEdge();
00181
00182 virtual void setIsolated(bool newIsIsolated) {
00183 isIsolatedVar=newIsIsolated;
00184 testInvariant();
00185 }
00186
00187 virtual bool isIsolated() const {
00188 testInvariant();
00189 return isIsolatedVar;
00190 }
00191
00196 virtual void addIntersections(algorithm::LineIntersector *li, int segmentIndex,
00197 int geomIndex);
00198
00200
00204 virtual void addIntersection(algorithm::LineIntersector *li, int segmentIndex,
00205 int geomIndex, int intIndex);
00206
00208
00211 virtual void computeIM(geom::IntersectionMatrix *im) {
00212 updateIM(label, im);
00213 testInvariant();
00214 }
00215
00217 virtual bool isPointwiseEqual(const Edge *e) const;
00218
00219 virtual std::string print() const;
00220
00221 virtual std::string printReverse() const;
00222
00230 virtual bool equals(const Edge& e) const;
00231
00232 virtual bool equals(const Edge* e) const {
00233 assert(e);
00234 return equals(*e);
00235 }
00236
00237 virtual geom::Envelope* getEnvelope();
00238 };
00239
00240
00241
00242 inline bool operator==(const Edge &a, const Edge &b) {
00243 return a.equals(b);
00244 }
00245
00246 std::ostream& operator<< (std::ostream& os, const Edge& el);
00247
00248
00249 }
00250 }
00251
00252 #ifdef _MSC_VER
00253 #pragma warning(pop)
00254 #endif
00255
00256
00257
00258
00259
00260 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278