19 #ifndef vtkBoundingBox_h
20 #define vtkBoundingBox_h
21 #include "vtkCommonDataModelModule.h"
25 VTK_ABI_NAMESPACE_BEGIN
38 vtkBoundingBox(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
64 void SetBounds(
const double bounds[6]);
65 void SetBounds(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
76 static void ComputeBounds(
vtkPoints* pts,
double bounds[6]);
77 static void ComputeBounds(
vtkPoints* pts,
const unsigned char* ptUses,
double bounds[6]);
78 static void ComputeBounds(
79 vtkPoints* pts,
const std::atomic<unsigned char>* ptUses,
double bounds[6]);
80 static void ComputeBounds(
81 vtkPoints* pts,
const long long* ptIds,
long long numPointIds,
double bounds[6]);
82 static void ComputeBounds(
vtkPoints* pts,
const long* ptIds,
long numPointIds,
double bounds[6]);
83 static void ComputeBounds(
vtkPoints* pts,
const int* ptIds,
int numPointIds,
double bounds[6]);
88 this->MinPnt[0] = bds[0];
89 this->MinPnt[1] = bds[2];
90 this->MinPnt[2] = bds[4];
91 this->MaxPnt[0] = bds[1];
92 this->MaxPnt[1] = bds[3];
93 this->MaxPnt[2] = bds[5];
99 this->MinPnt[0] = bds[0];
100 this->MinPnt[1] = bds[2];
101 this->MinPnt[2] = bds[4];
102 this->MaxPnt[0] = bds[1];
103 this->MaxPnt[1] = bds[3];
104 this->MaxPnt[2] = bds[5];
113 static void ComputeLocalBounds(
114 vtkPoints*
points,
double u[3],
double v[3],
double w[3],
double outputBounds[6]);
122 void SetMinPoint(
double x,
double y,
double z);
123 void SetMinPoint(
double p[3]);
131 void SetMaxPoint(
double x,
double y,
double z);
132 void SetMaxPoint(
double p[3]);
141 static int IsValid(
const double bounds[6]);
149 void AddPoint(
double p[3]);
150 void AddPoint(
double px,
double py,
double pz);
163 void AddBounds(
const double bounds[6]);
187 bool IntersectPlane(
double origin[3],
double normal[3]);
193 bool IntersectsSphere(
double center[3],
double squaredRadius)
const;
199 bool IntersectsLine(
const double p1[3],
const double p2[3])
const;
204 int ComputeInnerDimension()
const;
228 static bool ContainsLine(
const double x[3],
const double s[3],
const double lineEnd[3],
double& t,
229 double xInt[3],
int& plane);
237 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const;
243 double GetBound(
int i)
const;
250 void GetMinPoint(
double& x,
double& y,
double& z) const;
251 void GetMinPoint(
double x[3]) const;
259 void GetMaxPoint(
double& x,
double& y,
double& z) const;
260 void GetMaxPoint(
double x[3]) const;
267 void GetCorner(
int corner,
double p[3]) const;
273 vtkTypeBool ContainsPoint(const
double p[3]) const;
274 vtkTypeBool ContainsPoint(
double px,
double py,
double pz) const;
275 template <class PointT>
276 bool ContainsPoint(const PointT& p) const;
282 void GetCenter(
double center[3]) const;
287 void GetLengths(
double lengths[3]) const;
292 double GetLength(
int i) const;
297 double GetMaxLength() const;
304 double GetDiagonalLength2() const;
305 double GetDiagonalLength() const;
320 void Inflate(
double delta);
321 void Inflate(
double deltaX,
double deltaY,
double deltaZ);
323 void InflateSlice(
double delta);
333 void Scale(
double s[3]);
334 void Scale(
double sx,
double sy,
double sz);
343 void ScaleAboutCenter(
double s);
344 void ScaleAboutCenter(
double s[3]);
345 void ScaleAboutCenter(
double sx,
double sy,
double sz);
364 static
void ClampDivisions(
vtkIdType targetBins,
int divs[3]);
372 double MinPnt[3], MaxPnt[3];
377 this->MinPnt[0] = this->MinPnt[1] = this->MinPnt[2] =
VTK_DOUBLE_MAX;
378 this->MaxPnt[0] = this->MaxPnt[1] = this->MaxPnt[2] =
VTK_DOUBLE_MIN;
382 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const
384 xMin = this->MinPnt[0];
385 xMax = this->MaxPnt[0];
386 yMin = this->MinPnt[1];
387 yMax = this->MaxPnt[1];
388 zMin = this->MinPnt[2];
389 zMax = this->MaxPnt[2];
397 return ((i & 0x1) ? this->MaxPnt[i >> 1] : this->MinPnt[i >> 1]);
407 x[0] = this->MinPnt[0];
408 x[1] = this->MinPnt[1];
409 x[2] = this->MinPnt[2];
419 x[0] = this->MaxPnt[0];
420 x[1] = this->MaxPnt[1];
421 x[2] = this->MaxPnt[2];
426 return ((this->MinPnt[0] <= this->MaxPnt[0]) && (this->MinPnt[1] <= this->MaxPnt[1]) &&
427 (this->MinPnt[2] <= this->MaxPnt[2]));
432 return (bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5]);
437 return this->MaxPnt[i] - this->MinPnt[i];
442 lengths[0] = this->GetLength(0);
443 lengths[1] = this->GetLength(1);
444 lengths[2] = this->GetLength(2);
449 center[0] = 0.5 * (this->MaxPnt[0] + this->MinPnt[0]);
450 center[1] = 0.5 * (this->MaxPnt[1] + this->MinPnt[1]);
451 center[2] = 0.5 * (this->MaxPnt[2] + this->MinPnt[2]);
458 return this->MaxPnt[0] < bboxMaxPnt[0] && this->MinPnt[0] > bboxMinPnt[0] &&
459 this->MaxPnt[1] < bboxMaxPnt[1] && this->MinPnt[1] > bboxMinPnt[1] &&
460 this->MaxPnt[2] < bboxMaxPnt[2] && this->MinPnt[2] > bboxMinPnt[2];
465 this->SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
470 this->
GetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
481 this->SetBounds(bounds);
485 double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax)
488 this->SetBounds(xMin, xMax, yMin, yMax, zMin, zMax);
493 this->MinPnt[0] = bbox.
MinPnt[0];
494 this->MinPnt[1] = bbox.
MinPnt[1];
495 this->MinPnt[2] = bbox.
MinPnt[2];
497 this->MaxPnt[0] = bbox.
MaxPnt[0];
498 this->MaxPnt[1] = bbox.
MaxPnt[1];
499 this->MaxPnt[2] = bbox.
MaxPnt[2];
504 this->MinPnt[0] = bbox.
MinPnt[0];
505 this->MinPnt[1] = bbox.
MinPnt[1];
506 this->MinPnt[2] = bbox.
MinPnt[2];
508 this->MaxPnt[0] = bbox.
MaxPnt[0];
509 this->MaxPnt[1] = bbox.
MaxPnt[1];
510 this->MaxPnt[2] = bbox.
MaxPnt[2];
516 return ((this->MinPnt[0] == bbox.
MinPnt[0]) && (this->MinPnt[1] == bbox.
MinPnt[1]) &&
517 (this->MinPnt[2] == bbox.
MinPnt[2]) && (this->MaxPnt[0] == bbox.
MaxPnt[0]) &&
518 (this->MaxPnt[1] == bbox.
MaxPnt[1]) && (this->MaxPnt[2] == bbox.
MaxPnt[2]));
523 return !((*this) == bbox);
528 this->SetMinPoint(p[0], p[1], p[2]);
533 this->SetMaxPoint(p[0], p[1], p[2]);
552 if ((px < this->MinPnt[0]) || (px > this->MaxPnt[0]))
556 if ((py < this->MinPnt[1]) || (py > this->MaxPnt[1]))
560 if ((pz < this->MinPnt[2]) || (pz > this->MaxPnt[2]))
569 return this->ContainsPoint(p[0], p[1], p[2]);
572 template <
class Po
intT>
575 return this->ContainsPoint(p[0], p[1], p[2]);
580 if ((corner < 0) || (corner > 7))
588 int ix = (corner & 1) ? 1 : 0;
589 int iy = ((corner >> 1) & 1) ? 1 : 0;
590 int iz = (corner >> 2) ? 1 : 0;
592 const double* pts[2] = { this->MinPnt, this->MaxPnt };
598 VTK_ABI_NAMESPACE_END
void GetBounds(double bounds[6]) const
Get the bounds of the box (defined by VTK style).
void GetBounds(T a, double bds[6])
const double * GetMinPoint() const
Get the minimum point of the bounding box.
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 ComputeBounds(vtkPoints *pts)
Compute the bounding box from an array of vtkPoints.
bool operator!=(const vtkBoundingBox &bbox) const
Equality operator.
static void ComputeBounds(vtkPoints *pts, double bounds[6])
Compute the bounding box from an array of vtkPoints.
bool VTKCOMMONCORE_EXPORT operator==(const std::string &a, const vtkStringToken &b)
void GetCorner(int corner, double p[3]) const
Get the ith corner of the bounding box.
bool operator==(const vtkBoundingBox &bbox) const
Equality operator.
void GetCenter(double center[3]) const
Get the center of the bounding 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...
double GetBound(int i) const
Return the ith bounds of the box (defined by VTK style).
void GetLengths(double lengths[3]) const
Get the length of each side of the box.
vtkBoundingBox & operator=(const vtkBoundingBox &bbox)
Assignment Operator.
bool VTKCOMMONCORE_EXPORT operator!=(const std::string &a, const vtkStringToken &b)
vtkTypeBool ContainsPoint(const double p[3]) const
Returns 1 if the point is contained in the box else 0.
#define VTK_SIZEHINT(...)
bool IsSubsetOf(const vtkBoundingBox &bbox) const
Returns true if this instance is entirely contained by bbox.
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...
double GetLength(int i) const
Return the length of the bounding box in the ith direction.
void SetBounds(const double bounds[6])
Set the bounds explicitly of the box (using the VTK convention for representing a bounding box)...
vtkBoundingBox()
Construct a bounding box with the min point set to VTK_DOUBLE_MAX and the max point set to VTK_DOUBLE...
void ComputeBounds(vtkPoints *pts, unsigned char *ptUses)
Compute the bounding box from an array of vtkPoints.
const double * GetMaxPoint() const
Get the maximum point of the bounding box.
represent and manipulate 3D points
Fast, simple class for representing and operating on 3D bounds.