19#ifndef vtkBoundingBox_h
20#define vtkBoundingBox_h
21#include "vtkCommonDataModelModule.h"
27VTK_ABI_NAMESPACE_BEGIN
46 vtkBoundingBox(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
81 void SetBounds(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
95 vtkPoints* pts,
const std::atomic<unsigned char>* ptUses,
double bounds[6]);
96 template <
typename TIter>
128 vtkPoints* points,
double u[3],
double v[3],
double w[3],
double outputBounds[6]);
155 static int IsValid(
const double bounds[6]);
209 const double min[3],
const double max[3],
const double center[3],
double r2)
212 for (
int i = 0; i < 3; ++i)
214 if (center[i] < min[i])
216 d2 += (center[i] - min[i]) * (center[i] - min[i]);
218 else if (center[i] >
max[i])
220 d2 += (center[i] -
max[i]) * (center[i] -
max[i]);
247 const double min[3],
const double max[3],
const double center[3],
double r2)
249 double dmin = 0.0, dmax = 0.0;
250 for (
int i = 0; i < 3; ++i)
252 double a = (center[i] - min[i]) * (center[i] - min[i]);
253 double b = (center[i] -
max[i]) * (center[i] -
max[i]);
254 dmax += std::max(a, b);
255 if (min[i] <= center[i] && center[i] <=
max[i])
257 dmin += std::min(a, b);
260 return (!(dmin <=
r2 &&
r2 <= dmax));
305 static bool ContainsLine(
const double x[3],
const double s[3],
const double lineEnd[3],
double& t,
306 double xInt[3],
int& plane);
314 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const;
327 void GetMinPoint(
double& x,
double& y,
double& z) const;
336 void GetMaxPoint(
double& x,
double& y,
double& z) const;
344 void GetCorner(
int corner,
double p[3]) const;
352 template <class PointT>
398 void Inflate(
double deltaX,
double deltaY,
double deltaZ);
411 void Scale(
double sx,
double sy,
double sz);
474 this->MinPnt[0] = this->MinPnt[1] = this->MinPnt[2] =
VTK_DOUBLE_MAX;
475 this->MaxPnt[0] = this->MaxPnt[1] = this->MaxPnt[2] =
VTK_DOUBLE_MIN;
479 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const
494 return ((i & 0x1) ? this->
MaxPnt[i >> 1] : this->
MinPnt[i >> 1]);
529 return (bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5]);
555 return this->
MaxPnt[0] < bboxMaxPnt[0] && this->
MinPnt[0] > bboxMinPnt[0] &&
556 this->
MaxPnt[1] < bboxMaxPnt[1] && this->
MinPnt[1] > bboxMinPnt[1] &&
557 this->
MaxPnt[2] < bboxMaxPnt[2] && this->
MinPnt[2] > bboxMinPnt[2];
562 this->
SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
567 this->
GetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
582 double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax)
585 this->
SetBounds(xMin, xMax, yMin, yMax, zMin, zMax);
632 (this->MinPnt[2] == bbox.
MinPnt[2]) && (this->MaxPnt[0] == bbox.
MaxPnt[0]) &&
633 (this->MaxPnt[1] == bbox.
MaxPnt[1]) && (this->MaxPnt[2] == bbox.
MaxPnt[2]));
638 return !((*this) == bbox);
687template <
class Po
intT>
695 if ((corner < 0) || (corner > 7))
703 int ix = (corner & 1) ? 1 : 0;
704 int iy = ((corner >> 1) & 1) ? 1 : 0;
705 int iz = (corner >> 2) ? 1 : 0;
void ScaleAboutCenter(double s)
Scale each dimension of the box by some given factor, with the origin of the bounding box the center ...
static bool ContainsLine(const double x[3], const double s[3], const double lineEnd[3], double &t, double xInt[3], int &plane)
A specialized, performant method to compute the containment of a finite line emanating from the cente...
double GetDiagonalLength2() const
Return the length of the diagonal.
void Scale(double s[3])
Scale each dimension of the box by some given factor.
void ClampPoint(double point[3])
Clamp point so it is contained inside box.
void AddBounds(const double bounds[6])
Adjust the bounding box so it contains the specified bounds (defined by the VTK representation (xmin,...
vtkIdType ComputeDivisions(vtkIdType totalBins, double bounds[6], int divs[3]) const
Compute the number of divisions in the x-y-z directions given a psoitive, target number of total bins...
static void ComputeBounds(vtkPoints *pts, TIter ptIds, vtkIdType numPointIds, double bounds[6])
Compute the bounding box from an array of vtkPoints.
int IntersectBox(const vtkBoundingBox &bbox)
Intersect this box with bbox.
const double * GetMinPoint() const
Get the minimum point of the bounding box.
double GetDiagonalLength() const
Return the length of the diagonal.
bool InsideSphere(double center[3], double radius2) const
Determine if this bounding box is completely contained by a sphere.
void SetBounds(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
Set the bounds explicitly of the box (using the VTK convention for representing a bounding box).
void AddBox(const vtkBoundingBox &bbox)
Change the bounding box to be the union of itself and the specified bbox.
int Contains(const vtkBoundingBox &bbox) const
Returns 1 if the min and max points of bbox are contained within the bounds of the specified box,...
int IsValid() const
Returns 1 if the bounds have been set and 0 if the box is in its initialized state which is an invert...
int Intersects(const vtkBoundingBox &bbox) const
Returns 1 if the boxes intersect else returns 0.
double GetMaxLength() const
Return the maximum length of the box.
bool operator!=(const vtkBoundingBox &bbox) const
Equality operator.
void AddPoint(double px, double py, double pz)
Change bounding box so it includes the point p.
void GetDistance(double point[3], double distance[3])
For each axis, get the minimum distance to put the point inside the box.
int ComputeInnerDimension() const
Returns the inner dimension of the bounding box.
void GetCorner(int corner, double p[3]) const
Get the ith corner of the bounding box.
void ComputeBounds(vtkPoints *pts)
Compute the bounding box from an array of vtkPoints.
bool IsSubsetOf(const vtkBoundingBox &bbox) const
Returns true if this instance is entirely contained by bbox.
static void ComputeBounds(vtkPoints *pts, double bounds[6])
Compute the bounding box from an array of vtkPoints.
void SetMaxPoint(double x, double y, double z)
Set the maximum point of the bounding box - if the max point is less than the min point then the min ...
void Reset()
Returns the box to its initialized state.
bool IntersectPlane(double origin[3], double normal[3])
Intersect this box with the half space defined by plane.
bool IntersectsLine(const double p1[3], const double p2[3]) const
Returns true if any part of segment [p1,p2] lies inside the bounding box, as well as on its boundarie...
static void ComputeLocalBounds(vtkPoints *points, double u[3], double v[3], double w[3], double outputBounds[6])
Compute local bounds.
void GetCenter(double center[3]) const
Get the center of the bounding box.
void AddPoint(double p[3])
Change bounding box so it includes the point p.
bool IntersectsSphere2(double center[3], double radius2) const
Intersect this box with a sphere.
double GetLength(int i) const
Return the length of the bounding box in the ith direction.
bool operator==(const vtkBoundingBox &bbox) const
Equality operator.
vtkTypeBool ContainsPoint(const double p[3]) const
Returns 1 if the point is contained in the box else 0.
static void ClampDivisions(vtkIdType targetBins, int divs[3])
Clamp the number of divisions to be less than or equal to a target number of bins,...
vtkBoundingBox()
Construct a bounding box with the min point set to VTK_DOUBLE_MAX and the max point set to VTK_DOUBLE...
bool IntersectsSphere(double center[3], double radius) const
Intersect this box with a sphere.
void GetLengths(double lengths[3]) const
Get the length of each side of the box.
static bool IntersectsSphere(const double min[3], const double max[3], const double center[3], double r2)
Performant method to intersect box with a sphere.
void Inflate(double delta)
Expand the bounding box.
void ComputeBounds(vtkPoints *pts, unsigned char *ptUses)
Compute the bounding box from an array of vtkPoints.
void InflateSlice(double delta)
Expand the bounding box.
static void ComputeBounds(vtkPoints *pts, const unsigned char *ptUses, double bounds[6])
Compute the bounding box from an array of vtkPoints.
void SetBounds(const double bounds[6])
Set the bounds explicitly of the box (using the VTK convention for representing a bounding box).
const double * GetMaxPoint() const
Get the maximum point of the bounding box.
double GetBound(int i) const
Return the ith bounds of the box (defined by VTK style).
static void ComputeBounds(vtkPoints *pts, const std::atomic< unsigned char > *ptUses, double bounds[6])
Compute the bounding box from an array of vtkPoints.
void GetBounds(double bounds[6]) const
Get the bounds of the box (defined by VTK style).
void Translate(double motion[3])
Translate box from motion.
void SetMinPoint(double x, double y, double z)
Set the minimum point of the bounding box - if the min point is greater than the max point then the m...
static bool InsideSphere(const double min[3], const double max[3], const double center[3], double r2)
Performant method to determine if box if fully inside a sphere.
vtkBoundingBox & operator=(const vtkBoundingBox &bbox)
Assignment Operator.
represent and manipulate 3D points
void Reset()
Initializes the field list to empty.
virtual double * GetBounds()
Compute the bounding box of the current cell in `bounds' in global coordinates.
bool VTKCOMMONCORE_EXPORT operator==(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator!=(const std::string &a, const vtkStringToken &b)
virtual void SetBounds(double, double, double, double, double, double)
int Inflate(double dist) override
Inflates voxel by moving every faces by dist.
#define VTK_SIZEHINT(...)