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_EDGERING_H
00023 #define GEOS_GEOMGRAPH_EDGERING_H
00024
00025 #include <geos/geomgraph/Label.h>
00026
00027 #include <geos/inline.h>
00028
00029 #include <vector>
00030 #include <cassert>
00031 #include <iosfwd>
00032
00033
00034
00035 namespace geos {
00036 namespace geom {
00037 class GeometryFactory;
00038 class LinearRing;
00039 class Polygon;
00040 class Coordinate;
00041 class CoordinateSequence;
00042 }
00043 namespace geomgraph {
00044 class DirectedEdge;
00045
00046 class Edge;
00047 }
00048 }
00049
00050 namespace geos {
00051 namespace geomgraph {
00052
00053 class EdgeRing {
00054
00055 public:
00056 friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
00057
00058 EdgeRing(DirectedEdge *newStart,
00059 const geom::GeometryFactory *newGeometryFactory);
00060
00061 virtual ~EdgeRing();
00062
00063 bool isIsolated();
00064
00065 bool isHole();
00066
00067
00068
00069
00070
00071
00072 geom::LinearRing* getLinearRing();
00073
00074 Label& getLabel();
00075
00076 bool isShell();
00077
00078 EdgeRing *getShell();
00079
00080 void setShell(EdgeRing *newShell);
00081
00082 void addHole(EdgeRing *edgeRing);
00083
00089 geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
00090
00096 void computeRing();
00097
00098 virtual DirectedEdge* getNext(DirectedEdge *de)=0;
00099
00100 virtual void setEdgeRing(DirectedEdge *de, EdgeRing *er)=0;
00101
00105 std::vector<DirectedEdge*>& getEdges();
00106
00107 int getMaxNodeDegree();
00108
00109 void setInResult();
00110
00115 bool containsPoint(const geom::Coordinate& p);
00116
00117 void testInvariant()
00118 {
00119
00120 assert(pts);
00121
00122 #ifndef NDEBUG
00123
00124
00125
00126 if ( ! shell )
00127 {
00128 for (std::vector<EdgeRing*>::const_iterator
00129 it=holes.begin(), itEnd=holes.end();
00130 it != itEnd;
00131 ++it)
00132 {
00133 EdgeRing* hole=*it;
00134 assert(hole);
00135 assert(hole->getShell()==this);
00136 }
00137 }
00138 #endif // ndef NDEBUG
00139 }
00140
00141 protected:
00142
00143 DirectedEdge *startDe;
00144
00145 const geom::GeometryFactory *geometryFactory;
00146
00147 void computePoints(DirectedEdge *newStart);
00148
00149 void mergeLabel(Label& deLabel);
00150
00163 void mergeLabel(Label& deLabel, int geomIndex);
00164
00165 void addPoints(Edge *edge, bool isForward, bool isFirstEdge);
00166
00168 std::vector<EdgeRing*> holes;
00169
00170 private:
00171
00172 int maxNodeDegree;
00173
00175 std::vector<DirectedEdge*> edges;
00176
00177 geom::CoordinateSequence* pts;
00178
00179
00180
00181 Label label;
00182
00183 geom::LinearRing *ring;
00184
00185 bool isHoleVar;
00186
00188 EdgeRing *shell;
00189
00190 void computeMaxNodeDegree();
00191
00192 };
00193
00194 std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
00195
00196 }
00197 }
00198
00199
00200
00201
00202
00203 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246