QgsBox3d class

A 3-dimensional box composed of x, y, z coordinates.

A box composed of x/y/z minimum and maximum values. It is often used to return the 3D extent of a geometry or collection of geometries.

Constructors, destructors, conversion operators

QgsBox3d(double xmin = 0, double ymin = 0, double zmin = 0, double xmax = 0, double ymax = 0, double zmax = 0)
Constructor for QgsBox3D which accepts the ranges of x/y/z coordinates.
QgsBox3d(const QgsPoint& p1, const QgsPoint& p2)
Constructs a QgsBox3D from two points representing opposite corners of the box.
QgsBox3d(const QgsRectangle& rect)
Constructs a QgsBox3D from a rectangle.

Public functions

auto contains(const QgsBox3d& other) const -> bool
Returns true when box contains other box.
auto contains(const QgsPoint& point) const -> bool
Returns true when box contains a point.
auto depth() const -> double
Returns the depth of the box.
auto height() const -> double
Returns the height of the box.
auto intersect(const QgsBox3d& other) const -> QgsBox3d
Returns the intersection of this box and another 3D box.
auto intersects(const QgsBox3d& other) const -> bool
Returns true if box intersects with another box.
auto is2d() const -> bool
Returns true if the box can be considered a 2-dimensional box, i.e.
void normalize()
Normalize the box so it has non-negative width/height/depth.
void setXMaximum(double x)
Sets the maximum x value.
void setXMinimum(double x)
Sets the minimum x value.
void setYMaximum(double y)
Sets the maximum y value.
void setYMinimum(double y)
Sets the minimum y value.
void setZMaximum(double z)
Sets the maximum z value.
void setZMinimum(double z)
Sets the minimum z value.
auto toRectangle() const -> QgsRectangle
Converts the box to a 2D rectangle.
auto volume() const -> double
Returns the volume of the box.
auto width() const -> double
Returns the width of the box.
auto xMaximum() const -> double
Returns the maximum x value.
auto xMinimum() const -> double
Returns the minimum x value.
auto yMaximum() const -> double
Returns the maximum y value.
auto yMinimum() const -> double
Returns the minimum y value.
auto zMaximum() const -> double
Returns the maximum z value.
auto zMinimum() const -> double
Returns the minimum z value.

Function documentation

QgsBox3d::QgsBox3d(const QgsPoint& p1, const QgsPoint& p2)

Constructs a QgsBox3D from two points representing opposite corners of the box.

The box is normalized after construction.

QgsBox3d::QgsBox3d(const QgsRectangle& rect)

Constructs a QgsBox3D from a rectangle.

Z Minimum and Z Maximum are set to 0.0.

bool QgsBox3d::contains(const QgsPoint& point) const

Returns true when box contains a point.

If the point is a 2D point (no z-coordinate), then the containment test will be performed on the x/y extent of the box only.

double QgsBox3d::depth() const

Returns the depth of the box.

double QgsBox3d::height() const

Returns the height of the box.

bool QgsBox3d::is2d() const

Returns true if the box can be considered a 2-dimensional box, i.e.

it has equal minimum and maximum z values.

void QgsBox3d::setXMaximum(double x)

Sets the maximum x value.

void QgsBox3d::setXMinimum(double x)

Sets the minimum x value.

void QgsBox3d::setYMaximum(double y)

Sets the maximum y value.

void QgsBox3d::setYMinimum(double y)

Sets the minimum y value.

void QgsBox3d::setZMaximum(double z)

Sets the maximum z value.

void QgsBox3d::setZMinimum(double z)

Sets the minimum z value.

double QgsBox3d::width() const

Returns the width of the box.

double QgsBox3d::xMaximum() const

Returns the maximum x value.

double QgsBox3d::xMinimum() const

Returns the minimum x value.

double QgsBox3d::yMaximum() const

Returns the maximum y value.

double QgsBox3d::yMinimum() const

Returns the minimum y value.

double QgsBox3d::zMaximum() const

Returns the maximum z value.

double QgsBox3d::zMinimum() const

Returns the minimum z value.