diff --git a/python/core/auto_generated/geometry/qgsorientedboundingbox.sip.in b/python/core/auto_generated/geometry/qgsorientedbox3d.sip.in similarity index 76% rename from python/core/auto_generated/geometry/qgsorientedboundingbox.sip.in rename to python/core/auto_generated/geometry/qgsorientedbox3d.sip.in index 5ed493f8ade1..6bcdcbacb6e0 100644 --- a/python/core/auto_generated/geometry/qgsorientedboundingbox.sip.in +++ b/python/core/auto_generated/geometry/qgsorientedbox3d.sip.in @@ -1,7 +1,7 @@ /************************************************************************ * This file has been generated automatically from * * * - * src/core/geometry/qgsorientedboundingbox.h * + * src/core/geometry/qgsorientedbox3d.h * * * * Do not edit manually ! Edit header and run scripts/sipify.pl again * ************************************************************************/ @@ -11,10 +11,10 @@ -class QgsOrientedBoundingBox +class QgsOrientedBox3D { %Docstring(signature="appended") -Represents a oriented (rotated) bounding box in 3 dimensions. +Represents a oriented (rotated) box in 3 dimensions. .. warning:: @@ -24,23 +24,23 @@ Represents a oriented (rotated) bounding box in 3 dimensions. %End %TypeHeaderCode -#include "qgsorientedboundingbox.h" +#include "qgsorientedbox3d.h" %End public: - QgsOrientedBoundingBox(); + QgsOrientedBox3D(); %Docstring -Constructor for a null bounding box. +Constructor for a null oriented box. %End - QgsOrientedBoundingBox( const QList ¢er, QList< double > &halfAxes ); + QgsOrientedBox3D( const QList ¢er, QList< double > &halfAxes ); %Docstring -Constructor for a oriented bounding box, with a specified center and half axes matrix. +Constructor for a oriented box, with a specified center and half axes matrix. %End bool isNull() const; %Docstring -Returns ``True`` if the box is a null bounding box. +Returns ``True`` if the box is a null box. %End double centerX() const; @@ -87,7 +87,7 @@ Returns the overall bounding box of the object. /************************************************************************ * This file has been generated automatically from * * * - * src/core/geometry/qgsorientedboundingbox.h * + * src/core/geometry/qgsorientedbox3d.h * * * * Do not edit manually ! Edit header and run scripts/sipify.pl again * ************************************************************************/ diff --git a/python/core/auto_generated/tiledmesh/qgscesiumutils.sip.in b/python/core/auto_generated/tiledmesh/qgscesiumutils.sip.in index 31a4489c5b7d..8ac60f291e3a 100644 --- a/python/core/auto_generated/tiledmesh/qgscesiumutils.sip.in +++ b/python/core/auto_generated/tiledmesh/qgscesiumutils.sip.in @@ -31,7 +31,7 @@ Parses a ``region`` object from a Cesium JSON document to a 3D box. %End - static QgsOrientedBoundingBox parseBox( const QVariantList &box ); + static QgsOrientedBox3D parseBox( const QVariantList &box ); %Docstring Parses a ``box`` object from a Cesium JSON document to an oriented bounding box. %End diff --git a/python/core/core_auto.sip b/python/core/core_auto.sip index fc54db2f0628..983c22b7e96d 100644 --- a/python/core/core_auto.sip +++ b/python/core/core_auto.sip @@ -345,7 +345,7 @@ %Include auto_generated/geometry/qgsmultipoint.sip %Include auto_generated/geometry/qgsmultipolygon.sip %Include auto_generated/geometry/qgsmultisurface.sip -%Include auto_generated/geometry/qgsorientedboundingbox.sip +%Include auto_generated/geometry/qgsorientedbox3d.sip %Include auto_generated/geometry/qgspoint.sip %Include auto_generated/geometry/qgspolygon.sip %Include auto_generated/geometry/qgsquadrilateral.sip diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 80c119ac96ae..483ae5758fac 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -847,7 +847,7 @@ set(QGIS_CORE_SRCS geometry/qgsmultipoint.cpp geometry/qgsmultipolygon.cpp geometry/qgsmultisurface.cpp - geometry/qgsorientedboundingbox.cpp + geometry/qgsorientedbox3d.cpp geometry/qgspoint.cpp geometry/qgspolygon.cpp geometry/qgsquadrilateral.cpp @@ -1432,7 +1432,7 @@ set(QGIS_CORE_HDRS geometry/qgsmultipoint.h geometry/qgsmultipolygon.h geometry/qgsmultisurface.h - geometry/qgsorientedboundingbox.h + geometry/qgsorientedbox3d.h geometry/qgspoint.h geometry/qgspolygon.h geometry/qgsquadrilateral.h diff --git a/src/core/geometry/qgsorientedboundingbox.cpp b/src/core/geometry/qgsorientedbox3d.cpp similarity index 84% rename from src/core/geometry/qgsorientedboundingbox.cpp rename to src/core/geometry/qgsorientedbox3d.cpp index a8434476a0eb..525362f7e15a 100644 --- a/src/core/geometry/qgsorientedboundingbox.cpp +++ b/src/core/geometry/qgsorientedbox3d.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - qgsorientedboundingbox.cpp + qgsorientedbox3d.cpp -------------------- begin : July 2023 copyright : (C) 2023 by Nyall Dawson @@ -16,12 +16,12 @@ * * ***************************************************************************/ -#include "qgsorientedboundingbox.h" +#include "qgsorientedbox3d.h" #include "qgsbox3d.h" -QgsOrientedBoundingBox::QgsOrientedBoundingBox() = default; +QgsOrientedBox3D::QgsOrientedBox3D() = default; -QgsOrientedBoundingBox::QgsOrientedBoundingBox( const QList ¢er, QList &halfAxes ) +QgsOrientedBox3D::QgsOrientedBox3D( const QList ¢er, QList &halfAxes ) { if ( center.size() == 3 ) { @@ -38,12 +38,12 @@ QgsOrientedBoundingBox::QgsOrientedBoundingBox( const QList ¢er, QLi } } -bool QgsOrientedBoundingBox::isNull() const +bool QgsOrientedBox3D::isNull() const { return std::isnan( mCenter[0] ) || std::isnan( mCenter[1] ) || std::isnan( mCenter[2] ); } -QList< double > QgsOrientedBoundingBox::halfAxesList() const +QList< double > QgsOrientedBox3D::halfAxesList() const { QList< double > res; res.reserve( 9 ); @@ -54,7 +54,7 @@ QList< double > QgsOrientedBoundingBox::halfAxesList() const return res; } -QgsBox3d QgsOrientedBoundingBox::extent() const +QgsBox3d QgsOrientedBox3D::extent() const { const double extent[3] { diff --git a/src/core/geometry/qgsorientedboundingbox.h b/src/core/geometry/qgsorientedbox3d.h similarity index 80% rename from src/core/geometry/qgsorientedboundingbox.h rename to src/core/geometry/qgsorientedbox3d.h index 914639917332..547264c58bc4 100644 --- a/src/core/geometry/qgsorientedboundingbox.h +++ b/src/core/geometry/qgsorientedbox3d.h @@ -1,5 +1,5 @@ /*************************************************************************** - qgsorientedboundingbox.h + qgsorientedbox3d.h -------------------- begin : July 2023 copyright : (C) 2023 by Nyall Dawson @@ -16,8 +16,8 @@ * * ***************************************************************************/ -#ifndef QGSORIENTEDBOUNDINGBOX_H -#define QGSORIENTEDBOUNDINGBOX_H +#ifndef QGSORIENTEDBOX3D_H +#define QGSORIENTEDBOX3D_H #include "qgis_core.h" #include "qgis_sip.h" @@ -28,7 +28,7 @@ class QgsBox3d; /** - * \brief Represents a oriented (rotated) bounding box in 3 dimensions. + * \brief Represents a oriented (rotated) box in 3 dimensions. * * \ingroup core * @@ -36,22 +36,22 @@ class QgsBox3d; * * \since QGIS 3.34 */ -class CORE_EXPORT QgsOrientedBoundingBox +class CORE_EXPORT QgsOrientedBox3D { public: /** - * Constructor for a null bounding box. + * Constructor for a null oriented box. */ - QgsOrientedBoundingBox(); + QgsOrientedBox3D(); /** - * Constructor for a oriented bounding box, with a specified center and half axes matrix. + * Constructor for a oriented box, with a specified center and half axes matrix. */ - QgsOrientedBoundingBox( const QList ¢er, QList< double > &halfAxes ); + QgsOrientedBox3D( const QList ¢er, QList< double > &halfAxes ); /** - * Returns TRUE if the box is a null bounding box. + * Returns TRUE if the box is a null box. */ bool isNull() const; @@ -104,4 +104,4 @@ class CORE_EXPORT QgsOrientedBoundingBox }; -#endif // QGSORIENTEDBOUNDINGBOX_H +#endif // QGSORIENTEDBOX3D_H diff --git a/src/core/tiledmesh/qgscesiumtilesdataprovider.cpp b/src/core/tiledmesh/qgscesiumtilesdataprovider.cpp index f53b7a0e1d04..27d375e0cfdb 100644 --- a/src/core/tiledmesh/qgscesiumtilesdataprovider.cpp +++ b/src/core/tiledmesh/qgscesiumtilesdataprovider.cpp @@ -25,7 +25,7 @@ #include "qgscesiumutils.h" #include "qgssphere.h" #include "qgslogger.h" -#include "qgsorientedboundingbox.h" +#include "qgsorientedbox3d.h" #include #include @@ -73,7 +73,7 @@ void QgsCesiumTilesDataProviderSharedData::setTilesetContent( const QString &til } else if ( rootBoundingVolume.contains( "box" ) ) { - const QgsOrientedBoundingBox bbox = QgsCesiumUtils::parseBox( rootBoundingVolume["box"] ); + const QgsOrientedBox3D bbox = QgsCesiumUtils::parseBox( rootBoundingVolume["box"] ); if ( !bbox.isNull() ) { const QgsBox3d rootRegion = bbox.extent(); diff --git a/src/core/tiledmesh/qgscesiumutils.cpp b/src/core/tiledmesh/qgscesiumutils.cpp index 0d53d1d05e9b..c2c5b3d44aa7 100644 --- a/src/core/tiledmesh/qgscesiumutils.cpp +++ b/src/core/tiledmesh/qgscesiumutils.cpp @@ -20,7 +20,7 @@ #include "nlohmann/json.hpp" #include "qgsjsonutils.h" #include "qgssphere.h" -#include "qgsorientedboundingbox.h" +#include "qgsorientedbox3d.h" QgsBox3d QgsCesiumUtils::parseRegion( const json ®ion ) { @@ -48,14 +48,14 @@ QgsBox3d QgsCesiumUtils::parseRegion( const QVariantList ®ion ) return parseRegion( QgsJsonUtils::jsonFromVariant( region ) ); } -QgsOrientedBoundingBox QgsCesiumUtils::parseBox( const json &box ) +QgsOrientedBox3D QgsCesiumUtils::parseBox( const json &box ) { if ( box.size() != 12 ) - return QgsOrientedBoundingBox(); + return QgsOrientedBox3D(); try { - QgsOrientedBoundingBox res; + QgsOrientedBox3D res; for ( int i = 0; i < 3; ++i ) { res.mCenter[i] = box[i].get(); @@ -68,14 +68,14 @@ QgsOrientedBoundingBox QgsCesiumUtils::parseBox( const json &box ) } catch ( nlohmann::json::exception & ) { - return QgsOrientedBoundingBox(); + return QgsOrientedBox3D(); } } -QgsOrientedBoundingBox QgsCesiumUtils::parseBox( const QVariantList &box ) +QgsOrientedBox3D QgsCesiumUtils::parseBox( const QVariantList &box ) { if ( box.size() != 12 ) - return QgsOrientedBoundingBox(); + return QgsOrientedBox3D(); return parseBox( QgsJsonUtils::jsonFromVariant( box ) ); } diff --git a/src/core/tiledmesh/qgscesiumutils.h b/src/core/tiledmesh/qgscesiumutils.h index 4fd9e01555a5..67bc8ebcc405 100644 --- a/src/core/tiledmesh/qgscesiumutils.h +++ b/src/core/tiledmesh/qgscesiumutils.h @@ -29,7 +29,7 @@ using namespace nlohmann; #endif class QgsSphere; -class QgsOrientedBoundingBox; +class QgsOrientedBox3D; /** * \brief Contains utilities for working with Cesium data. @@ -64,13 +64,13 @@ class CORE_EXPORT QgsCesiumUtils * * \note Not available in Python bindings. */ - static QgsOrientedBoundingBox parseBox( const json &box ); + static QgsOrientedBox3D parseBox( const json &box ); #endif /** * Parses a \a box object from a Cesium JSON document to an oriented bounding box. */ - static QgsOrientedBoundingBox parseBox( const QVariantList &box ); + static QgsOrientedBox3D parseBox( const QVariantList &box ); #ifndef SIP_RUN diff --git a/tests/src/python/CMakeLists.txt b/tests/src/python/CMakeLists.txt index 1849f913d882..3c87ab3394ea 100644 --- a/tests/src/python/CMakeLists.txt +++ b/tests/src/python/CMakeLists.txt @@ -252,7 +252,7 @@ ADD_PYTHON_TEST(PyQgsOGRProviderGpkg test_provider_ogr_gpkg.py) ADD_PYTHON_TEST(PyQgsOGRProviderSqlite test_provider_ogr_sqlite.py) ADD_PYTHON_TEST(PyQgsOpacityWidget test_qgsopacitywidget.py) ADD_PYTHON_TEST(PyQgsOptional test_qgsoptional.py) -ADD_PYTHON_TEST(PyQgsOrientedBoundingBox test_qgsorientedboundingbox.py) +ADD_PYTHON_TEST(PyQgsOrientedBox3D test_qgsorientedbox3d.py) ADD_PYTHON_TEST(PyQgsOwsConnection test_qgsowsconnection.py) ADD_PYTHON_TEST(PyQgsPalLabelingBase test_qgspallabeling_base.py) ADD_PYTHON_TEST(PyQgsPalLabelingCanvas test_qgspallabeling_canvas.py) diff --git a/tests/src/python/test_qgsorientedboundingbox.py b/tests/src/python/test_qgsorientedbox3d.py similarity index 83% rename from tests/src/python/test_qgsorientedboundingbox.py rename to tests/src/python/test_qgsorientedbox3d.py index e87b3679c1a4..ba07159774fb 100644 --- a/tests/src/python/test_qgsorientedboundingbox.py +++ b/tests/src/python/test_qgsorientedbox3d.py @@ -1,6 +1,6 @@ -"""QGIS Unit tests for QgsOrientedBoundingBox +"""QGIS Unit tests for QgsOrientedBox3D -From build dir, run: ctest -R QgsOrientedBoundingBox -V +From build dir, run: ctest -R QgsOrientedBox3D -V .. note:: 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 @@ -14,7 +14,7 @@ import math import qgis # NOQA from qgis.core import ( - QgsOrientedBoundingBox + QgsOrientedBox3D ) import unittest from qgis.testing import start_app, QgisTestCase @@ -25,27 +25,27 @@ TEST_DATA_DIR = unitTestDataPath() -class TestQgsOrientedBoundingBox(QgisTestCase): +class TestQgsOrientedBox3D(QgisTestCase): def test_oriented_bounding_box(self): - box = QgsOrientedBoundingBox() + box = QgsOrientedBox3D() self.assertTrue(box.isNull()) # valid - box = QgsOrientedBoundingBox([1, 2, 3], [10, 0, 0, 0, 20, 0, 0, 0, 30]) + box = QgsOrientedBox3D([1, 2, 3], [10, 0, 0, 0, 20, 0, 0, 0, 30]) self.assertEqual(box.centerX(), 1) self.assertEqual(box.centerY(), 2) self.assertEqual(box.centerZ(), 3) self.assertEqual(box.halfAxes(), [10.0, 0.0, 0.0, 0.0, 20.0, 0.0, 0.0, 0.0, 30.0]) - box = QgsOrientedBoundingBox([1, 2, 3], [1, 0, 0, 0, 1, 0, 0, 0, 1]) + box = QgsOrientedBox3D([1, 2, 3], [1, 0, 0, 0, 1, 0, 0, 0, 1]) self.assertEqual(box.centerX(), 1) self.assertEqual(box.centerY(), 2) self.assertEqual(box.centerZ(), 3) self.assertEqual(box.halfAxes(), [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]) # 45 degree y axis rotation - box = QgsOrientedBoundingBox([1, 2, 3], + box = QgsOrientedBox3D([1, 2, 3], [math.cos(math.pi / 4), 0, math.sin(math.pi / 4), 0, 1, 0, -math.sin(math.pi / 4), 0, math.cos(math.pi / 4)]) @@ -55,7 +55,7 @@ def test_oriented_bounding_box(self): self.assertEqual(box.halfAxes(), [0.7071067811865476, 0.0, 0.7071067811865475, 0.0, 1.0, 0.0, -0.7071067811865475, 0.0, 0.7071067811865476]) def test_box_extent(self): - box = QgsOrientedBoundingBox([1, 2, 3], [10, 0, 0, 0, 20, 0, 0, 0, 30]) + box = QgsOrientedBox3D([1, 2, 3], [10, 0, 0, 0, 20, 0, 0, 0, 30]) bounds = box.extent() self.assertEqual(bounds.xMinimum(), -9) self.assertEqual(bounds.xMaximum(), 11) @@ -64,7 +64,7 @@ def test_box_extent(self): self.assertEqual(bounds.zMinimum(), -27) self.assertEqual(bounds.zMaximum(), 33) - box = QgsOrientedBoundingBox([1, 2, 3], [1, 0, 0, 0, 1, 0, 0, 0, 1]) + box = QgsOrientedBox3D([1, 2, 3], [1, 0, 0, 0, 1, 0, 0, 0, 1]) bounds = box.extent() self.assertEqual(bounds.xMinimum(), 0) self.assertEqual(bounds.xMaximum(), 2) @@ -74,7 +74,7 @@ def test_box_extent(self): self.assertEqual(bounds.zMaximum(), 4) # 45 degree y axis rotation - box = QgsOrientedBoundingBox([1, 2, 3], + box = QgsOrientedBox3D([1, 2, 3], [math.cos(math.pi / 4), 0, math.sin(math.pi / 4), 0, 1, 0, -math.sin(math.pi / 4), 0, math.cos(math.pi / 4)])