31 #ifndef vtkBoundingBox_h
32 #define vtkBoundingBox_h
33 #include "vtkCommonDataModelModule.h"
49 vtkBoundingBox(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
75 void SetBounds(
const double bounds[6]);
76 void SetBounds(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
87 static void ComputeBounds(
vtkPoints* pts,
double bounds[6]);
88 static void ComputeBounds(
vtkPoints* pts,
const unsigned char* ptUses,
double bounds[6]);
89 static void ComputeBounds(
90 vtkPoints* pts,
const std::atomic<unsigned char>* ptUses,
double bounds[6]);
96 this->MinPnt[0] = bds[0];
97 this->MinPnt[1] = bds[2];
98 this->MinPnt[2] = bds[4];
99 this->MaxPnt[0] = bds[1];
100 this->MaxPnt[1] = bds[3];
101 this->MaxPnt[2] = bds[5];
110 static void ComputeLocalBounds(
111 vtkPoints*
points,
double u[3],
double v[3],
double w[3],
double outputBounds[6]);
119 void SetMinPoint(
double x,
double y,
double z);
120 void SetMinPoint(
double p[3]);
128 void SetMaxPoint(
double x,
double y,
double z);
129 void SetMaxPoint(
double p[3]);
138 static int IsValid(
const double bounds[6]);
146 void AddPoint(
double p[3]);
147 void AddPoint(
double px,
double py,
double pz);
160 void AddBounds(
const double bounds[]);
184 bool IntersectPlane(
double origin[3],
double normal[3]);
190 bool IntersectsSphere(
double center[3],
double squaredRadius)
const;
196 bool IntersectsLine(
const double p1[3],
const double p2[3])
const;
201 int ComputeInnerDimension()
const;
215 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const;
221 double GetBound(
int i)
const;
228 void GetMinPoint(
double& x,
double& y,
double& z) const;
229 void GetMinPoint(
double x[3]) const;
237 void GetMaxPoint(
double& x,
double& y,
double& z) const;
238 void GetMaxPoint(
double x[3]) const;
245 void GetCorner(
int corner,
double p[3]) const;
251 vtkTypeBool ContainsPoint(const
double p[3]) const;
252 vtkTypeBool ContainsPoint(
double px,
double py,
double pz) const;
253 template <class PointT>
254 bool ContainsPoint(const PointT& p) const;
260 void GetCenter(
double center[3]) const;
265 void GetLengths(
double lengths[3]) const;
270 double GetLength(
int i) const;
275 double GetMaxLength() const;
281 double GetDiagonalLength() const;
295 void Inflate(
double delta);
296 void Inflate(
double deltaX,
double deltaY,
double deltaZ);
298 void InflateSlice(
double delta);
308 void Scale(
double s[3]);
309 void Scale(
double sx,
double sy,
double sz);
318 void ScaleAboutCenter(
double s);
319 void ScaleAboutCenter(
double s[3]);
320 void ScaleAboutCenter(
double sx,
double sy,
double sz);
339 static
void ClampDivisions(
vtkIdType targetBins,
int divs[3]);
347 double MinPnt[3], MaxPnt[3];
352 this->MinPnt[0] = this->MinPnt[1] = this->MinPnt[2] =
VTK_DOUBLE_MAX;
353 this->MaxPnt[0] = this->MaxPnt[1] = this->MaxPnt[2] =
VTK_DOUBLE_MIN;
357 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const
359 xMin = this->MinPnt[0];
360 xMax = this->MaxPnt[0];
361 yMin = this->MinPnt[1];
362 yMax = this->MaxPnt[1];
363 zMin = this->MinPnt[2];
364 zMax = this->MaxPnt[2];
372 return ((i & 0x1) ? this->MaxPnt[i >> 1] : this->MinPnt[i >> 1]);
382 x[0] = this->MinPnt[0];
383 x[1] = this->MinPnt[1];
384 x[2] = this->MinPnt[2];
394 x[0] = this->MaxPnt[0];
395 x[1] = this->MaxPnt[1];
396 x[2] = this->MaxPnt[2];
401 return ((this->MinPnt[0] <= this->MaxPnt[0]) && (this->MinPnt[1] <= this->MaxPnt[1]) &&
402 (this->MinPnt[2] <= this->MaxPnt[2]));
407 return (bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5]);
412 return this->MaxPnt[i] - this->MinPnt[i];
417 lengths[0] = this->GetLength(0);
418 lengths[1] = this->GetLength(1);
419 lengths[2] = this->GetLength(2);
424 center[0] = 0.5 * (this->MaxPnt[0] + this->MinPnt[0]);
425 center[1] = 0.5 * (this->MaxPnt[1] + this->MinPnt[1]);
426 center[2] = 0.5 * (this->MaxPnt[2] + this->MinPnt[2]);
433 return this->MaxPnt[0] < bboxMaxPnt[0] && this->MinPnt[0] > bboxMinPnt[0] &&
434 this->MaxPnt[1] < bboxMaxPnt[1] && this->MinPnt[1] > bboxMinPnt[1] &&
435 this->MaxPnt[2] < bboxMaxPnt[2] && this->MinPnt[2] > bboxMinPnt[2];
440 this->SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
445 this->
GetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
456 this->SetBounds(bounds);
460 double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax)
463 this->SetBounds(xMin, xMax, yMin, yMax, zMin, zMax);
468 this->MinPnt[0] = bbox.
MinPnt[0];
469 this->MinPnt[1] = bbox.
MinPnt[1];
470 this->MinPnt[2] = bbox.
MinPnt[2];
472 this->MaxPnt[0] = bbox.
MaxPnt[0];
473 this->MaxPnt[1] = bbox.
MaxPnt[1];
474 this->MaxPnt[2] = bbox.
MaxPnt[2];
479 this->MinPnt[0] = bbox.
MinPnt[0];
480 this->MinPnt[1] = bbox.
MinPnt[1];
481 this->MinPnt[2] = bbox.
MinPnt[2];
483 this->MaxPnt[0] = bbox.
MaxPnt[0];
484 this->MaxPnt[1] = bbox.
MaxPnt[1];
485 this->MaxPnt[2] = bbox.
MaxPnt[2];
491 return ((this->MinPnt[0] == bbox.
MinPnt[0]) && (this->MinPnt[1] == bbox.
MinPnt[1]) &&
492 (this->MinPnt[2] == bbox.
MinPnt[2]) && (this->MaxPnt[0] == bbox.
MaxPnt[0]) &&
493 (this->MaxPnt[1] == bbox.
MaxPnt[1]) && (this->MaxPnt[2] == bbox.
MaxPnt[2]));
498 return !((*this) == bbox);
503 this->SetMinPoint(p[0], p[1], p[2]);
508 this->SetMaxPoint(p[0], p[1], p[2]);
527 if ((px < this->MinPnt[0]) || (px > this->MaxPnt[0]))
531 if ((py < this->MinPnt[1]) || (py > this->MaxPnt[1]))
535 if ((pz < this->MinPnt[2]) || (pz > this->MaxPnt[2]))
544 return this->ContainsPoint(p[0], p[1], p[2]);
547 template <
class Po
intT>
550 return this->ContainsPoint(p[0], p[1], p[2]);
555 if ((corner < 0) || (corner > 7))
563 int ix = (corner & 1) ? 1 : 0;
564 int iy = ((corner >> 1) & 1) ? 1 : 0;
565 int iz = (corner >> 2) ? 1 : 0;
567 const double* pts[2] = { this->MinPnt, this->MaxPnt };
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.
bool VTKCOMMONDATAMODEL_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2)
static void ComputeBounds(vtkPoints *pts, double bounds[6])
Compute the bounding box from an array of vtkPoints.
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...
bool VTKCOMMONDATAMODEL_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2)
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.
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.