PolyhedralSurface.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/geometry/PolyhedralSurface.h
22 
23  \brief PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_POLYHEDRALSURFACE_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_POLYHEDRALSURFACE_H
28 
29 // TerraLib
30 #include "Surface.h"
31 
32 // STL
33 #include <vector>
34 
35 namespace te
36 {
37  namespace gm
38  {
39 // Forward declarations
40  class MultiPolygon;
41  class Polygon;
42 
43  /*!
44  \class PolyhedralSurface
45 
46  \brief PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments.
47 
48  \ingroup geometry
49 
50  \sa Geometry,
51  Point,
52  Curve, LineString, LinearRing,
53  Surface, Polygon, Triangle, TIN,
54  GeometryCollection, MultiSurface, MultiCurve,
55  MultiPoint, MultiLineString, MultiPolygon
56  */
58  {
59  public:
60 
62 
63  /** @name Initializer methods on geometric objects
64  * Methods for initializing a geometric object.
65  */
66  //@{
67 
68  /*!
69  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
70 
71  \param nPolygons The number of polygons forming the polyhedral.
72  \param t The internal type of the Geometry.
73  \param srid The Spatial Reference System ID associated to the Geometry.
74  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope). It may be a NULL value.
75 
76  \note The Geometry will take the ownership of the given mbr.
77  */
78  PolyhedralSurface(std::size_t nPolygons, GeomType t, int srid = 0, Envelope* mbr = 0);
79 
80  /*!
81  \brief Copy constructor.
82 
83  \param rhs The other geometry.
84  */
85  PolyhedralSurface(const PolyhedralSurface& rhs);
86 
87  /*! \brief Virtual destructor. */
88  virtual ~PolyhedralSurface();
89 
90  /*!
91  \brief Assignment operator.
92 
93  \param rhs The other geometry.
94 
95  \return A reference for this.
96  */
97  virtual PolyhedralSurface& operator=(const PolyhedralSurface& rhs);
98 
99  //@}
100 
101  /** @name Re-Implementation from AbstractData
102  * Methods re-Implementated from AbstractData.
103  */
104  //@{
105 
106  /*!
107  \brief It clones the linestring.
108 
109  \return A copy of the given linestring.
110 
111  \note The caller of this method will take the ownership of the returned linestring.
112 
113  \note The cloned linestring will not have the
114  MBR computed. This will save time when you
115  are just cloning a geometry and don't intend
116  to waste time computing the bounding box.
117  If you have another suggestion, please, let me know.
118  */
119  virtual te::dt::AbstractData* clone() const;
120 
121  //@}
122 
123  /** @name PolyhedralSurface Specific Methods
124  * Specific methods for a PolyhedralSurface.
125  */
126  //@{
127 
128  /*!
129  \brief It returns the number of including polygons.
130 
131  \return The number of including polygons.
132  */
133  std::size_t getNumPatches() const
134  {
135  return m_polygons.size();
136  }
137 
138  /*!
139  \brief It sets the number of including polygons.
140 
141  If the new size is less than the old it will drop the geometries.
142 
143  \param size The number of polygons for the PolyhedralSurface.
144 
145  \note TerraLib extended method.
146  */
147  void setNumPatches(std::size_t size);
148 
149  /*!
150  \brief It returns a polygon in this surface, the order is arbitrary.
151 
152  \param i The index of the polygon component.
153 
154  \return A polygon in this surface, the order is arbitrary.
155 
156  \note It doesn't check the index range.
157  */
158  Polygon* getPatchN(std::size_t i) const;
159 
160  /*!
161  \brief It sets the informed position polygon to the new one.
162 
163  \param i The polygon index.
164  \param p The new polygon to be placed in the informed position.
165 
166  \note The polygon index start at 0.
167 
168  \note It doesn't check the index range.
169 
170  \note TerraLib extended method.
171  */
172  void setPatchN(std::size_t i, Polygon* p);
173 
174  /*!
175  \brief It returns the collection of polygons in this surface that bounds the given polygon "p" for any polygon "p" in the surface.
176 
177  \param p The bounding Polygon.
178 
179  \return The collection of polygons in this surface that bounds the given polygon "p" for any polygon "p" in the surface.
180 
181  \note The caller of this method will take the ownership of the returned geometry.
182  */
183  MultiPolygon* getBoundingPolygons(const Polygon* p) const;
184 
185  /*!
186  \brief It returns true if the polygon closes on itself, and thus has no boundary and encloses a solid.
187 
188  \return True if the polygon closes on itself, and thus has no boundary and encloses a solid.
189  */
190  bool isClosed() const
191  {
192  return false;
193  }
194 
195  //@}
196 
197  /** @name Re-Implmentation of methods from surface class
198  * Re-Implmentation of basic methods from surface class.
199  */
200  //@{
201 
202  /*!
203  \brief It returns the area of this surface, as measured in the spatial reference system of this surface.
204 
205  \return The area of this surface.
206  */
207  double getArea() const
208  {
209  return 0.0;
210  }
211 
212  /*!
213  \brief It returns the mathematical centroid for this surface as a point.
214 
215  \return The mathematical centroid for this surface.
216 
217  \note The caller of this method will take the ownership of the returned point.
218 
219  \note The result is not guaranteed to be on this Surface.
220  */
222  {
223  return 0;
224  }
225 
226  /*!
227  \brief It returns the mathematical centroid for this surface as a coordinate.
228 
229  \return The mathematical centroid for this surface.
230 
231  \note The caller of this method will take the ownership of the returned coordinate.
232 
233  \note The result is not guaranteed to be on this Surface.
234 
235  \note TerraLib extended method.
236  */
238  {
239  return 0;
240  }
241 
242  /*!
243  \brief It returns a point guaranteed to be on this surface.
244 
245  \return A point guaranteed to be on this surface.
246 
247  \note The caller of this method will take the ownership of the returned point.
248  */
250  {
251  return 0;
252  }
253 
254  /*!
255  \brief It returns a coordinate guaranteed to be on this surface.
256 
257  \return A point guaranteed to be on this surface.
258 
259  \note The caller of this method will take the ownership of the returned coordinate.
260 
261  \note TerraLib extended method.
262  */
264  {
265  return 0;
266  }
267 
268  /*!
269  \brief It returns the length of the boundary for the surface.
270 
271  \return The length of the boundary for the surface.
272  */
273  double getPerimeter() const;
274 
275  //@}
276 
277  /** @name Re-Implmentation of methods from Geometry class
278  * Re-Implmentation of basic methods from Geometry class.
279  */
280  //@{
281 
282  /*!
283  \brief The name of the geometry subtype for PolyhedralSurface is: PolyhedralSurface.
284 
285  \return The name of the geometry subtype for PolyhedralSurface is: PolyhedralSurface.
286  */
287  virtual const std::string& getGeometryType() const throw();
288 
289  /*!
290  \brief It sets the Spatial Reference System ID of the Geometry and all its parts if it is a GeometryCollection (or a Multi).
291 
292  \param srid The Spatial Reference System ID to be associated to the geometric object.
293 
294  \note TerraLib extended method.
295  */
296  void setSRID(int srid) throw();
297 
298  /*!
299  \brief It will transform the coordinates of the Geometry to the new one.
300 
301  After calling this method the Geometry will be associated to the new SRID.
302 
303  \param srid The new Spatial Reference System ID used to transform the coordinates of the Geometry.
304 
305  \exception Exception It will throw an exception if it can not do the transformation.
306 
307  \note The Geometry must be associated to a valid SRID before calling this method.
308 
309  \note If the geometry already has an associated MBR, it will automatically update it (i. e. automatically recompute it).
310 
311  \note TerraLib extended method.
312  */
313  void transform(int srid) throw(te::common::Exception);
314 
315  /*!
316  \brief It computes the minimum bounding rectangle for the Geometry.
317 
318  \param cascade If true, it will update the MBR of its parts.
319 
320  \note You can use this method in order to update the MBR of the Geometry.
321 
322  \note TerraLib extended method.
323  */
324  void computeMBR(bool cascade) const throw();
325 
326  /*!
327  \brief it returns the number of points (vertexes) in the geometry.
328 
329  \return The number of points (vertexes) in the geometry.
330 
331  \note TerraLib extended method.
332  */
333  std::size_t getNPoints() const throw();
334 
335  //@}
336 
337  protected:
338 
339  std::vector<Polygon*> m_polygons; //!< An array with the polygon list.
340 
341  private:
342 
343  static const std::string sm_typeName; //!< Geometry type name for PolyhedralSurface.
344  };
345 
346  } // end namespace gm
347 } // end namespace te
348 
349 #endif // __TERRALIB_GEOMETRY_INTERNAL_POLYHEDRALSURFACE_H
350 
351 
double getArea() const
It returns the area of this surface, as measured in the spatial reference system of this surface...
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
Base exception class for plugin module.
Definition: Exception.h:42
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
URI C++ Library.
Surface is an abstract class that represents a 2-dimensional geometric objects.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
Coord2D * getCentroidCoord() const
It returns the mathematical centroid for this surface as a coordinate.
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
Point * getCentroid() const
It returns the mathematical centroid for this surface as a point.
std::size_t getNumPatches() const
It returns the number of including polygons.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
Coord2D * getCoordOnSurface() const
It returns a coordinate guaranteed to be on this surface.
bool isClosed() const
It returns true if the polygon closes on itself, and thus has no boundary and encloses a solid...
Point * getPointOnSurface() const
It returns a point guaranteed to be on this surface.
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:54