GEOS  3.3.3
PointExtracter.h
1 /**********************************************************************
2  * $Id: PointExtracter.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_POINTEXTRACTER_H
18 #define GEOS_GEOM_UTIL_POINTEXTRACTER_H
19 
20 #include <geos/export.h>
21 #include <geos/geom/GeometryFilter.h>
22 #include <geos/geom/Point.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 PointExtracter: public GeometryFilter {
34 
35 public:
42  static void getPoints(const Geometry &geom, Point::ConstVect &ret)
43  {
44  PointExtracter pe(ret);
45  geom.apply_ro(&pe);
46  }
47 
53  :
54  comps(newComps)
55  {}
56 
57  void filter_rw(Geometry *geom)
58  {
59 if ( const Point *p=dynamic_cast<const Point *>(geom) )
60  comps.push_back(p);
61  }
62 
63  void filter_ro(const Geometry *geom)
64  {
65 if ( const Point *p=dynamic_cast<const Point *>(geom) )
66  comps.push_back(p);
67  }
68 
69 private:
70 
71  Point::ConstVect& comps;
72 
73  // Declare type as noncopyable
74  PointExtracter(const PointExtracter& other);
75  PointExtracter& operator=(const PointExtracter& rhs);
76 };
77 
78 } // namespace geos.geom.util
79 } // namespace geos.geom
80 } // namespace geos
81 
82 #endif
83 
84 /**********************************************************************
85  * $Log$
86  * Revision 1.1 2006/03/09 16:46:49 strk
87  * geos::geom namespace definition, first pass at headers split
88  *
89  **********************************************************************/