forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move QgsOrientedBoundingBox out to own file
- Loading branch information
1 parent
525098b
commit f6cae1f
Showing
12 changed files
with
392 additions
and
285 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
python/core/auto_generated/geometry/qgsorientedboundingbox.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/geometry/qgsorientedboundingbox.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsOrientedBoundingBox | ||
{ | ||
%Docstring(signature="appended") | ||
Represents a oriented (rotated) bounding box in 3 dimensions. | ||
|
||
.. warning:: | ||
|
||
Non-stable API, exposed to Python for unit testing only. | ||
|
||
.. versionadded:: 3.34 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsorientedboundingbox.h" | ||
%End | ||
public: | ||
|
||
QgsOrientedBoundingBox(); | ||
%Docstring | ||
Constructor for a null bounding box. | ||
%End | ||
|
||
QgsOrientedBoundingBox( const QList<double> ¢er, QList< double > &halfAxes ); | ||
%Docstring | ||
Constructor for a oriented bounding box, with a specified center and half axes matrix. | ||
%End | ||
|
||
bool isNull() const; | ||
%Docstring | ||
Returns ``True`` if the box is a null bounding box. | ||
%End | ||
|
||
double centerX() const; | ||
%Docstring | ||
Returns the center x-coordinate. | ||
|
||
.. seealso:: :py:func:`centerY` | ||
|
||
.. seealso:: :py:func:`centerZ` | ||
%End | ||
|
||
double centerY() const; | ||
%Docstring | ||
Returns the center y-coordinate. | ||
|
||
.. seealso:: :py:func:`centerX` | ||
|
||
.. seealso:: :py:func:`centerZ` | ||
%End | ||
|
||
double centerZ() const; | ||
%Docstring | ||
Returns the center z-coordinate. | ||
|
||
.. seealso:: :py:func:`centerX` | ||
|
||
.. seealso:: :py:func:`centerY` | ||
%End | ||
|
||
|
||
QList< double > halfAxesList() const /PyName=halfAxes/; | ||
%Docstring | ||
Returns the half axes matrix; | ||
%End | ||
|
||
QgsBox3d extent() const; | ||
%Docstring | ||
Returns the overall bounding box of the object. | ||
%End | ||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/geometry/qgsorientedboundingbox.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*************************************************************************** | ||
qgsorientedboundingbox.cpp | ||
-------------------- | ||
begin : July 2023 | ||
copyright : (C) 2023 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
****************************************************************** | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsorientedboundingbox.h" | ||
#include "qgsbox3d.h" | ||
|
||
QgsOrientedBoundingBox::QgsOrientedBoundingBox() = default; | ||
|
||
QgsOrientedBoundingBox::QgsOrientedBoundingBox( const QList<double> ¢er, QList<double> &halfAxes ) | ||
{ | ||
if ( center.size() == 3 ) | ||
{ | ||
mCenter[0] = center.at( 0 ); | ||
mCenter[1] = center.at( 1 ); | ||
mCenter[2] = center.at( 2 ); | ||
} | ||
if ( halfAxes.size() == 9 ) | ||
{ | ||
for ( int i = 0; i < 9; ++i ) | ||
{ | ||
mHalfAxes[i] = halfAxes.at( i ); | ||
} | ||
} | ||
} | ||
|
||
bool QgsOrientedBoundingBox::isNull() const | ||
{ | ||
return std::isnan( mCenter[0] ) || std::isnan( mCenter[1] ) || std::isnan( mCenter[2] ); | ||
} | ||
|
||
QList< double > QgsOrientedBoundingBox::halfAxesList() const | ||
{ | ||
QList< double > res; | ||
res.reserve( 9 ); | ||
for ( int i = 0; i < 9; ++i ) | ||
{ | ||
res.append( mHalfAxes[i] ); | ||
} | ||
return res; | ||
} | ||
|
||
QgsBox3d QgsOrientedBoundingBox::extent() const | ||
{ | ||
const double extent[3] | ||
{ | ||
std::fabs( mHalfAxes[0] ) + std::fabs( mHalfAxes[3] ) + std::fabs( mHalfAxes[6] ), | ||
std::fabs( mHalfAxes[1] ) + std::fabs( mHalfAxes[4] ) + std::fabs( mHalfAxes[7] ), | ||
std::fabs( mHalfAxes[2] ) + std::fabs( mHalfAxes[5] ) + std::fabs( mHalfAxes[8] ), | ||
}; | ||
|
||
const double minX = mCenter[0] - extent[0]; | ||
const double maxX = mCenter[0] + extent[0]; | ||
const double minY = mCenter[1] - extent[1]; | ||
const double maxY = mCenter[1] + extent[1]; | ||
const double minZ = mCenter[2] - extent[2]; | ||
const double maxZ = mCenter[2] + extent[2]; | ||
|
||
return QgsBox3d( minX, minY, minZ, maxX, maxY, maxZ ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/*************************************************************************** | ||
qgsorientedboundingbox.h | ||
-------------------- | ||
begin : July 2023 | ||
copyright : (C) 2023 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
****************************************************************** | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSORIENTEDBOUNDINGBOX_H | ||
#define QGSORIENTEDBOUNDINGBOX_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis_sip.h" | ||
|
||
#include <QList> | ||
#include <limits> | ||
|
||
class QgsBox3d; | ||
|
||
/** | ||
* \brief Represents a oriented (rotated) bounding box in 3 dimensions. | ||
* | ||
* \ingroup core | ||
* | ||
* \warning Non-stable API, exposed to Python for unit testing only. | ||
* | ||
* \since QGIS 3.34 | ||
*/ | ||
class CORE_EXPORT QgsOrientedBoundingBox | ||
{ | ||
public: | ||
|
||
/** | ||
* Constructor for a null bounding box. | ||
*/ | ||
QgsOrientedBoundingBox(); | ||
|
||
/** | ||
* Constructor for a oriented bounding box, with a specified center and half axes matrix. | ||
*/ | ||
QgsOrientedBoundingBox( const QList<double> ¢er, QList< double > &halfAxes ); | ||
|
||
/** | ||
* Returns TRUE if the box is a null bounding box. | ||
*/ | ||
bool isNull() const; | ||
|
||
/** | ||
* Returns the center x-coordinate. | ||
* | ||
* \see centerY() | ||
* \see centerZ() | ||
*/ | ||
double centerX() const { return mCenter[0]; } | ||
|
||
/** | ||
* Returns the center y-coordinate. | ||
* \see centerX() | ||
* \see centerZ() | ||
*/ | ||
double centerY() const { return mCenter[1]; } | ||
|
||
/** | ||
* Returns the center z-coordinate. | ||
* | ||
* \see centerX() | ||
* \see centerY() | ||
*/ | ||
double centerZ() const { return mCenter[2]; } | ||
|
||
/** | ||
* Returns the half axes matrix; | ||
*/ | ||
const double *halfAxes() const SIP_SKIP { return mHalfAxes; } | ||
|
||
/** | ||
* Returns the half axes matrix; | ||
*/ | ||
QList< double > halfAxesList() const SIP_PYNAME( halfAxes ); | ||
|
||
/** | ||
* Returns the overall bounding box of the object. | ||
*/ | ||
QgsBox3d extent() const; | ||
|
||
private: | ||
|
||
double mCenter[ 3 ] { std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN() }; | ||
double mHalfAxes[9] { 1, 0, 0, 0, 1, 0, 0, 0, 1 }; | ||
|
||
friend class QgsCesiumUtils; | ||
|
||
}; | ||
|
||
|
||
#endif // QGSORIENTEDBOUNDINGBOX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.