QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsorientedbox3d.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsorientedbox3d.h
3 --------------------
4 begin : July 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ******************************************************************
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#ifndef QGSORIENTEDBOX3D_H
20#define QGSORIENTEDBOX3D_H
21
22#include <limits>
23
24#include "qgis.h"
25#include "qgis_core.h"
26#include "qgis_sip.h"
27#include "qgsvector3d.h"
28
29#include <QList>
30#include <QString>
31
32using namespace Qt::StringLiterals;
33
34class QgsBox3D;
36class QgsMatrix4x4;
37
47class CORE_EXPORT QgsOrientedBox3D
48{
49 public:
50
55
59 QgsOrientedBox3D( const QList<double> &center, const QList< double > &halfAxes );
60
64 QgsOrientedBox3D( const QgsVector3D &center, const QList< QgsVector3D > &halfAxes );
65
70 QgsOrientedBox3D( const QgsVector3D &center, const QgsVector3D &halfSizes, const QQuaternion &quaternion );
71
75 static QgsOrientedBox3D fromBox3D( const QgsBox3D &box );
76
77 bool operator==( const QgsOrientedBox3D &other ) const SIP_HOLDGIL
78 {
79 return qgsDoubleNear( mCenter[0], other.mCenter[0] )
80 && qgsDoubleNear( mCenter[1], other.mCenter[1] )
81 && qgsDoubleNear( mCenter[2], other.mCenter[2] )
82 && qgsDoubleNear( mHalfAxes[0], other.mHalfAxes[0] )
83 && qgsDoubleNear( mHalfAxes[1], other.mHalfAxes[1] )
84 && qgsDoubleNear( mHalfAxes[2], other.mHalfAxes[2] )
85 && qgsDoubleNear( mHalfAxes[3], other.mHalfAxes[3] )
86 && qgsDoubleNear( mHalfAxes[4], other.mHalfAxes[4] )
87 && qgsDoubleNear( mHalfAxes[5], other.mHalfAxes[5] )
88 && qgsDoubleNear( mHalfAxes[6], other.mHalfAxes[6] )
89 && qgsDoubleNear( mHalfAxes[7], other.mHalfAxes[7] )
90 && qgsDoubleNear( mHalfAxes[8], other.mHalfAxes[8] );
91 }
92
93 bool operator!=( const QgsOrientedBox3D &other ) const SIP_HOLDGIL
94 {
95 return !( *this == other );
96 }
97
101 bool isNull() const SIP_HOLDGIL;
102
109 double centerX() const SIP_HOLDGIL { return mCenter[0]; }
110
117 double centerY() const SIP_HOLDGIL { return mCenter[1]; }
118
125 double centerZ() const SIP_HOLDGIL { return mCenter[2]; }
126
130 QgsVector3D center() const SIP_HOLDGIL { return QgsVector3D( mCenter[0], mCenter[1], mCenter[2] ); }
131
135 const double *halfAxes() const SIP_SKIP { return mHalfAxes; }
136
140 QList< double > halfAxesList() const SIP_HOLDGIL SIP_PYNAME( halfAxes );
141
145 QgsBox3D extent() const SIP_HOLDGIL;
146
150 QVector< QgsVector3D > corners() const SIP_HOLDGIL;
151
155 QgsVector3D size() const SIP_HOLDGIL;
156
161 double longestSide() const SIP_HOLDGIL;
162
168 QgsBox3D reprojectedExtent( const QgsCoordinateTransform &ct ) const SIP_THROW( QgsCsException ) SIP_HOLDGIL;
169
173 QgsOrientedBox3D transformed( const QgsMatrix4x4 &transform ) const SIP_HOLDGIL;
174
178 bool intersects( const QgsOrientedBox3D &other ) const SIP_HOLDGIL;
179
180#ifdef SIP_RUN
181 SIP_PYOBJECT __repr__();
182 % MethodCode
183 QString str = u"<QgsOrientedBox3D([%1, %2, %3], [%4, %5, %6, %7, %8, %9, %10, %11, %12])>"_s
184 .arg( sipCpp->centerX() )
185 .arg( sipCpp->centerY() )
186 .arg( sipCpp->centerZ() )
187 .arg( sipCpp->halfAxes()[0] )
188 .arg( sipCpp->halfAxes()[1] )
189 .arg( sipCpp->halfAxes()[2] )
190 .arg( sipCpp->halfAxes()[3] )
191 .arg( sipCpp->halfAxes()[4] )
192 .arg( sipCpp->halfAxes()[5] )
193 .arg( sipCpp->halfAxes()[6] )
194 .arg( sipCpp->halfAxes()[7] )
195 .arg( sipCpp->halfAxes()[8] );
196 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
197 % End
198#endif
199
200 private:
201
202 double mCenter[ 3 ] { std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN() };
203 double mHalfAxes[9] { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
204
205 friend class QgsCesiumUtils;
206
207};
208
209
210#endif // QGSORIENTEDBOX3D_H
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
Handles coordinate transforms between two coordinate systems.
Custom exception class for Coordinate Reference System related exceptions.
A simple 4x4 matrix implementation useful for transformation in 3D space.
Represents a oriented (rotated) box in 3 dimensions.
const double * halfAxes() const
Returns the half axes matrix;.
friend class QgsCesiumUtils
double centerZ() const
Returns the center z-coordinate.
QgsOrientedBox3D()
Constructor for a null oriented box.
bool operator==(const QgsOrientedBox3D &other) const
bool operator!=(const QgsOrientedBox3D &other) const
static QgsOrientedBox3D fromBox3D(const QgsBox3D &box)
Constructs an oriented box from an axis-aligned bounding box.
double centerX() const
Returns the center x-coordinate.
double centerY() const
Returns the center y-coordinate.
QgsVector3D center() const
Returns the vector to the center of the box.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:6900
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_PYNAME(name)
Definition qgis_sip.h:89
#define SIP_HOLDGIL
Definition qgis_sip.h:179
#define SIP_THROW(name,...)
Definition qgis_sip.h:211