GEOS
3.3.1
|
00001 /********************************************************************** 00002 * $Id: EdgeRing.h 3255 2011-03-01 17:56:10Z mloskot $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2005-2006 Refractions Research Inc. 00008 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00009 * 00010 * This is free software; you can redistribute and/or modify it under 00011 * the terms of the GNU Lesser General Public Licence as published 00012 * by the Free Software Foundation. 00013 * See the COPYING file for more information. 00014 * 00015 ********************************************************************** 00016 * 00017 * Last port: geomgraph/EdgeRing.java rev. 1.10 (JTS-1.10) 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> // for composition 00027 00028 #include <geos/inline.h> 00029 00030 #include <vector> 00031 #include <cassert> // for testInvariant 00032 #include <iosfwd> // for operator<< 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 // Forward declarations 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 //class Label; 00051 class Edge; 00052 } 00053 } 00054 00055 namespace geos { 00056 namespace geomgraph { // geos.geomgraph 00057 00058 class GEOS_DLL EdgeRing { 00059 00060 public: 00061 friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er); 00062 00063 EdgeRing(DirectedEdge *newStart, 00064 const geom::GeometryFactory *newGeometryFactory); 00065 00066 virtual ~EdgeRing(); 00067 00068 bool isIsolated(); 00069 00070 bool isHole(); 00071 00072 /* 00073 * Return a pointer to the LinearRing owned by 00074 * this object. Make a copy if you need it beyond 00075 * this objects's lifetime. 00076 */ 00077 geom::LinearRing* getLinearRing(); 00078 00079 Label& getLabel(); 00080 00081 bool isShell(); 00082 00083 EdgeRing *getShell(); 00084 00085 void setShell(EdgeRing *newShell); 00086 00087 void addHole(EdgeRing *edgeRing); 00088 00094 geom::Polygon* toPolygon(const geom::GeometryFactory* geometryFactory); 00095 00101 void computeRing(); 00102 00103 virtual DirectedEdge* getNext(DirectedEdge *de)=0; 00104 00105 virtual void setEdgeRing(DirectedEdge *de, EdgeRing *er)=0; 00106 00110 std::vector<DirectedEdge*>& getEdges(); 00111 00112 int getMaxNodeDegree(); 00113 00114 void setInResult(); 00115 00120 bool containsPoint(const geom::Coordinate& p); 00121 00122 void testInvariant() 00123 { 00124 // pts are never NULL 00125 assert(pts); 00126 00127 #ifndef NDEBUG 00128 // If this is not an hole, check that 00129 // each hole is not null and 00130 // has 'this' as it's shell 00131 if ( ! shell ) 00132 { 00133 for (std::vector<EdgeRing*>::const_iterator 00134 it=holes.begin(), itEnd=holes.end(); 00135 it != itEnd; 00136 ++it) 00137 { 00138 EdgeRing* hole=*it; 00139 assert(hole); 00140 assert(hole->getShell()==this); 00141 } 00142 } 00143 #endif // ndef NDEBUG 00144 } 00145 00146 protected: 00147 00148 DirectedEdge *startDe; // the directed edge which starts the list of edges for this EdgeRing 00149 00150 const geom::GeometryFactory *geometryFactory; 00151 00153 void computePoints(DirectedEdge *newStart); 00154 00155 void mergeLabel(Label& deLabel); 00156 00169 void mergeLabel(Label& deLabel, int geomIndex); 00170 00171 void addPoints(Edge *edge, bool isForward, bool isFirstEdge); 00172 00174 std::vector<EdgeRing*> holes; 00175 00176 private: 00177 00178 int maxNodeDegree; 00179 00181 std::vector<DirectedEdge*> edges; 00182 00183 geom::CoordinateSequence* pts; 00184 00185 // label stores the locations of each geometry on the 00186 // face surrounded by this ring 00187 Label label; 00188 00189 geom::LinearRing *ring; // the ring created for this EdgeRing 00190 00191 bool isHoleVar; 00192 00194 EdgeRing *shell; 00195 00196 void computeMaxNodeDegree(); 00197 00198 }; 00199 00200 std::ostream& operator<< (std::ostream& os, const EdgeRing& er); 00201 00202 } // namespace geos.geomgraph 00203 } // namespace geos 00204 00205 #ifdef _MSC_VER 00206 #pragma warning(pop) 00207 #endif 00208 00209 //#ifdef GEOS_INLINE 00210 //# include "geos/geomgraph/EdgeRing.inl" 00211 //#endif 00212 00213 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H 00214 00215 /********************************************************************** 00216 * $Log$ 00217 * Revision 1.9 2006/07/08 00:33:55 strk 00218 * * configure.in: incremented CAPI minor version, to avoid falling behind any future version from the 2.2. branch. 00219 * * source/geom/Geometry.cpp, source/geom/GeometryFactory.cpp, 00220 * source/geomgraph/EdgeRing.cpp, 00221 * source/headers/geos/geom/Geometry.h, 00222 * source/headers/geos/geom/GeometryFactory.h, 00223 * source/headers/geos/geom/GeometryFactory.inl, 00224 * source/headers/geos/geomgraph/EdgeRing.h: 00225 * updated doxygen comments (sync with JTS head). 00226 * * source/headers/geos/platform.h.in: include <inttypes.h> 00227 * rather then <stdint.h> 00228 * 00229 * Revision 1.8 2006/04/06 09:41:55 strk 00230 * Added operator<<, added pts!=NULL assertion in testInvariant() function 00231 * 00232 * Revision 1.7 2006/04/05 18:28:42 strk 00233 * Moved testInvariant() methods from private to public, added 00234 * some comments about them. 00235 * 00236 * Revision 1.6 2006/03/29 13:53:59 strk 00237 * EdgeRing equipped with Invariant testing function and lots of exceptional assertions. Removed useless heap allocations, and pointers usages. 00238 * 00239 * Revision 1.5 2006/03/27 16:02:34 strk 00240 * Added INL file for MinimalEdgeRing, added many debugging blocks, 00241 * fixed memory leak in ConnectedInteriorTester (bug #59) 00242 * 00243 * Revision 1.4 2006/03/24 09:52:41 strk 00244 * USE_INLINE => GEOS_INLINE 00245 * 00246 * Revision 1.3 2006/03/20 12:32:57 strk 00247 * Added note about responsibility of return from ::toPolygon 00248 * 00249 * Revision 1.2 2006/03/15 17:17:41 strk 00250 * Added missing forward declarations 00251 * 00252 * Revision 1.1 2006/03/09 16:46:49 strk 00253 * geos::geom namespace definition, first pass at headers split 00254 * 00255 **********************************************************************/ 00256