GEOS: PolygonExtracter.h Source File

GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

PolygonExtracter.h
1 /**********************************************************************
2 * $Id: PolygonExtracter.h 2772 2009-12-03 19:30:54Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 * Copyright (C) 2006 Refractions Research Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************/
16
17 #ifndef GEOS_GEOM_UTIL_POLYGONEXTRACTER_H
18 #define GEOS_GEOM_UTIL_POLYGONEXTRACTER_H
19
20 #include <geos/export.h>
21 #include <geos/geom/GeometryFilter.h>
22 #include <geos/geom/Polygon.h>
23 #include <geos/platform.h>
24 #include <vector>
25
26 namespace geos {
27 namespace geom { // geos.geom
28 namespace util { // geos.geom.util
29
33 class GEOS_DLL PolygonExtracter: public GeometryFilter {
34
35 public:
36
44 static void getPolygons(const Geometry &geom, std::vector<const Polygon*>& ret)
45 {
46 PolygonExtracter pe(ret);
47 geom.apply_ro(&pe);
48 }
49
54 PolygonExtracter(std::vector<const Polygon*>& newComps)
55 :
56 comps(newComps)
57 {}
58
59 void filter_rw(Geometry *geom) {
60 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
61 {
62 comps.push_back(p);
63 }
64 }
65
66 void filter_ro(const Geometry *geom)
67 {
68 if ( const Polygon *p=dynamic_cast<const Polygon *>(geom) )
69 {
70 comps.push_back(p);
71 }
72 }
73
74 private:
75
77 std::vector<const Polygon*>& comps;
78
79 // Declare type as noncopyable
80 PolygonExtracter(const PolygonExtracter& other);
81 PolygonExtracter& operator=(const PolygonExtracter& rhs);
82 };
83
84 } // namespace geos.geom.util
85 } // namespace geos.geom
86 } // namespace geos
87
88 #endif
89
90 /**********************************************************************
91 * $Log$
92 * Revision 1.1 2006/03/09 16:46:49 strk
93 * geos::geom namespace definition, first pass at headers split
94 *
95 **********************************************************************/