Skip to content

Commit

Permalink
qgsbox3d: Add support for area method
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjano committed Jul 11, 2024
1 parent 47f7b3a commit 40c8a1c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/PyQt6/core/auto_generated/geometry/qgsbox3d.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ Returns the depth of the box.
Returns the center of the box as a vector.

.. versionadded:: 3.34
%End

double area() const /HoldGIL/;
%Docstring
Returns the area of the box.

.. versionadded:: 3.40
%End

double volume() const /HoldGIL/;
Expand Down
7 changes: 7 additions & 0 deletions python/core/auto_generated/geometry/qgsbox3d.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ Returns the depth of the box.
Returns the center of the box as a vector.

.. versionadded:: 3.34
%End

double area() const /HoldGIL/;
%Docstring
Returns the area of the box.

.. versionadded:: 3.40
%End

double volume() const /HoldGIL/;
Expand Down
7 changes: 7 additions & 0 deletions src/core/geometry/qgsbox3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ class CORE_EXPORT QgsBox3D
*/
QgsVector3D center() const SIP_HOLDGIL;

/**
* Returns the area of the box.
*
* \since QGIS 3.40
*/
double area() const SIP_HOLDGIL { return mBounds2d.area(); }

/**
* Returns the volume of the box.
*/
Expand Down
4 changes: 4 additions & 0 deletions tests/src/python/test_qgsbox3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ def testCombineWith(self):
self.assertEqual(box15.yMaximum(), 6)
self.assertEqual(box15.zMaximum(), 23)

def test_area(self):
box = QgsBox3d(5.0, 6.0, 7.0, 11.0, 13.0, 15.0)
self.assertEqual(box.area(), 42.0)

def testVolume(self):
box = QgsBox3d(5.0, 6.0, 7.0, 11.0, 13.0, 15.0)
self.assertEqual(box.volume(), 336.0)
Expand Down

0 comments on commit 40c8a1c

Please sign in to comment.