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
00066 class GEOS_DLL Edge: public GraphComponent{
00067 using GraphComponent::updateIM;
00068
00069 private:
00070
00071 std::string name;
00072
00074 index::MonotoneChainEdge *mce;
00075
00077 geom::Envelope *env;
00078
00079 bool isIsolatedVar;
00080
00081 Depth depth;
00082
00083 int depthDelta;
00084
00085 public:
00086
00087 void testInvariant() const {
00088 assert(pts);
00089 assert(pts->size() > 1);
00090 }
00091
00092
00093 friend std::ostream& operator<< (std::ostream& os, const Edge& el);
00094
00095 static void updateIM(const Label& lbl, geom::IntersectionMatrix& im);
00096
00098 geom::CoordinateSequence* pts;
00099
00100 EdgeIntersectionList eiList;
00101
00102
00103
00105 Edge(geom::CoordinateSequence* newPts, const Label& newLabel);
00106
00108 Edge(geom::CoordinateSequence* newPts);
00109
00110 virtual ~Edge();
00111
00112 virtual int getNumPoints() const {
00113 return static_cast<int>(pts->getSize());
00114 }
00115
00116 virtual void setName(const std::string &newName) {
00117 name=newName;
00118 }
00119
00120 virtual const geom::CoordinateSequence* getCoordinates() const {
00121 testInvariant();
00122 return pts;
00123 }
00124
00125 virtual const geom::Coordinate& getCoordinate(int i) const {
00126 testInvariant();
00127 return pts->getAt(i);
00128 }
00129
00130 virtual const geom::Coordinate& getCoordinate() const {
00131 testInvariant();
00132 return pts->getAt(0);
00133 }
00134
00135
00136 virtual Depth &getDepth() {
00137 testInvariant();
00138 return depth;
00139 }
00140
00146 virtual int getDepthDelta() const {
00147 testInvariant();
00148 return depthDelta;
00149 }
00150
00151 virtual void setDepthDelta(int newDepthDelta) {
00152 depthDelta=newDepthDelta;
00153 testInvariant();
00154 }
00155
00156 virtual int getMaximumSegmentIndex() const {
00157 testInvariant();
00158 return getNumPoints()-1;
00159 }
00160
00161 virtual EdgeIntersectionList& getEdgeIntersectionList() {
00162 testInvariant();
00163 return eiList;
00164 }
00165
00170 virtual index::MonotoneChainEdge* getMonotoneChainEdge();
00171
00172 virtual bool isClosed() const {
00173 testInvariant();
00174 return pts->getAt(0)==pts->getAt(getNumPoints()-1);
00175 }
00176
00181 virtual bool isCollapsed() const;
00182
00183 virtual Edge* getCollapsedEdge();
00184
00185 virtual void setIsolated(bool newIsIsolated) {
00186 isIsolatedVar=newIsIsolated;
00187 testInvariant();
00188 }
00189
00190 virtual bool isIsolated() const {
00191 testInvariant();
00192 return isIsolatedVar;
00193 }
00194
00199 virtual void addIntersections(algorithm::LineIntersector *li, int segmentIndex,
00200 int geomIndex);
00201
00203
00207 virtual void addIntersection(algorithm::LineIntersector *li, int segmentIndex,
00208 int geomIndex, int intIndex);
00209
00211
00215 virtual void computeIM(geom::IntersectionMatrix& im) {
00216 updateIM(label, im);
00217 testInvariant();
00218 }
00219
00221 virtual bool isPointwiseEqual(const Edge *e) const;
00222
00223 virtual std::string print() const;
00224
00225 virtual std::string printReverse() const;
00226
00234 virtual bool equals(const Edge& e) const;
00235
00236 virtual bool equals(const Edge* e) const {
00237 assert(e);
00238 return equals(*e);
00239 }
00240
00241 virtual geom::Envelope* getEnvelope();
00242 };
00243
00244
00245
00246 inline bool operator==(const Edge &a, const Edge &b) {
00247 return a.equals(b);
00248 }
00249
00250 std::ostream& operator<< (std::ostream& os, const Edge& el);
00251
00252
00253 }
00254 }
00255
00256 #ifdef _MSC_VER
00257 #pragma warning(pop)
00258 #endif
00259
00260
00261
00262
00263
00264 #endif // ifndef GEOS_GEOMGRAPH_EDGE_H
00265