QGIS API Documentation  3.17.0-Master (7a14973234)
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 ) SIP_HOLDGIL;
44 
49  QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 ) SIP_HOLDGIL;
50 
55  QgsBox3d( const QgsRectangle &rect ) SIP_HOLDGIL;
56 
62  void setXMinimum( double x ) SIP_HOLDGIL;
63 
69  void setXMaximum( double x ) SIP_HOLDGIL;
70 
76  double xMinimum() const SIP_HOLDGIL { return mBounds2d.xMinimum(); }
77 
83  double xMaximum() const SIP_HOLDGIL { return mBounds2d.xMaximum(); }
84 
90  void setYMinimum( double y ) SIP_HOLDGIL;
91 
97  void setYMaximum( double y ) SIP_HOLDGIL;
98 
104  double yMinimum() const SIP_HOLDGIL { return mBounds2d.yMinimum(); }
105 
111  double yMaximum() const SIP_HOLDGIL { return mBounds2d.yMaximum(); }
112 
118  void setZMinimum( double z ) SIP_HOLDGIL;
119 
125  void setZMaximum( double z ) SIP_HOLDGIL;
126 
132  double zMinimum() const SIP_HOLDGIL { return mZmin; }
133 
139  double zMaximum() const SIP_HOLDGIL { return mZmax; }
140 
144  void normalize();
145 
151  double width() const SIP_HOLDGIL { return mBounds2d.width(); }
152 
158  double height() const SIP_HOLDGIL { return mBounds2d.height(); }
159 
165  double depth() const SIP_HOLDGIL { return mZmax - mZmin; }
166 
170  double volume() const SIP_HOLDGIL { return mBounds2d.area() * ( mZmax - mZmin ); }
171 
175  QgsBox3d intersect( const QgsBox3d &other ) const;
176 
181  bool is2d() const SIP_HOLDGIL;
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
double zMaximum() const SIP_HOLDGIL
Returns the maximum z value.
Definition: qgsbox3d.h:139
A rectangle specified with double values.
Definition: qgsrectangle.h:41
double depth() const SIP_HOLDGIL
Returns the depth of the box.
Definition: qgsbox3d.h:165
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double xMinimum() const SIP_HOLDGIL
Returns the minimum x value.
Definition: qgsbox3d.h:76
double width() const SIP_HOLDGIL
Returns the width of the box.
Definition: qgsbox3d.h:151
double zMinimum() const SIP_HOLDGIL
Returns the minimum z value.
Definition: qgsbox3d.h:132
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:36
double yMinimum() const SIP_HOLDGIL
Returns the minimum y value.
Definition: qgsbox3d.h:104
QgsRectangle toRectangle() const
Converts the box to a 2D rectangle.
Definition: qgsbox3d.h:204
#define SIP_HOLDGIL
Definition: qgis_sip.h:157
double yMaximum() const SIP_HOLDGIL
Returns the maximum y value.
Definition: qgsbox3d.h:111
double height() const SIP_HOLDGIL
Returns the height of the box.
Definition: qgsbox3d.h:158
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
double xMaximum() const SIP_HOLDGIL
Returns the maximum x value.
Definition: qgsbox3d.h:83
double volume() const SIP_HOLDGIL
Returns the volume of the box.
Definition: qgsbox3d.h:170