28#ifndef vtkBoundingBox_h
29#define vtkBoundingBox_h
30#include "vtkCommonDataModelModule.h"
46 vtkBoundingBox(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
72 void SetBounds(
const double bounds[6]);
73 void SetBounds(
double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax);
87 vtkPoints* pts,
const std::atomic<unsigned char>* ptUses,
double bounds[6]);
93 this->MinPnt[0] = bds[0];
94 this->MinPnt[1] = bds[2];
95 this->MinPnt[2] = bds[4];
96 this->MaxPnt[0] = bds[1];
97 this->MaxPnt[1] = bds[3];
98 this->MaxPnt[2] = bds[5];
108 vtkPoints* points,
double u[3],
double v[3],
double w[3],
double outputBounds[6]);
117 void SetMinPoint(
double p[3]);
126 void SetMaxPoint(
double p[3]);
135 static int IsValid(
const double bounds[6]);
210 void GetBounds(
double bounds[6])
const;
212 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const;
218 double GetBound(
int i)
const;
225 void GetMinPoint(
double& x,
double& y,
double& z) const;
226 void GetMinPoint(
double x[3]) const;
234 void GetMaxPoint(
double& x,
double& y,
double& z) const;
235 void GetMaxPoint(
double x[3]) const;
242 void GetCorner(
int corner,
double p[3]) const;
248 vtkTypeBool ContainsPoint(const
double p[3]) const;
249 vtkTypeBool ContainsPoint(
double px,
double py,
double pz) const;
250 template <class PointT>
251 bool ContainsPoint(const PointT& p) const;
257 void GetCenter(
double center[3]) const;
262 void GetLengths(
double lengths[3]) const;
267 double GetLength(
int i) const;
272 double GetMaxLength() const;
278 double GetDiagonalLength() const;
292 void Inflate(
double delta);
293 void Inflate(
double deltaX,
double deltaY,
double deltaZ);
295 void InflateSlice(
double delta);
305 void Scale(
double s[3]);
306 void Scale(
double sx,
double sy,
double sz);
315 void ScaleAboutCenter(
double s);
316 void ScaleAboutCenter(
double s[3]);
317 void ScaleAboutCenter(
double sx,
double sy,
double sz);
336 static
void ClampDivisions(
vtkIdType targetBins,
int divs[3]);
344 double MinPnt[3], MaxPnt[3];
349 this->MinPnt[0] = this->MinPnt[1] = this->MinPnt[2] =
VTK_DOUBLE_MAX;
350 this->MaxPnt[0] = this->MaxPnt[1] = this->MaxPnt[2] =
VTK_DOUBLE_MIN;
354 double& xMin,
double& xMax,
double& yMin,
double& yMax,
double& zMin,
double& zMax)
const
356 xMin = this->MinPnt[0];
357 xMax = this->MaxPnt[0];
358 yMin = this->MinPnt[1];
359 yMax = this->MaxPnt[1];
360 zMin = this->MinPnt[2];
361 zMax = this->MaxPnt[2];
369 return ((i & 0x1) ? this->MaxPnt[i >> 1] : this->MinPnt[i >> 1]);
379 x[0] = this->MinPnt[0];
380 x[1] = this->MinPnt[1];
381 x[2] = this->MinPnt[2];
391 x[0] = this->MaxPnt[0];
392 x[1] = this->MaxPnt[1];
393 x[2] = this->MaxPnt[2];
398 return ((this->MinPnt[0] <= this->MaxPnt[0]) && (this->MinPnt[1] <= this->MaxPnt[1]) &&
399 (this->MinPnt[2] <= this->MaxPnt[2]));
404 return (bounds[0] <= bounds[1] && bounds[2] <= bounds[3] && bounds[4] <= bounds[5]);
409 return this->MaxPnt[i] - this->MinPnt[i];
414 lengths[0] = this->GetLength(0);
415 lengths[1] = this->GetLength(1);
416 lengths[2] = this->GetLength(2);
421 center[0] = 0.5 * (this->MaxPnt[0] + this->MinPnt[0]);
422 center[1] = 0.5 * (this->MaxPnt[1] + this->MinPnt[1]);
423 center[2] = 0.5 * (this->MaxPnt[2] + this->MinPnt[2]);
430 return this->MaxPnt[0] < bboxMaxPnt[0] && this->MinPnt[0] > bboxMinPnt[0] &&
431 this->MaxPnt[1] < bboxMaxPnt[1] && this->MinPnt[1] > bboxMinPnt[1] &&
432 this->MaxPnt[2] < bboxMaxPnt[2] && this->MinPnt[2] > bboxMinPnt[2];
437 this->SetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
442 this->GetBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
453 this->SetBounds(bounds);
457 double xMin,
double xMax,
double yMin,
double yMax,
double zMin,
double zMax)
460 this->SetBounds(xMin, xMax, yMin, yMax, zMin, zMax);
465 this->MinPnt[0] = bbox.
MinPnt[0];
466 this->MinPnt[1] = bbox.
MinPnt[1];
467 this->MinPnt[2] = bbox.
MinPnt[2];
469 this->MaxPnt[0] = bbox.
MaxPnt[0];
470 this->MaxPnt[1] = bbox.
MaxPnt[1];
471 this->MaxPnt[2] = bbox.
MaxPnt[2];
476 this->MinPnt[0] = bbox.
MinPnt[0];
477 this->MinPnt[1] = bbox.
MinPnt[1];
478 this->MinPnt[2] = bbox.
MinPnt[2];
480 this->MaxPnt[0] = bbox.
MaxPnt[0];
481 this->MaxPnt[1] = bbox.
MaxPnt[1];
482 this->MaxPnt[2] = bbox.
MaxPnt[2];
488 return ((this->MinPnt[0] == bbox.
MinPnt[0]) && (this->MinPnt[1] == bbox.
MinPnt[1]) &&
489 (this->MinPnt[2] == bbox.
MinPnt[2]) && (this->MaxPnt[0] == bbox.
MaxPnt[0]) &&
490 (this->MaxPnt[1] == bbox.
MaxPnt[1]) && (this->MaxPnt[2] == bbox.
MaxPnt[2]));
495 return !((*this) == bbox);
500 this->SetMinPoint(p[0], p[1], p[2]);
505 this->SetMaxPoint(p[0], p[1], p[2]);
524 if ((px < this->MinPnt[0]) || (px > this->MaxPnt[0]))
528 if ((py < this->MinPnt[1]) || (py > this->MaxPnt[1]))
532 if ((pz < this->MinPnt[2]) || (pz > this->MaxPnt[2]))
541 return this->ContainsPoint(p[0], p[1], p[2]);
544template <
class Po
intT>
547 return this->ContainsPoint(p[0], p[1], p[2]);
552 if ((corner < 0) || (corner > 7))
560 int ix = (corner & 1) ? 1 : 0;
561 int iy = ((corner >> 1) & 1) ? 1 : 0;
562 int iz = (corner >> 2) ? 1 : 0;
564 const double* pts[2] = { this->MinPnt, this->MaxPnt };
Fast, simple class for representing and operating on 3D bounds.
int IntersectBox(const vtkBoundingBox &bbox)
Intersect this box with bbox.
const double * GetMinPoint() const
Get the minimum point of the bounding box.
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.
void AddBounds(const double bounds[])
Adjust the bounding box so it contains the specified bounds (defined by the VTK representation (xmin,...
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.
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.
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.
bool IntersectsSphere(double center[3], double squaredRadius) const
Intersect this box with a sphere.
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 ...
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.
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.
vtkBoundingBox()
Construct a bounding box with the min point set to VTK_DOUBLE_MAX and the max point set to VTK_DOUBLE...
void GetLengths(double lengths[3]) const
Get the length of each side of the box.
void ComputeBounds(vtkPoints *pts, unsigned char *ptUses)
Compute the bounding box from an array of vtkPoints.
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 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...
vtkBoundingBox & operator=(const vtkBoundingBox &bbox)
Assignment Operator.
represent and manipulate 3D points
bool VTKCOMMONDATAMODEL_EXPORT operator==(vtkEdgeBase e1, vtkEdgeBase e2)
bool VTKCOMMONDATAMODEL_EXPORT operator!=(vtkEdgeBase e1, vtkEdgeBase e2)
#define VTK_SIZEHINT(...)