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 #ifdef _MSC_VER
00035 #pragma warning(push)
00036 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00037 #endif
00038
00039
00040 namespace geos {
00041 namespace geom {
00042 class GeometryFactory;
00043 class LinearRing;
00044 class Polygon;
00045 class Coordinate;
00046 class CoordinateSequence;
00047 }
00048 namespace geomgraph {
00049 class DirectedEdge;
00050
00051 class Edge;
00052 }
00053 }
00054
00055 namespace geos {
00056 namespace geomgraph {
00057
00059 class GEOS_DLL EdgeRing {
00060
00061 public:
00062 friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
00063
00064 EdgeRing(DirectedEdge *newStart,
00065 const geom::GeometryFactory *newGeometryFactory);
00066
00067 virtual ~EdgeRing();
00068
00069 bool isIsolated();
00070
00071 bool isHole();
00072
00073
00074
00075
00076
00077
00078 geom::LinearRing* getLinearRing();
00079
00080 Label& getLabel();
00081
00082 bool isShell();
00083
00084 EdgeRing *getShell();
00085
00086 void setShell(EdgeRing *newShell);
00087
00088 void addHole(EdgeRing *edgeRing);
00089
00095 geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory);
00096
00102 void computeRing();
00103
00104 virtual DirectedEdge* getNext(DirectedEdge *de)=0;
00105
00106 virtual void setEdgeRing(DirectedEdge *de, EdgeRing *er)=0;
00107
00111 std::vector<DirectedEdge*>& getEdges();
00112
00113 int getMaxNodeDegree();
00114
00115 void setInResult();
00116
00121 bool containsPoint(const geom::Coordinate& p);
00122
00123 void testInvariant()
00124 {
00125
00126 assert(pts);
00127
00128 #ifndef NDEBUG
00129
00130
00131
00132 if ( ! shell )
00133 {
00134 for (std::vector<EdgeRing*>::const_iterator
00135 it=holes.begin(), itEnd=holes.end();
00136 it != itEnd;
00137 ++it)
00138 {
00139 EdgeRing* hole=*it;
00140 assert(hole);
00141 assert(hole->getShell()==this);
00142 }
00143 }
00144 #endif // ndef NDEBUG
00145 }
00146
00147 protected:
00148
00149 DirectedEdge *startDe;
00150
00151 const geom::GeometryFactory *geometryFactory;
00152
00154 void computePoints(DirectedEdge *newStart);
00155
00156 void mergeLabel(const Label& deLabel);
00157
00170 void mergeLabel(const Label& deLabel, int geomIndex);
00171
00172 void addPoints(Edge *edge, bool isForward, bool isFirstEdge);
00173
00175 std::vector<EdgeRing*> holes;
00176
00177 private:
00178
00179 int maxNodeDegree;
00180
00182 std::vector<DirectedEdge*> edges;
00183
00184 geom::CoordinateSequence* pts;
00185
00186
00187
00188 Label label;
00189
00190 geom::LinearRing *ring;
00191
00192 bool isHoleVar;
00193
00195 EdgeRing *shell;
00196
00197 void computeMaxNodeDegree();
00198
00199 };
00200
00201 std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
00202
00203 }
00204 }
00205
00206 #ifdef _MSC_VER
00207 #pragma warning(pop)
00208 #endif
00209
00210 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H
00211