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/export.h>
00026 #include <geos/geomgraph/Label.h>
00027
00028 #include <geos/inline.h>
00029
00030 #include <vector>
00031 #include <cassert>
00032 #include <iosfwd>
00033
00034
00035
00036 namespace geos {
00037 namespace geom {
00038 class GeometryFactory;
00039 class LinearRing;
00040 class Polygon;
00041 class Coordinate;
00042 class CoordinateSequence;
00043 }
00044 namespace geomgraph {
00045 class DirectedEdge;
00046
00047 class Edge;
00048 }
00049 }
00050
00051 namespace geos {
00052 namespace geomgraph {
00053
00054 class GEOS_DLL EdgeRing {
00055
00056 public:
00057 friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
00058
00059 EdgeRing(DirectedEdge *newStart,
00060 const geom::GeometryFactory *newGeometryFactory);
00061
00062 virtual ~EdgeRing();
00063
00064 bool isIsolated();
00065
00066 bool isHole();
00067
00068
00069
00070
00071
00072
00073 geom::LinearRing* getLinearRing();
00074
00075 Label& getLabel();
00076
00077 bool isShell();
00078
00079 EdgeRing *getShell();
00080
00081 void setShell(EdgeRing *newShell);
00082
00083 void addHole(EdgeRing *edgeRing);
00084
00090 geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
00091
00097 void computeRing();
00098
00099 virtual DirectedEdge* getNext(DirectedEdge *de)=0;
00100
00101 virtual void setEdgeRing(DirectedEdge *de, EdgeRing *er)=0;
00102
00106 std::vector<DirectedEdge*>& getEdges();
00107
00108 int getMaxNodeDegree();
00109
00110 void setInResult();
00111
00116 bool containsPoint(const geom::Coordinate& p);
00117
00118 void testInvariant()
00119 {
00120
00121 assert(pts);
00122
00123 #ifndef NDEBUG
00124
00125
00126
00127 if ( ! shell )
00128 {
00129 for (std::vector<EdgeRing*>::const_iterator
00130 it=holes.begin(), itEnd=holes.end();
00131 it != itEnd;
00132 ++it)
00133 {
00134 EdgeRing* hole=*it;
00135 assert(hole);
00136 assert(hole->getShell()==this);
00137 }
00138 }
00139 #endif // ndef NDEBUG
00140 }
00141
00142 protected:
00143
00144 DirectedEdge *startDe;
00145
00146 const geom::GeometryFactory *geometryFactory;
00147
00149 void computePoints(DirectedEdge *newStart);
00150
00151 void mergeLabel(Label& deLabel);
00152
00165 void mergeLabel(Label& deLabel, int geomIndex);
00166
00167 void addPoints(Edge *edge, bool isForward, bool isFirstEdge);
00168
00170 std::vector<EdgeRing*> holes;
00171
00172 private:
00173
00174 int maxNodeDegree;
00175
00177 std::vector<DirectedEdge*> edges;
00178
00179 geom::CoordinateSequence* pts;
00180
00181
00182
00183 Label label;
00184
00185 geom::LinearRing *ring;
00186
00187 bool isHoleVar;
00188
00190 EdgeRing *shell;
00191
00192 void computeMaxNodeDegree();
00193
00194 };
00195
00196 std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
00197
00198 }
00199 }
00200
00201
00202
00203
00204
00205 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H
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
00247
00248