19#include "moc_qgsbox3d.cpp" 
   24QgsBox3D::QgsBox3D( 
double xmin, 
double ymin, 
double zmin, 
double xmax, 
double ymax, 
double zmax, 
bool normalize )
 
   25  : mBounds2d( xmin, ymin, xmax, ymax, false )
 
 
   36  : mBounds2d( p1.x(), p1.y(), p2.x(), p2.y(), false )
 
 
   58  : mBounds2d( corner1.x(), corner1.y(), corner2.x(), corner2.y(), false )
 
   59  , mZmin( corner1.z() )
 
   60  , mZmax( corner2.z() )
 
 
  105  mZmin = std::numeric_limits<double>::max();
 
  106  mZmax = -std::numeric_limits<double>::max();
 
 
  114    std::swap( mZmin, mZmax );
 
 
  122                      0.5 * ( mZmin + mZmax ) );
 
 
  128  const double zMin = std::max( mZmin, other.mZmin );
 
  129  const double zMax = std::min( mZmax, other.mZmax );
 
 
  136  return qgsDoubleNear( mZmin, mZmax ) || ( mZmin > mZmax ) || std::isnan( mZmin ) || std::isnan( mZmax ) ;
 
 
  146  if ( !mBounds2d.
intersects( other.mBounds2d ) )
 
  155    const double z1 = ( mZmin > other.mZmin ? mZmin : other.mZmin );
 
  156    const double z2 = ( mZmax < other.mZmax ? mZmax : other.mZmax );
 
 
  163  if ( !mBounds2d.
contains( other.mBounds2d ) )
 
  172    return ( other.mZmin >= mZmin && other.mZmax <= mZmax );
 
 
  195  if ( std::isnan( z ) || 
is2d() )
 
  201    return mZmin <= z && z <= mZmax;
 
 
  233    *
this = 
QgsBox3D( x, y, z, x, y, z );
 
  243    mZmin = ( mZmin < z ) ? mZmin : z;
 
  244    mZmax = ( mZmax > z ) ? mZmax : z;
 
 
  250  const double dx = std::max( mBounds2d.
xMinimum() - point.
x(), std::max( 0., point.
x() - mBounds2d.
xMaximum() ) );
 
  251  const double dy = std::max( mBounds2d.
yMinimum() - point.
y(), std::max( 0., point.
y() - mBounds2d.
yMaximum() ) );
 
  252  if ( 
is2d() || std::isnan( point.
z() ) )
 
  254    return std::hypot( dx, dy );
 
  258    const double dz = std::max( mZmin - point.
z(), std::max( 0., point.
z() - mZmax ) );
 
  259    return std::hypot( dx, dy, dz );
 
 
  265  return mBounds2d == other.mBounds2d &&
 
 
  273  double centerX, centerY, centerZ;
 
  286  scale( scaleFactor, centerX, centerY, centerZ );
 
 
  289void QgsBox3D::scale( 
double scaleFactor, 
double centerX, 
double centerY, 
double centerZ )
 
 
  305  mBounds2d.
grow( delta );
 
 
  312  return ( std::isnan( mBounds2d.
xMinimum() ) && std::isnan( mBounds2d.
xMaximum() )
 
  314           && std::isnan( mZmin ) && std::isnan( mZmax ) )
 
  316         ( mBounds2d.
xMinimum() == std::numeric_limits<double>::max() && mBounds2d.
yMinimum() == std::numeric_limits<double>::max() && mZmin == std::numeric_limits<double>::max()
 
  317           && mBounds2d.
xMaximum() == -std::numeric_limits<double>::max() && mBounds2d.
yMaximum() == -std::numeric_limits<double>::max() && mZmax == -std::numeric_limits<double>::max() );
 
 
  334      precision = 
static_cast<int>( std::ceil( -1.0 * std::log10( std::min( 
width(), 
height() ) ) ) ) + 1;
 
  342    rep = QStringLiteral( 
"Null" );
 
  344    rep = QStringLiteral( 
"Empty" );
 
  346    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.
 
Q_DECL_DEPRECATED 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...
 
QVector< QgsVector3D > corners() const
Returns an array of all box corners as 3D vectors.
 
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.
 
void grow(double delta)
Grows the box in place by the specified amount in all dimensions.
 
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.
 
void setYMinimum(double y)
Set the minimum y value.
 
bool intersects(const QgsRectangle &rect) const
Returns true when rectangle intersects with other rectangle.
 
void setXMinimum(double x)
Set the minimum x value.
 
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 grow(double delta)
Grows the rectangle in place by the specified amount.
 
void normalize()
Normalize the rectangle so it has non-negative width/height.
 
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.
 
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
 
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)