QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsBox3D Class Reference

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

#include <qgsbox3d.h>

Public Member Functions

 QgsBox3D (const QgsPoint &p1, const QgsPoint &p2, bool normalize=true)
 Constructs a QgsBox3D from two points representing opposite corners of the box.
 
 QgsBox3D (const QgsRectangle &rect, double zMin=std::numeric_limits< double >::quiet_NaN(), double zMax=std::numeric_limits< double >::quiet_NaN(), bool normalize=true)
 Constructs a QgsBox3D from a rectangle.
 
 QgsBox3D (const QgsVector3D &corner1, const QgsVector3D &corner2, bool normalize=true)
 Constructs a QgsBox3D from two 3D vectors representing opposite corners of the box.
 
 QgsBox3D (double xmin=std::numeric_limits< double >::quiet_NaN(), double ymin=std::numeric_limits< double >::quiet_NaN(), double zmin=std::numeric_limits< double >::quiet_NaN(), double xmax=std::numeric_limits< double >::quiet_NaN(), double ymax=std::numeric_limits< double >::quiet_NaN(), double zmax=std::numeric_limits< double >::quiet_NaN(), bool normalize=true)
 Constructor for QgsBox3D which accepts the ranges of x/y/z coordinates.
 
double area () const
 Returns the area of the box.
 
QgsVector3D center () const
 Returns the center of the box as a vector.
 
void combineWith (const QgsBox3D &box)
 Expands the bbox so that it covers both the original rectangle and the given rectangle.
 
void combineWith (double x, double y, double z)
 Expands the bbox so that it covers both the original rectangle and the given point.
 
bool contains (const QgsBox3D &other) const
 Returns true when box contains other box.
 
bool contains (const QgsPoint &point) const
 Returns true when box contains a point.
 
bool contains (double x, double y, double z) const
 Returns true when box contains a point (x, y, z).
 
QVector< QgsVector3Dcorners () const
 Returns an array of all box corners as 3D vectors.
 
double depth () const
 Returns the depth of the box.
 
double distanceTo (const QVector3D &point) const
 Returns the smallest distance between the box and the point point (returns 0 if the point is inside the box)
 
void grow (double delta)
 Grows the box in place by the specified amount in all dimensions.
 
double height () const
 Returns the height of the box.
 
QgsBox3D intersect (const QgsBox3D &other) const
 Returns the intersection of this box and another 3D box.
 
bool intersects (const QgsBox3D &other) const
 Returns true if box intersects with another box.
 
bool is2d () const
 Returns true if the box can be considered a 2-dimensional box, i.e.
 
bool is3D () const
 Returns true if the box can be considered a 3-dimensional box, i.e.
 
bool isEmpty () const
 Returns true if the box is empty.
 
bool isNull () const
 Test if the box is null (holding no spatial information).
 
void normalize ()
 Normalize the box so it has non-negative width/height/depth.
 
QgsBox3D operator+ (const QgsVector3D &v) const
 Returns a box offset from this one in the direction of the vector.
 
QgsBox3Doperator+= (const QgsVector3D &v)
 Moves this box in the direction of the vector.
 
QgsBox3D operator- (const QgsVector3D &v) const
 Returns a box offset from this one in the direction of the reversed vector.
 
QgsBox3Doperator-= (const QgsVector3D &v)
 Moves this box in the direction of the reversed vector.
 
bool operator== (const QgsBox3D &other) const
 
void scale (double scaleFactor, const QgsPoint &center=QgsPoint())
 Scale the rectangle around a center QgsPoint.
 
void scale (double scaleFactor, double centerX, double centerY, double centerZ)
 Scale the rectangle around a center coordinates.
 
void set (double xMin, double yMin, double zMin, double xMax, double yMax, double zMax, bool normalize=true)
 Sets the box from a set of (x,y,z) minimum and maximum coordinates.
 
void setNull ()
 Mark a box as being null (holding no spatial information).
 
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.
 
QgsRectangle toRectangle () const
 Converts the box to a 2D rectangle.
 
QString toString (int precision=16) const
 Returns a string representation of form xmin,ymin,zmin : xmax,ymax,zmax Coordinates will be truncated to the specified precision.
 
double volume () const
 Returns the volume of the box.
 
double width () const
 Returns the width of the box.
 
double xMaximum () const
 Returns the maximum x value.
 
double xMinimum () const
 Returns the minimum x value.
 
double yMaximum () const
 Returns the maximum y value.
 
double yMinimum () const
 Returns the minimum y value.
 
double zMaximum () const
 Returns the maximum z value.
 
double zMinimum () const
 Returns the minimum z value.
 

Detailed Description

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.

Note
In QGIS 3.34 this class was renamed from QgsBox3d to QgsBox3D. The old QgsBox3d name remains available in PyQGIS for compatibility.
See also
QgsRectangle

Definition at line 42 of file qgsbox3d.h.

Constructor & Destructor Documentation

◆ QgsBox3D() [1/4]

QgsBox3D::QgsBox3D ( double  xmin = std::numeric_limits<double>::quiet_NaN(),
double  ymin = std::numeric_limits<double>::quiet_NaN(),
double  zmin = std::numeric_limits<double>::quiet_NaN(),
double  xmax = std::numeric_limits<double>::quiet_NaN(),
double  ymax = std::numeric_limits<double>::quiet_NaN(),
double  zmax = std::numeric_limits<double>::quiet_NaN(),
bool  normalize = true 
)

Constructor for QgsBox3D which accepts the ranges of x/y/z coordinates.

If normalize is false then the normalization step will not be applied automatically.

Definition at line 24 of file qgsbox3d.cpp.

◆ QgsBox3D() [2/4]

QgsBox3D::QgsBox3D ( const QgsPoint p1,
const QgsPoint p2,
bool  normalize = true 
)

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

The box is normalized after construction. If normalize is false then the normalization step will not be applied automatically.

Definition at line 35 of file qgsbox3d.cpp.

◆ QgsBox3D() [3/4]

QgsBox3D::QgsBox3D ( const QgsVector3D corner1,
const QgsVector3D corner2,
bool  normalize = true 
)

Constructs a QgsBox3D from two 3D vectors representing opposite corners of the box.

The box is normalized after construction. If normalize is false then the normalization step will not be applied automatically.

Since
QGIS 3.42

Definition at line 57 of file qgsbox3d.cpp.

◆ QgsBox3D() [4/4]

QgsBox3D::QgsBox3D ( const QgsRectangle rect,
double  zMin = std::numeric_limits<double>::quiet_NaN(),
double  zMax = std::numeric_limits<double>::quiet_NaN(),
bool  normalize = true 
)

Constructs a QgsBox3D from a rectangle.

If normalize is false then the normalization step will not be applied automatically.

Definition at line 46 of file qgsbox3d.cpp.

Member Function Documentation

◆ area()

double QgsBox3D::area ( ) const
inline

Returns the area of the box.

Since
QGIS 3.40

Definition at line 321 of file qgsbox3d.h.

◆ center()

QgsVector3D QgsBox3D::center ( ) const

Returns the center of the box as a vector.

Since
QGIS 3.34

Definition at line 118 of file qgsbox3d.cpp.

◆ combineWith() [1/2]

void QgsBox3D::combineWith ( const QgsBox3D box)

Expands the bbox so that it covers both the original rectangle and the given rectangle.

Since
QGIS 3.34

Definition at line 208 of file qgsbox3d.cpp.

◆ combineWith() [2/2]

void QgsBox3D::combineWith ( double  x,
double  y,
double  z 
)

Expands the bbox so that it covers both the original rectangle and the given point.

Since
QGIS 3.34

Definition at line 230 of file qgsbox3d.cpp.

◆ contains() [1/3]

bool QgsBox3D::contains ( const QgsBox3D other) const

Returns true when box contains other box.

Definition at line 161 of file qgsbox3d.cpp.

◆ contains() [2/3]

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.

Definition at line 176 of file qgsbox3d.cpp.

◆ contains() [3/3]

bool QgsBox3D::contains ( double  x,
double  y,
double  z 
) const

Returns true when box contains a point (x, y, z).

A point on the border of the box will also return true

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.

Since
QGIS 3.34

Definition at line 188 of file qgsbox3d.cpp.

◆ corners()

QVector< QgsVector3D > QgsBox3D::corners ( ) const

Returns an array of all box corners as 3D vectors.

Definition at line 359 of file qgsbox3d.cpp.

◆ depth()

double QgsBox3D::depth ( ) const
inline

Returns the depth of the box.

See also
width()
height()

Definition at line 307 of file qgsbox3d.h.

◆ distanceTo()

double QgsBox3D::distanceTo ( const QVector3D &  point) const

Returns the smallest distance between the box and the point point (returns 0 if the point is inside the box)

Since
QGIS 3.18

Definition at line 248 of file qgsbox3d.cpp.

◆ grow()

void QgsBox3D::grow ( double  delta)

Grows the box in place by the specified amount in all dimensions.

Since
QGIS 3.42

Definition at line 301 of file qgsbox3d.cpp.

◆ height()

double QgsBox3D::height ( ) const
inline

Returns the height of the box.

See also
width()
depth()

Definition at line 300 of file qgsbox3d.h.

◆ intersect()

QgsBox3D QgsBox3D::intersect ( const QgsBox3D other) const

Returns the intersection of this box and another 3D box.

Definition at line 125 of file qgsbox3d.cpp.

◆ intersects()

bool QgsBox3D::intersects ( const QgsBox3D other) const

Returns true if box intersects with another box.

Definition at line 144 of file qgsbox3d.cpp.

◆ is2d()

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.

Definition at line 134 of file qgsbox3d.cpp.

◆ is3D()

bool QgsBox3D::is3D ( ) const

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

it has valid minimum and maximum z values. If the box is not normalized, this returns false.

Since
QGIS 3.34

Definition at line 139 of file qgsbox3d.cpp.

◆ isEmpty()

bool QgsBox3D::isEmpty ( ) const

Returns true if the box is empty.

An empty box may still be non-null if it contains valid spatial information (e.g. bounding box of a point or of a vertical or horizontal segment).

Since
QGIS 3.34

Definition at line 320 of file qgsbox3d.cpp.

◆ isNull()

bool QgsBox3D::isNull ( ) const

Test if the box is null (holding no spatial information).

A null box is also an empty box.

See also
setNull()
Since
QGIS 3.34

Definition at line 310 of file qgsbox3d.cpp.

◆ normalize()

void QgsBox3D::normalize ( )

Normalize the box so it has non-negative width/height/depth.

Definition at line 109 of file qgsbox3d.cpp.

◆ operator+()

QgsBox3D QgsBox3D::operator+ ( const QgsVector3D v) const

Returns a box offset from this one in the direction of the vector.

Since
QGIS 3.34

Definition at line 381 of file qgsbox3d.cpp.

◆ operator+=()

QgsBox3D & QgsBox3D::operator+= ( const QgsVector3D v)

Moves this box in the direction of the vector.

Since
QGIS 3.34

Definition at line 396 of file qgsbox3d.cpp.

◆ operator-()

QgsBox3D QgsBox3D::operator- ( const QgsVector3D v) const

Returns a box offset from this one in the direction of the reversed vector.

Since
QGIS 3.34

Definition at line 375 of file qgsbox3d.cpp.

◆ operator-=()

QgsBox3D & QgsBox3D::operator-= ( const QgsVector3D v)

Moves this box in the direction of the reversed vector.

Since
QGIS 3.34

Definition at line 387 of file qgsbox3d.cpp.

◆ operator==()

bool QgsBox3D::operator== ( const QgsBox3D other) const

Definition at line 263 of file qgsbox3d.cpp.

◆ scale() [1/2]

void QgsBox3D::scale ( double  scaleFactor,
const QgsPoint center = QgsPoint() 
)

Scale the rectangle around a center QgsPoint.

If no center point is specified then the current center of the box will be used.

Since
QGIS 3.26

Definition at line 270 of file qgsbox3d.cpp.

◆ scale() [2/2]

void QgsBox3D::scale ( double  scaleFactor,
double  centerX,
double  centerY,
double  centerZ 
)

Scale the rectangle around a center coordinates.

Since
QGIS 3.26

Definition at line 289 of file qgsbox3d.cpp.

◆ set()

void QgsBox3D::set ( double  xMin,
double  yMin,
double  zMin,
double  xMax,
double  yMax,
double  zMax,
bool  normalize = true 
)
inline

Sets the box from a set of (x,y,z) minimum and maximum coordinates.

Since
QGIS 3.40

Definition at line 181 of file qgsbox3d.h.

◆ setNull()

void QgsBox3D::setNull ( )

Mark a box as being null (holding no spatial information).

Set a rectangle so that min corner is at max and max corner is at min.

Since
QGIS 3.34

It is NOT normalized.

Definition at line 102 of file qgsbox3d.cpp.

◆ setXMaximum()

void QgsBox3D::setXMaximum ( double  x)

Sets the maximum x value.

See also
xMaximum()
setXMinimum()

Definition at line 73 of file qgsbox3d.cpp.

◆ setXMinimum()

void QgsBox3D::setXMinimum ( double  x)

Sets the minimum x value.

See also
xMinimum()
setXMaximum()

Definition at line 68 of file qgsbox3d.cpp.

◆ setYMaximum()

void QgsBox3D::setYMaximum ( double  y)

Sets the maximum y value.

See also
yMaximum()
setYMinimum()

Definition at line 83 of file qgsbox3d.cpp.

◆ setYMinimum()

void QgsBox3D::setYMinimum ( double  y)

Sets the minimum y value.

See also
yMinimum()
setYMaximum()

Definition at line 78 of file qgsbox3d.cpp.

◆ setZMaximum()

void QgsBox3D::setZMaximum ( double  z)

Sets the maximum z value.

See also
zMaximum()
setZMinimum()

Definition at line 93 of file qgsbox3d.cpp.

◆ setZMinimum()

void QgsBox3D::setZMinimum ( double  z)

Sets the minimum z value.

See also
zMinimum()
setZMaximum()

Definition at line 88 of file qgsbox3d.cpp.

◆ toRectangle()

QgsRectangle QgsBox3D::toRectangle ( ) const
inline

Converts the box to a 2D rectangle.

Definition at line 394 of file qgsbox3d.h.

◆ toString()

QString QgsBox3D::toString ( int  precision = 16) const

Returns a string representation of form xmin,ymin,zmin : xmax,ymax,zmax Coordinates will be truncated to the specified precision.

If the specified precision is less than 0, a suitable minimum precision is used.

Since
QGIS 3.34

Definition at line 325 of file qgsbox3d.cpp.

◆ volume()

double QgsBox3D::volume ( ) const
inline

Returns the volume of the box.

Definition at line 326 of file qgsbox3d.h.

◆ width()

double QgsBox3D::width ( ) const
inline

Returns the width of the box.

See also
height()
depth()

Definition at line 293 of file qgsbox3d.h.

◆ xMaximum()

double QgsBox3D::xMaximum ( ) const
inline

Returns the maximum x value.

See also
setXMaximum()
xMinimum()

Definition at line 218 of file qgsbox3d.h.

◆ xMinimum()

double QgsBox3D::xMinimum ( ) const
inline

Returns the minimum x value.

See also
setXMinimum()
xMaximum()

Definition at line 211 of file qgsbox3d.h.

◆ yMaximum()

double QgsBox3D::yMaximum ( ) const
inline

Returns the maximum y value.

See also
setYMaximum()
yMinimum()

Definition at line 246 of file qgsbox3d.h.

◆ yMinimum()

double QgsBox3D::yMinimum ( ) const
inline

Returns the minimum y value.

See also
setYMinimum()
yMaximum()

Definition at line 239 of file qgsbox3d.h.

◆ zMaximum()

double QgsBox3D::zMaximum ( ) const
inline

Returns the maximum z value.

See also
setZMaximum()
zMinimum()

Definition at line 274 of file qgsbox3d.h.

◆ zMinimum()

double QgsBox3D::zMinimum ( ) const
inline

Returns the minimum z value.

See also
setZMinimum()
zMaximum()

Definition at line 267 of file qgsbox3d.h.


The documentation for this class was generated from the following files: