QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 #include <QVector3D>
25 
26 class QgsPoint;
27 
38 class CORE_EXPORT QgsBox3d
39 {
40  public:
41 
45  QgsBox3d( double xmin = 0, double ymin = 0, double zmin = 0, double xmax = 0, double ymax = 0, double zmax = 0 ) SIP_HOLDGIL;
46 
51  QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 ) SIP_HOLDGIL;
52 
57  QgsBox3d( const QgsRectangle &rect ) SIP_HOLDGIL;
58 
64  void setXMinimum( double x ) SIP_HOLDGIL;
65 
71  void setXMaximum( double x ) SIP_HOLDGIL;
72 
78  double xMinimum() const SIP_HOLDGIL { return mBounds2d.xMinimum(); }
79 
85  double xMaximum() const SIP_HOLDGIL { return mBounds2d.xMaximum(); }
86 
92  void setYMinimum( double y ) SIP_HOLDGIL;
93 
99  void setYMaximum( double y ) SIP_HOLDGIL;
100 
106  double yMinimum() const SIP_HOLDGIL { return mBounds2d.yMinimum(); }
107 
113  double yMaximum() const SIP_HOLDGIL { return mBounds2d.yMaximum(); }
114 
120  void setZMinimum( double z ) SIP_HOLDGIL;
121 
127  void setZMaximum( double z ) SIP_HOLDGIL;
128 
134  double zMinimum() const SIP_HOLDGIL { return mZmin; }
135 
141  double zMaximum() const SIP_HOLDGIL { return mZmax; }
142 
146  void normalize();
147 
153  double width() const SIP_HOLDGIL { return mBounds2d.width(); }
154 
160  double height() const SIP_HOLDGIL { return mBounds2d.height(); }
161 
167  double depth() const SIP_HOLDGIL { return mZmax - mZmin; }
168 
172  double volume() const SIP_HOLDGIL { return mBounds2d.area() * ( mZmax - mZmin ); }
173 
177  QgsBox3d intersect( const QgsBox3d &other ) const;
178 
183  bool is2d() const SIP_HOLDGIL;
184 
188  bool intersects( const QgsBox3d &other ) const;
189 
193  bool contains( const QgsBox3d &other ) const;
194 
201  bool contains( const QgsPoint &point ) const;
202 
206  QgsRectangle toRectangle() const { return mBounds2d; }
207 
214  double distanceTo( const QVector3D &point ) const;
215 
216  bool operator==( const QgsBox3d &other ) const;
217 
218  private:
219 
220  QgsRectangle mBounds2d;
221  double mZmin = 0.0;
222  double mZmax = 0.0;
223 
224 };
225 
226 #endif // QGSBOX3D_H
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:39
double yMaximum() const SIP_HOLDGIL
Returns the maximum y value.
Definition: qgsbox3d.h:113
double zMaximum() const SIP_HOLDGIL
Returns the maximum z value.
Definition: qgsbox3d.h:141
double zMinimum() const SIP_HOLDGIL
Returns the minimum z value.
Definition: qgsbox3d.h:134
double xMinimum() const SIP_HOLDGIL
Returns the minimum x value.
Definition: qgsbox3d.h:78
double volume() const SIP_HOLDGIL
Returns the volume of the box.
Definition: qgsbox3d.h:172
double xMaximum() const SIP_HOLDGIL
Returns the maximum x value.
Definition: qgsbox3d.h:85
double depth() const SIP_HOLDGIL
Returns the depth of the box.
Definition: qgsbox3d.h:167
double height() const SIP_HOLDGIL
Returns the height of the box.
Definition: qgsbox3d.h:160
double width() const SIP_HOLDGIL
Returns the width of the box.
Definition: qgsbox3d.h:153
double yMinimum() const SIP_HOLDGIL
Returns the minimum y value.
Definition: qgsbox3d.h:106
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_HOLDGIL
Definition: qgis_sip.h:157
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)