Skip to content

Commit

Permalink
Rename to QgsOrientedBox3d
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 15, 2023
1 parent f6cae1f commit 08f986b
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -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 *
************************************************************************/
Expand All @@ -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::

Expand All @@ -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<double> &center, QList< double > &halfAxes );
QgsOrientedBox3D( const QList<double> &center, 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;
Expand Down Expand Up @@ -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 *
************************************************************************/
2 changes: 1 addition & 1 deletion python/core/auto_generated/tiledmesh/qgscesiumutils.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
qgsorientedboundingbox.cpp
qgsorientedbox3d.cpp
--------------------
begin : July 2023
copyright : (C) 2023 by Nyall Dawson
Expand All @@ -16,12 +16,12 @@
* *
***************************************************************************/

#include "qgsorientedboundingbox.h"
#include "qgsorientedbox3d.h"
#include "qgsbox3d.h"

QgsOrientedBoundingBox::QgsOrientedBoundingBox() = default;
QgsOrientedBox3D::QgsOrientedBox3D() = default;

QgsOrientedBoundingBox::QgsOrientedBoundingBox( const QList<double> &center, QList<double> &halfAxes )
QgsOrientedBox3D::QgsOrientedBox3D( const QList<double> &center, QList<double> &halfAxes )
{
if ( center.size() == 3 )
{
Expand All @@ -38,12 +38,12 @@ QgsOrientedBoundingBox::QgsOrientedBoundingBox( const QList<double> &center, 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 );
Expand All @@ -54,7 +54,7 @@ QList< double > QgsOrientedBoundingBox::halfAxesList() const
return res;
}

QgsBox3d QgsOrientedBoundingBox::extent() const
QgsBox3d QgsOrientedBox3D::extent() const
{
const double extent[3]
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
qgsorientedboundingbox.h
qgsorientedbox3d.h
--------------------
begin : July 2023
copyright : (C) 2023 by Nyall Dawson
Expand All @@ -16,8 +16,8 @@
* *
***************************************************************************/

#ifndef QGSORIENTEDBOUNDINGBOX_H
#define QGSORIENTEDBOUNDINGBOX_H
#ifndef QGSORIENTEDBOX3D_H
#define QGSORIENTEDBOX3D_H

#include "qgis_core.h"
#include "qgis_sip.h"
Expand All @@ -28,30 +28,30 @@
class QgsBox3d;

/**
* \brief Represents a oriented (rotated) bounding box in 3 dimensions.
* \brief Represents a oriented (rotated) 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
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<double> &center, QList< double > &halfAxes );
QgsOrientedBox3D( const QList<double> &center, 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;

Expand Down Expand Up @@ -104,4 +104,4 @@ class CORE_EXPORT QgsOrientedBoundingBox
};


#endif // QGSORIENTEDBOUNDINGBOX_H
#endif // QGSORIENTEDBOX3D_H
4 changes: 2 additions & 2 deletions src/core/tiledmesh/qgscesiumtilesdataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "qgscesiumutils.h"
#include "qgssphere.h"
#include "qgslogger.h"
#include "qgsorientedboundingbox.h"
#include "qgsorientedbox3d.h"

#include <QUrl>
#include <QIcon>
Expand Down Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions src/core/tiledmesh/qgscesiumutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &region )
{
Expand Down Expand Up @@ -48,14 +48,14 @@ QgsBox3d QgsCesiumUtils::parseRegion( const QVariantList &region )
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<double>();
Expand All @@ -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 ) );
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/tiledmesh/qgscesiumutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace nlohmann;
#endif

class QgsSphere;
class QgsOrientedBoundingBox;
class QgsOrientedBox3D;

/**
* \brief Contains utilities for working with Cesium data.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,7 +14,7 @@
import math
import qgis # NOQA
from qgis.core import (
QgsOrientedBoundingBox
QgsOrientedBox3D
)
import unittest
from qgis.testing import start_app, QgisTestCase
Expand All @@ -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),

Check failure on line 49 in tests/src/python/test_qgsorientedbox3d.py

View workflow job for this annotation

GitHub Actions / Python Lint

tests/src/python/test_qgsorientedbox3d.py#L49

[E127] continuation line over-indented for visual indent
0, 1, 0,
-math.sin(math.pi / 4), 0, math.cos(math.pi / 4)])
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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),

Check failure on line 78 in tests/src/python/test_qgsorientedbox3d.py

View workflow job for this annotation

GitHub Actions / Python Lint

tests/src/python/test_qgsorientedbox3d.py#L78

[E127] continuation line over-indented for visual indent
0, 1, 0,
-math.sin(math.pi / 4), 0, math.cos(math.pi / 4)])
Expand Down

0 comments on commit 08f986b

Please sign in to comment.