GEOS
3.2.3
|
00001 /********************************************************************** 00002 * $Id: EdgeRing.h 2557 2009-06-08 09:30:55Z strk $ 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 00035 // Forward declarations 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 //class Label; 00047 class Edge; 00048 } 00049 } 00050 00051 namespace geos { 00052 namespace geomgraph { // geos.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 * Return a pointer to the LinearRing owned by 00070 * this object. Make a copy if you need it beyond 00071 * this objects's lifetime. 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 // pts are never NULL 00121 assert(pts); 00122 00123 #ifndef NDEBUG 00124 // If this is not an hole, check that 00125 // each hole is not null and 00126 // has 'this' as it's shell 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; // the directed edge which starts the list of edges for this EdgeRing 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 // label stores the locations of each geometry on the 00182 // face surrounded by this ring 00183 Label label; 00184 00185 geom::LinearRing *ring; // the ring created for this EdgeRing 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 } // namespace geos.geomgraph 00199 } // namespace geos 00200 00201 //#ifdef GEOS_INLINE 00202 //# include "geos/geomgraph/EdgeRing.inl" 00203 //#endif 00204 00205 #endif // ifndef GEOS_GEOMGRAPH_EDGERING_H 00206 00207 /********************************************************************** 00208 * $Log$ 00209 * Revision 1.9 2006/07/08 00:33:55 strk 00210 * * configure.in: incremented CAPI minor version, to avoid falling behind any future version from the 2.2. branch. 00211 * * source/geom/Geometry.cpp, source/geom/GeometryFactory.cpp, 00212 * source/geomgraph/EdgeRing.cpp, 00213 * source/headers/geos/geom/Geometry.h, 00214 * source/headers/geos/geom/GeometryFactory.h, 00215 * source/headers/geos/geom/GeometryFactory.inl, 00216 * source/headers/geos/geomgraph/EdgeRing.h: 00217 * updated doxygen comments (sync with JTS head). 00218 * * source/headers/geos/platform.h.in: include <inttypes.h> 00219 * rather then <stdint.h> 00220 * 00221 * Revision 1.8 2006/04/06 09:41:55 strk 00222 * Added operator<<, added pts!=NULL assertion in testInvariant() function 00223 * 00224 * Revision 1.7 2006/04/05 18:28:42 strk 00225 * Moved testInvariant() methods from private to public, added 00226 * some comments about them. 00227 * 00228 * Revision 1.6 2006/03/29 13:53:59 strk 00229 * EdgeRing equipped with Invariant testing function and lots of exceptional assertions. Removed useless heap allocations, and pointers usages. 00230 * 00231 * Revision 1.5 2006/03/27 16:02:34 strk 00232 * Added INL file for MinimalEdgeRing, added many debugging blocks, 00233 * fixed memory leak in ConnectedInteriorTester (bug #59) 00234 * 00235 * Revision 1.4 2006/03/24 09:52:41 strk 00236 * USE_INLINE => GEOS_INLINE 00237 * 00238 * Revision 1.3 2006/03/20 12:32:57 strk 00239 * Added note about responsibility of return from ::toPolygon 00240 * 00241 * Revision 1.2 2006/03/15 17:17:41 strk 00242 * Added missing forward declarations 00243 * 00244 * Revision 1.1 2006/03/09 16:46:49 strk 00245 * geos::geom namespace definition, first pass at headers split 00246 * 00247 **********************************************************************/ 00248