23QgsBox3D::QgsBox3D(
double xmin,
double ymin,
double zmin,
double xmax,
double ymax,
double zmax,
bool normalize )
24 : mBounds2d( xmin, ymin, xmax, ymax, false )
35 : mBounds2d( p1.x(), p1.y(), p2.x(), p2.y(), false )
93 mZmin = std::numeric_limits<double>::max();
94 mZmax = -std::numeric_limits<double>::max();
102 std::swap( mZmin, mZmax );
110 0.5 * ( mZmin + mZmax ) );
116 const double zMin = std::max( mZmin, other.mZmin );
117 const double zMax = std::min( mZmax, other.mZmax );
124 return qgsDoubleNear( mZmin, mZmax ) || ( mZmin > mZmax ) || std::isnan( mZmin ) || std::isnan( mZmax ) ;
134 if ( !mBounds2d.
intersects( other.mBounds2d ) )
143 const double z1 = ( mZmin > other.mZmin ? mZmin : other.mZmin );
144 const double z2 = ( mZmax < other.mZmax ? mZmax : other.mZmax );
151 if ( !mBounds2d.
contains( other.mBounds2d ) )
160 return ( other.mZmin >= mZmin && other.mZmax <= mZmax );
183 if ( std::isnan( z ) ||
is2d() )
189 return mZmin <= z && z <= mZmax;
221 *
this =
QgsBox3D( x, y, z, x, y, z );
231 mZmin = ( mZmin < z ) ? mZmin : z;
232 mZmax = ( mZmax > z ) ? mZmax : z;
238 const double dx = std::max( mBounds2d.
xMinimum() - point.x(), std::max( 0., point.x() - mBounds2d.
xMaximum() ) );
239 const double dy = std::max( mBounds2d.
yMinimum() - point.y(), std::max( 0., point.y() - mBounds2d.
yMaximum() ) );
240 if (
is2d() || std::isnan( point.z() ) )
242 return std::hypot( dx, dy );
246 const double dz = std::max( mZmin - point.z(), std::max( 0., point.z() - mZmax ) );
247 return std::hypot( dx, dy, dz );
253 return mBounds2d == other.mBounds2d &&
261 double centerX, centerY, centerZ;
274 scale( scaleFactor, centerX, centerY, centerZ );
277void QgsBox3D::scale(
double scaleFactor,
double centerX,
double centerY,
double centerZ )
291 return ( std::isnan( mBounds2d.
xMinimum() ) && std::isnan( mBounds2d.
xMaximum() )
293 && std::isnan( mZmin ) && std::isnan( mZmax ) )
295 ( mBounds2d.
xMinimum() == std::numeric_limits<double>::max() && mBounds2d.
yMinimum() == std::numeric_limits<double>::max() && mZmin == std::numeric_limits<double>::max()
296 && mBounds2d.
xMaximum() == -std::numeric_limits<double>::max() && mBounds2d.
yMaximum() == -std::numeric_limits<double>::max() && mZmax == -std::numeric_limits<double>::max() );
313 precision =
static_cast<int>( std::ceil( -1.0 * std::log10( std::min(
width(),
height() ) ) ) ) + 1;
321 rep = QStringLiteral(
"Null" );
323 rep = QStringLiteral(
"Empty" );
325 rep = QStringLiteral(
"%1,%2,%3 : %4,%5,%6" )
A 3-dimensional box composed of x, y, z coordinates.
double yMaximum() const
Returns the maximum y value.
QgsBox3D operator-(const QgsVector3D &v) const
Returns a box offset from this one in the direction of the reversed vector.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin,zmin : xmax,ymax,zmax Coordinates will be truncated...
void scale(double scaleFactor, const QgsPoint ¢er=QgsPoint())
Scale the rectangle around a center QgsPoint.
void setZMinimum(double z)
Sets the minimum z value.
void setYMaximum(double y)
Sets the maximum y value.
bool is3D() const
Returns true if the box can be considered a 3-dimensional box, i.e.
void setZMaximum(double z)
Sets the maximum z value.
bool intersects(const QgsBox3D &other) const
Returns true if box intersects with another box.
double xMinimum() const
Returns the minimum x value.
bool contains(const QgsBox3D &other) const
Returns true when box contains other box.
double zMaximum() const
Returns the maximum z value.
QgsVector3D center() const
Returns the center of the box as a vector.
double xMaximum() const
Returns the maximum x value.
void normalize()
Normalize the box so it has non-negative width/height/depth.
void setXMaximum(double x)
Sets the maximum x value.
void combineWith(const QgsBox3D &box)
Expands the bbox so that it covers both the original rectangle and the given rectangle.
bool is2d() const
Returns true if the box can be considered a 2-dimensional box, i.e.
QVector< QgsVector3D > corners() const
Returns an array of all box corners as 3D vectors.
double distanceTo(const QVector3D &point) const
Returns the smallest distance between the box and the point point (returns 0 if the point is inside t...
QgsBox3D operator+(const QgsVector3D &v) const
Returns a box offset from this one in the direction of the vector.
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 width() const
Returns the width of the box.
QgsBox3D & operator+=(const QgsVector3D &v)
Moves this box in the direction of the vector.
QgsBox3D intersect(const QgsBox3D &other) const
Returns the intersection of this box and another 3D box.
void setNull()
Mark a box as being null (holding no spatial information).
void setYMinimum(double y)
Sets the minimum y value.
double zMinimum() const
Returns the minimum z value.
double yMinimum() const
Returns the minimum y value.
double height() const
Returns the height of the box.
QgsBox3D & operator-=(const QgsVector3D &v)
Moves this box in the direction of the reversed vector.
void setXMinimum(double x)
Sets the minimum x value.
bool isNull() const
Test if the box is null (holding no spatial information).
bool operator==(const QgsBox3D &other) const
bool isEmpty() const
Returns true if the box is empty.
Point geometry type, with support for z-dimension and m-values.
A rectangle specified with double values.
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setYMinimum(double y)
Set the minimum y value.
bool intersects(const QgsRectangle &rect) const
Returns true when rectangle intersects with other rectangle.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
void setXMinimum(double x)
Set the minimum x value.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
void setYMaximum(double y)
Set the maximum y value.
void setXMaximum(double x)
Set the maximum x value.
void normalize()
Normalize the rectangle so it has non-negative width/height.
bool isEmpty() const
Returns true if the rectangle has no area.
void setNull()
Mark a rectangle as being null (holding no spatial information).
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define QgsDebugMsgLevel(str, level)