QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
24 class QgsPoint;
25 
36 class CORE_EXPORT QgsBox3d
37 {
38  public:
39 
43  QgsBox3d( double xmin = 0, double ymin = 0, double zmin = 0, double xmax = 0, double ymax = 0, double zmax = 0 );
44 
49  QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 );
50 
55  QgsBox3d( const QgsRectangle &rect );
56 
62  void setXMinimum( double x );
63 
69  void setXMaximum( double x );
70 
76  double xMinimum() const { return mBounds2d.xMinimum(); }
77 
83  double xMaximum() const { return mBounds2d.xMaximum(); }
84 
90  void setYMinimum( double y );
91 
97  void setYMaximum( double y );
98 
104  double yMinimum() const { return mBounds2d.yMinimum(); }
105 
111  double yMaximum() const { return mBounds2d.yMaximum(); }
112 
118  void setZMinimum( double z );
119 
125  void setZMaximum( double z );
126 
132  double zMinimum() const { return mZmin; }
133 
139  double zMaximum() const { return mZmax; }
140 
144  void normalize();
145 
151  double width() const { return mBounds2d.width(); }
152 
158  double height() const { return mBounds2d.height(); }
159 
165  double depth() const { return mZmax - mZmin; }
166 
170  double volume() const { return mBounds2d.area() * ( mZmax - mZmin ); }
171 
175  QgsBox3d intersect( const QgsBox3d &other ) const;
176 
181  bool is2d() const;
182 
186  bool intersects( const QgsBox3d &other ) const;
187 
191  bool contains( const QgsBox3d &other ) const;
192 
199  bool contains( const QgsPoint &point ) const;
200 
204  QgsRectangle toRectangle() const { return mBounds2d; }
205 
206  bool operator==( const QgsBox3d &other ) const;
207 
208  private:
209 
210  QgsRectangle mBounds2d;
211  double mZmin = 0.0;
212  double mZmax = 0.0;
213 
214 };
215 
216 #endif // QGSBOX3D_H
A rectangle specified with double values.
Definition: qgsrectangle.h:40
double zMaximum() const
Returns the maximum z value.
Definition: qgsbox3d.h:139
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double volume() const
Returns the volume of the box.
Definition: qgsbox3d.h:170
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:36
double zMinimum() const
Returns the minimum z value.
Definition: qgsbox3d.h:132
double height() const
Returns the height of the box.
Definition: qgsbox3d.h:158
double width() const
Returns the width of the box.
Definition: qgsbox3d.h:151
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
double xMaximum() const
Returns the maximum x value.
Definition: qgsbox3d.h:83
QgsRectangle toRectangle() const
Converts the box to a 2D rectangle.
Definition: qgsbox3d.h:204
double yMinimum() const
Returns the minimum y value.
Definition: qgsbox3d.h:104
double xMinimum() const
Returns the minimum x value.
Definition: qgsbox3d.h:76
double depth() const
Returns the depth of the box.
Definition: qgsbox3d.h:165
double yMaximum() const
Returns the maximum y value.
Definition: qgsbox3d.h:111