QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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 (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.
 
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)
 
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 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
Since
QGIS 3.0

Definition at line 43 of file qgsbox3d.h.

Constructor & Destructor Documentation

◆ QgsBox3D() [1/3]

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 23 of file qgsbox3d.cpp.

◆ QgsBox3D() [2/3]

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 34 of file qgsbox3d.cpp.

◆ QgsBox3D() [3/3]

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 45 of file qgsbox3d.cpp.

Member Function Documentation

◆ center()

QgsVector3D QgsBox3D::center ( ) const

Returns the center of the box as a vector.

Since
QGIS 3.34

Definition at line 106 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 196 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 218 of file qgsbox3d.cpp.

◆ contains() [1/3]

bool QgsBox3D::contains ( const QgsBox3D other) const

Returns true when box contains other box.

Definition at line 149 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 164 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 176 of file qgsbox3d.cpp.

◆ corners()

QVector< QgsVector3D > QgsBox3D::corners ( ) const

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

Definition at line 338 of file qgsbox3d.cpp.

◆ depth()

double QgsBox3D::depth ( ) const
inline

Returns the depth of the box.

See also
width()
height()

Definition at line 259 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 236 of file qgsbox3d.cpp.

◆ height()

double QgsBox3D::height ( ) const
inline

Returns the height of the box.

See also
width()
depth()

Definition at line 252 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 113 of file qgsbox3d.cpp.

◆ intersects()

bool QgsBox3D::intersects ( const QgsBox3D other) const

Returns true if box intersects with another box.

Definition at line 132 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 122 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 127 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 299 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 289 of file qgsbox3d.cpp.

◆ normalize()

void QgsBox3D::normalize ( )

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

Definition at line 97 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 360 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 375 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 354 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 366 of file qgsbox3d.cpp.

◆ operator==()

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

Definition at line 251 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 258 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 277 of file qgsbox3d.cpp.

◆ 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 90 of file qgsbox3d.cpp.

◆ setXMaximum()

void QgsBox3D::setXMaximum ( double  x)

Sets the maximum x value.

See also
xMaximum()
setXMinimum()

Definition at line 61 of file qgsbox3d.cpp.

◆ setXMinimum()

void QgsBox3D::setXMinimum ( double  x)

Sets the minimum x value.

See also
xMinimum()
setXMaximum()

Definition at line 56 of file qgsbox3d.cpp.

◆ setYMaximum()

void QgsBox3D::setYMaximum ( double  y)

Sets the maximum y value.

See also
yMaximum()
setYMinimum()

Definition at line 71 of file qgsbox3d.cpp.

◆ setYMinimum()

void QgsBox3D::setYMinimum ( double  y)

Sets the minimum y value.

See also
yMinimum()
setYMaximum()

Definition at line 66 of file qgsbox3d.cpp.

◆ setZMaximum()

void QgsBox3D::setZMaximum ( double  z)

Sets the maximum z value.

See also
zMaximum()
setZMinimum()

Definition at line 81 of file qgsbox3d.cpp.

◆ setZMinimum()

void QgsBox3D::setZMinimum ( double  z)

Sets the minimum z value.

See also
zMinimum()
setZMaximum()

Definition at line 76 of file qgsbox3d.cpp.

◆ toRectangle()

QgsRectangle QgsBox3D::toRectangle ( ) const
inline

Converts the box to a 2D rectangle.

Definition at line 339 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 304 of file qgsbox3d.cpp.

◆ volume()

double QgsBox3D::volume ( ) const
inline

Returns the volume of the box.

Definition at line 271 of file qgsbox3d.h.

◆ width()

double QgsBox3D::width ( ) const
inline

Returns the width of the box.

See also
height()
depth()

Definition at line 245 of file qgsbox3d.h.

◆ xMaximum()

double QgsBox3D::xMaximum ( ) const
inline

Returns the maximum x value.

See also
setXMaximum()
xMinimum()

Definition at line 170 of file qgsbox3d.h.

◆ xMinimum()

double QgsBox3D::xMinimum ( ) const
inline

Returns the minimum x value.

See also
setXMinimum()
xMaximum()

Definition at line 163 of file qgsbox3d.h.

◆ yMaximum()

double QgsBox3D::yMaximum ( ) const
inline

Returns the maximum y value.

See also
setYMaximum()
yMinimum()

Definition at line 198 of file qgsbox3d.h.

◆ yMinimum()

double QgsBox3D::yMinimum ( ) const
inline

Returns the minimum y value.

See also
setYMinimum()
yMaximum()

Definition at line 191 of file qgsbox3d.h.

◆ zMaximum()

double QgsBox3D::zMaximum ( ) const
inline

Returns the maximum z value.

See also
setZMaximum()
zMinimum()

Definition at line 226 of file qgsbox3d.h.

◆ zMinimum()

double QgsBox3D::zMinimum ( ) const
inline

Returns the minimum z value.

See also
setZMinimum()
zMaximum()

Definition at line 219 of file qgsbox3d.h.


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