PolygonExtracter.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************/
00015 
00016 #ifndef GEOS_GEOM_UTIL_POLYGONEXTRACTER_H
00017 #define GEOS_GEOM_UTIL_POLYGONEXTRACTER_H
00018 
00019 #include <geos/export.h>
00020 #include <geos/geom/GeometryFilter.h>
00021 #include <geos/geom/Polygon.h>
00022 #include <geos/platform.h>
00023 #include <vector>
00024 
00025 namespace geos {
00026 namespace geom { // geos.geom
00027 namespace util { // geos.geom.util
00028 
00032 class GEOS_DLL PolygonExtracter: public GeometryFilter {
00033 
00034 public:
00035 
00043         static void getPolygons(const Geometry &geom, std::vector<const Polygon*>& ret)
00044         {
00045                 PolygonExtracter pe(ret);
00046                 geom.apply_ro(&pe);
00047         }
00048 
00053         PolygonExtracter(std::vector<const Polygon*>& newComps)
00054                 :
00055                 comps(newComps)
00056                 {}
00057 
00058         void filter_rw(Geometry *geom) {
00059                 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
00060                 {
00061                         comps.push_back(p);
00062                 }
00063         }
00064 
00065         void filter_ro(const Geometry *geom)
00066         {
00067                 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
00068                 {
00069                         comps.push_back(p);
00070                 }
00071         }
00072 
00073 private:
00074 
00076     std::vector<const Polygon*>& comps;
00077 
00078     // Declare type as noncopyable
00079     PolygonExtracter(const PolygonExtracter& other);
00080     PolygonExtracter& operator=(const PolygonExtracter& rhs);
00081 };
00082 
00083 } // namespace geos.geom.util
00084 } // namespace geos.geom
00085 } // namespace geos
00086 
00087 #endif

Generated on 23 Sep 2013 for GEOS by  doxygen 1.4.7