QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgis.h"
25#include "qgsvector3d.h"
26
27#include <QList>
28#include <limits>
29
30class QgsBox3D;
32class QgsMatrix4x4;
33
43class CORE_EXPORT QgsOrientedBox3D
44{
45 public:
46
51
55 QgsOrientedBox3D( const QList<double> &center, const QList< double > &halfAxes );
56
60 QgsOrientedBox3D( const QgsVector3D &center, const QList< QgsVector3D > &halfAxes );
61
65 static QgsOrientedBox3D fromBox3D( const QgsBox3D &box );
66
67 bool operator==( const QgsOrientedBox3D &other ) const SIP_HOLDGIL
68 {
69 return qgsDoubleNear( mCenter[0], other.mCenter[0] )
70 && qgsDoubleNear( mCenter[1], other.mCenter[1] )
71 && qgsDoubleNear( mCenter[2], other.mCenter[2] )
72 && qgsDoubleNear( mHalfAxes[0], other.mHalfAxes[0] )
73 && qgsDoubleNear( mHalfAxes[1], other.mHalfAxes[1] )
74 && qgsDoubleNear( mHalfAxes[2], other.mHalfAxes[2] )
75 && qgsDoubleNear( mHalfAxes[3], other.mHalfAxes[3] )
76 && qgsDoubleNear( mHalfAxes[4], other.mHalfAxes[4] )
77 && qgsDoubleNear( mHalfAxes[5], other.mHalfAxes[5] )
78 && qgsDoubleNear( mHalfAxes[6], other.mHalfAxes[6] )
79 && qgsDoubleNear( mHalfAxes[7], other.mHalfAxes[7] )
80 && qgsDoubleNear( mHalfAxes[8], other.mHalfAxes[8] );
81 }
82
83 bool operator!=( const QgsOrientedBox3D &other ) const SIP_HOLDGIL
84 {
85 return !( *this == other );
86 }
87
91 bool isNull() const SIP_HOLDGIL;
92
99 double centerX() const SIP_HOLDGIL { return mCenter[0]; }
100
107 double centerY() const SIP_HOLDGIL { return mCenter[1]; }
108
115 double centerZ() const SIP_HOLDGIL { return mCenter[2]; }
116
120 QgsVector3D center() const SIP_HOLDGIL { return QgsVector3D( mCenter[0], mCenter[1], mCenter[2] ); }
121
125 const double *halfAxes() const SIP_SKIP { return mHalfAxes; }
126
130 QList< double > halfAxesList() const SIP_HOLDGIL SIP_PYNAME( halfAxes );
131
135 QgsBox3D extent() const SIP_HOLDGIL;
136
140 QVector< QgsVector3D > corners() const SIP_HOLDGIL;
141
145 QgsVector3D size() const SIP_HOLDGIL;
146
152 QgsBox3D reprojectedExtent( const QgsCoordinateTransform &ct ) const SIP_THROW( QgsCsException ) SIP_HOLDGIL;
153
157 QgsOrientedBox3D transformed( const QgsMatrix4x4 &transform ) const SIP_HOLDGIL;
158
162 bool intersects( const QgsOrientedBox3D &other ) const SIP_HOLDGIL;
163
164#ifdef SIP_RUN
165 SIP_PYOBJECT __repr__();
166 % MethodCode
167 QString str = QStringLiteral( "<QgsOrientedBox3D([%1, %2, %3], [%4, %5, %6, %7, %8, %9, %10, %11, %12])>" )
168 .arg( sipCpp->centerX() )
169 .arg( sipCpp->centerY() )
170 .arg( sipCpp->centerZ() )
171 .arg( sipCpp->halfAxes()[0] )
172 .arg( sipCpp->halfAxes()[1] )
173 .arg( sipCpp->halfAxes()[2] )
174 .arg( sipCpp->halfAxes()[3] )
175 .arg( sipCpp->halfAxes()[4] )
176 .arg( sipCpp->halfAxes()[5] )
177 .arg( sipCpp->halfAxes()[6] )
178 .arg( sipCpp->halfAxes()[7] )
179 .arg( sipCpp->halfAxes()[8] );
180 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
181 % End
182#endif
183
184 private:
185
186 double mCenter[ 3 ] { std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN() };
187 double mHalfAxes[9] { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
188
189 friend class QgsCesiumUtils;
190
191};
192
193
194#endif // QGSORIENTEDBOX3D_H
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:44
Contains utilities for working with Cesium data.
Class for doing transforms between two map 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;.
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
double centerY() const
Returns the center y-coordinate.
QgsVector3D center() const
Returns the vector to the center of the box.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:32
#define str(x)
Definition qgis.cpp:38
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:4332
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_PYNAME(name)
Definition qgis_sip.h:81
#define SIP_HOLDGIL
Definition qgis_sip.h:166
#define SIP_THROW(name,...)
Definition qgis_sip.h:198