QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsbox3d.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbox3d.h
3  ----------
4  begin : April 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSBOX3D_H
19 #define QGSBOX3D_H
20 
21 #include "qgis_core.h"
22 #include "qgsrectangle.h"
23 #include "qgspoint.h"
24 
35 class CORE_EXPORT QgsBox3d
36 {
37  public:
38 
42  QgsBox3d( double xmin = 0, double ymin = 0, double zmin = 0, double xmax = 0, double ymax = 0, double zmax = 0 );
43 
48  QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 );
49 
54  QgsBox3d( const QgsRectangle &rect );
55 
61  void setXMinimum( double x );
62 
68  void setXMaximum( double x );
69 
75  double xMinimum() const { return mBounds2d.xMinimum(); }
76 
82  double xMaximum() const { return mBounds2d.xMaximum(); }
83 
89  void setYMinimum( double y );
90 
96  void setYMaximum( double y );
97 
103  double yMinimum() const { return mBounds2d.yMinimum(); }
104 
110  double yMaximum() const { return mBounds2d.yMaximum(); }
111 
117  void setZMinimum( double z );
118 
124  void setZMaximum( double z );
125 
131  double zMinimum() const { return mZmin; }
132 
138  double zMaximum() const { return mZmax; }
139 
143  void normalize();
144 
150  double width() const { return mBounds2d.width(); }
151 
157  double height() const { return mBounds2d.height(); }
158 
164  double depth() const { return mZmax - mZmin; }
165 
169  double volume() const { return mBounds2d.area() * ( mZmax - mZmin ); }
170 
174  QgsBox3d intersect( const QgsBox3d &other ) const;
175 
180  bool is2d() const;
181 
185  bool intersects( const QgsBox3d &other ) const;
186 
190  bool contains( const QgsBox3d &other ) const;
191 
198  bool contains( const QgsPoint &point ) const;
199 
203  QgsRectangle toRectangle() const { return mBounds2d; }
204 
205  bool operator==( const QgsBox3d &other ) const;
206 
207  private:
208 
209  QgsRectangle mBounds2d;
210  double mZmin = 0.0;
211  double mZmax = 0.0;
212 
213 };
214 
215 #endif // QGSBOX3D_H
double height() const
Returns the height of the box.
Definition: qgsbox3d.h:157
A rectangle specified with double values.
Definition: qgsrectangle.h:40
double zMaximum() const
Returns the maximum z value.
Definition: qgsbox3d.h:138
double depth() const
Returns the depth of the box.
Definition: qgsbox3d.h:164
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:35
double yMaximum() const
Returns the maximum y value.
Definition: qgsbox3d.h:110
double xMinimum() const
Returns the minimum x value.
Definition: qgsbox3d.h:75
QgsRectangle toRectangle() const
Converts the box to a 2D rectangle.
Definition: qgsbox3d.h:203
double xMaximum() const
Returns the maximum x value.
Definition: qgsbox3d.h:82
double zMinimum() const
Returns the minimum z value.
Definition: qgsbox3d.h:131
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
double yMinimum() const
Returns the minimum y value.
Definition: qgsbox3d.h:103
double width() const
Returns the width of the box.
Definition: qgsbox3d.h:150
double volume() const
Returns the volume of the box.
Definition: qgsbox3d.h:169