GEOS
3.3.6
|
00001 /********************************************************************** 00002 * $Id: PolygonExtracter.h 2772 2009-12-03 19:30:54Z mloskot $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00008 * Copyright (C) 2006 Refractions Research 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 #ifndef GEOS_GEOM_UTIL_POLYGONEXTRACTER_H 00018 #define GEOS_GEOM_UTIL_POLYGONEXTRACTER_H 00019 00020 #include <geos/export.h> 00021 #include <geos/geom/GeometryFilter.h> 00022 #include <geos/geom/Polygon.h> 00023 #include <geos/platform.h> 00024 #include <vector> 00025 00026 namespace geos { 00027 namespace geom { // geos.geom 00028 namespace util { // geos.geom.util 00029 00033 class GEOS_DLL PolygonExtracter: public GeometryFilter { 00034 00035 public: 00036 00044 static void getPolygons(const Geometry &geom, std::vector<const Polygon*>& ret) 00045 { 00046 PolygonExtracter pe(ret); 00047 geom.apply_ro(&pe); 00048 } 00049 00054 PolygonExtracter(std::vector<const Polygon*>& newComps) 00055 : 00056 comps(newComps) 00057 {} 00058 00059 void filter_rw(Geometry *geom) { 00060 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) ) 00061 { 00062 comps.push_back(p); 00063 } 00064 } 00065 00066 void filter_ro(const Geometry *geom) 00067 { 00068 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) ) 00069 { 00070 comps.push_back(p); 00071 } 00072 } 00073 00074 private: 00075 00077 std::vector<const Polygon*>& comps; 00078 00079 // Declare type as noncopyable 00080 PolygonExtracter(const PolygonExtracter& other); 00081 PolygonExtracter& operator=(const PolygonExtracter& rhs); 00082 }; 00083 00084 } // namespace geos.geom.util 00085 } // namespace geos.geom 00086 } // namespace geos 00087 00088 #endif 00089 00090 /********************************************************************** 00091 * $Log$ 00092 * Revision 1.1 2006/03/09 16:46:49 strk 00093 * geos::geom namespace definition, first pass at headers split 00094 * 00095 **********************************************************************/