# PolygonExtracter.h

    00001 /**********************************************************************
    00002  * $Id: PolygonExtracter.h 1820 2006-09-06 16:54:23Z 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/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 PolygonExtracter: public GeometryFilter {
    00033
    00034 private:
    00035
    00037         std::vector<const Polygon*>& comps;
    00038
    00039 public:
    00040
    00048         static void getPolygons(const Geometry &geom, std::vector<const Polygon*>& ret)
    00049         {
    00050                 PolygonExtracter pe(ret);
    00051                 geom.apply_ro(&pe);
    00052         }
    00053
    00058         PolygonExtracter(std::vector<const Polygon*>& newComps)
    00059                 :
    00060                 comps(newComps)
    00061                 {}
    00062
    00063         void filter_rw(Geometry *geom) {
    00064                 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
    00065                 {
    00066                         comps.push_back(p);
    00067                 }
    00068         }
    00069
    00070         void filter_ro(const Geometry *geom)
    00071         {
    00072                 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
    00073                 {
    00074                         comps.push_back(p);
    00075                 }
    00076         }
    00077
    00078 };
    00079
    00080 } // namespace geos.geom.util
    00081 } // namespace geos.geom
    00082 } // namespace geos
    00083
    00084 #endif
    00085
    00086 /**********************************************************************
    00087  * $Log$
    00088  * Revision 1.1  2006/03/09 16:46:49  strk
    00089  * geos::geom namespace definition, first pass at headers split
    00090  *
    00091  **********************************************************************/