Go to the documentation of this file.
30 #ifndef vtkBoundingBox_h
31 #define vtkBoundingBox_h
32 #include "vtkCommonDataModelModule.h"
46 double yMin,
double yMax,
47 double zMin,
double zMax);
73 void SetBounds(
const double bounds[6]);
75 double yMin,
double yMax,
76 double zMin,
double zMax);
85 void SetMinPoint(
double p[3]);
94 void SetMaxPoint(
double p[3]);
103 static int IsValid(
const double bounds[6]);
156 void GetBounds(
double bounds[6])
const;
157 void GetBounds(
double &xMin,
double &xMax,
158 double &yMin,
double &yMax,
159 double &zMin,
double &zMax)
const;
165 double GetBound(
int i)
const;
172 void GetMinPoint(
double &x,
double &y,
double &z) const;
173 void GetMinPoint(
double x[3]);
181 void GetMaxPoint(
double &x,
double &y,
double &z) const;
182 void GetMaxPoint(
double x[3]);
189 void GetCorner(
int corner,
double p[3]) const;
196 vtkTypeBool ContainsPoint(
double px,
double py,
double pz) const;
202 void GetCenter(
double center[3]) const;
207 void GetLengths(
double lengths[3]) const;
212 double GetLength(
int i) const;
217 double GetMaxLength() const;
223 double GetDiagonalLength() const;
234 void Inflate(
double delta);
235 void Inflate(
double deltaX,
double deltaY,
double deltaZ);
246 void Scale(
double s[3]);
247 void Scale(
double sx,
double sy,
double sz);
256 void ScaleAboutCenter(
double s);
257 void ScaleAboutCenter(
double s[3]);
258 void ScaleAboutCenter(
double sx,
double sy,
double sz);
279 double MinPnt[3], MaxPnt[3];
284 this->MinPnt[0] = this->MinPnt[1] = this->MinPnt[2] =
VTK_DOUBLE_MAX;
285 this->MaxPnt[0] = this->MaxPnt[1] = this->MaxPnt[2] =
VTK_DOUBLE_MIN;
289 double &yMin,
double &yMax,
290 double &zMin,
double &zMax)
const
292 xMin = this->MinPnt[0];
293 xMax = this->MaxPnt[0];
294 yMin = this->MinPnt[1];
295 yMax = this->MaxPnt[1];
296 zMin = this->MinPnt[2];
297 zMax = this->MaxPnt[2];
305 return ((i & 0x1) ? this->MaxPnt[i>>1] : this->MinPnt[i>>1]);
315 x[0] = this->MinPnt[0];
316 x[1] = this->MinPnt[1];
317 x[2] = this->MinPnt[2];
327 x[0] = this->MaxPnt[0];
328 x[1] = this->MaxPnt[1];
329 x[2] = this->MaxPnt[2];
334 return ((this->MinPnt[0] <= this->MaxPnt[0]) &&
335 (this->MinPnt[1] <= this->MaxPnt[1]) &&
336 (this->MinPnt[2] <= this->MaxPnt[2]));
341 return (bounds[0] <= bounds[1] &&
342 bounds[2] <= bounds[3] &&
343 bounds[4] <= bounds[5]);
348 return this->MaxPnt[i] - this->MinPnt[i];
353 lengths[0] = this->GetLength(0);
354 lengths[1] = this->GetLength(1);
355 lengths[2] = this->GetLength(2);
360 center[0] = 0.5 * (this->MaxPnt[0] + this->MinPnt[0]);
361 center[1] = 0.5 * (this->MaxPnt[1] + this->MinPnt[1]);
362 center[2] = 0.5 * (this->MaxPnt[2] + this->MinPnt[2]);
367 this->SetBounds(bounds[0], bounds[1], bounds[2],
368 bounds[3], bounds[4], bounds[5]);
373 this->GetBounds(bounds[0], bounds[1], bounds[2],
374 bounds[3], bounds[4], bounds[5]);
385 this->SetBounds(bounds);
389 double yMin,
double yMax,
390 double zMin,
double zMax)
393 this->SetBounds(xMin, xMax, yMin, yMax, zMin, zMax);
398 this->MinPnt[0] = bbox.
MinPnt[0];
399 this->MinPnt[1] = bbox.
MinPnt[1];
400 this->MinPnt[2] = bbox.
MinPnt[2];
402 this->MaxPnt[0] = bbox.
MaxPnt[0];
403 this->MaxPnt[1] = bbox.
MaxPnt[1];
404 this->MaxPnt[2] = bbox.
MaxPnt[2];
409 this->MinPnt[0] = bbox.
MinPnt[0];
410 this->MinPnt[1] = bbox.
MinPnt[1];
411 this->MinPnt[2] = bbox.
MinPnt[2];
413 this->MaxPnt[0] = bbox.
MaxPnt[0];
414 this->MaxPnt[1] = bbox.
MaxPnt[1];
415 this->MaxPnt[2] = bbox.
MaxPnt[2];
421 return ((this->MinPnt[0] == bbox.
MinPnt[0]) &&
422 (this->MinPnt[1] == bbox.
MinPnt[1]) &&
423 (this->MinPnt[2] == bbox.
MinPnt[2]) &&
424 (this->MaxPnt[0] == bbox.
MaxPnt[0]) &&
425 (this->MaxPnt[1] == bbox.
MaxPnt[1]) &&
426 (this->MaxPnt[2] == bbox.
MaxPnt[2]));
431 return !((*this) == bbox);
436 this->SetMinPoint(p[0], p[1], p[2]);
441 this->SetMaxPoint(p[0], p[1], p[2]);
461 if ((px < this->MinPnt[0]) || (px > this->MaxPnt[0]))
465 if ((py < this->MinPnt[1]) || (py > this->MaxPnt[1]))
469 if ((pz < this->MinPnt[2]) || (pz > this->MaxPnt[2]))
478 return this->ContainsPoint(p[0], p[1], p[2]);
483 if ((corner < 0) || (corner > 7))
491 int ix = (corner & 1) ? 1 : 0;
492 int iy = ((corner >> 1) & 1) ? 1 : 0;
493 int iz = (corner >> 2) ? 1 : 0;
495 const double* pts[2] = { this->MinPnt, this->MaxPnt };
vtkBoundingBox & operator=(const vtkBoundingBox &bbox)
Assignment Operator.
const double * GetMaxPoint() const
Get the maximum point of the bounding box.
int IntersectBox(const vtkBoundingBox &bbox)
Intersect this box with bbox.
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...
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...
void GetLengths(double lengths[3]) const
Get the length of each sode of the box.
vtkTypeBool ContainsPoint(double p[3]) const
Returns 1 if the point is contained in the box else 0.
Fast Simple Class for dealing with 3D bounds.
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 SetBounds(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
#define VTK_SIZEHINT(...)
void AddBounds(const double bounds[])
Adjust the bounding box so it contains the specified bounds (defined by the VTK representation (xmin,...
void SetBounds(const double bounds[6])
Set the bounds explicitly of the box (using the VTK convention for representing a bounding box).
void GetBounds(double bounds[6]) const
Get the bounds of the box (defined by VTK style).
bool operator!=(const vtkBoundingBox &bbox) const
const double * GetMinPoint() const
Get the minimum point 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 Contains(const vtkBoundingBox &bbox) const
Returns 1 if the min and max points of bbox are contained within the bounds of the specified box,...
double GetLength(int i) const
Return the length of the bounding box in the ith direction.
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
void AddPoint(double p[3])
Change bounding box so it includes the point p.
void AddPoint(double px, double py, double pz)
vtkBoundingBox()
Construct a bounding box with the min point set to VTK_DOUBLE_MAX and the max point set to VTK_DOUBLE...
void GetCorner(int corner, double p[3]) const
Get the ith corner of the bounding box.
int Intersects(const vtkBoundingBox &bbox) const
Returns 1 if the boxes intersect else returns 0.
bool IntersectPlane(double origin[3], double normal[3])
Intersect this box with the half space defined by plane.
VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
double GetBound(int i) const
Return the ith bounds of the box (defined by VTK style).
void AddBox(const vtkBoundingBox &bbox)
Change the bounding box to be the union of itself and the specified bbox.