/usr/include/vtk-7.1/vtkBoundingBox.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkBoundingBox.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkBoundingBox
* @brief Fast Simple Class for dealing with 3D bounds
*
* vtkBoundingBox maintains a 3D axis aligned bounding box. It is very
* lite weight and many of the member functions are in-lined so its very fast
* It is not derived from vtkObject so it can be allocated on the stack
*
* @sa
* vtkBox
*/
#ifndef vtkBoundingBox_h
#define vtkBoundingBox_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkSystemIncludes.h"
class VTKCOMMONDATAMODEL_EXPORT vtkBoundingBox
{
public:
//@{
/**
* Construct a bounding box with the min point set to
* VTK_DOUBLE_MAX and the max point set to VTK_DOUBLE_MIN
*/
vtkBoundingBox();
vtkBoundingBox(const double bounds[6]);
vtkBoundingBox(double xMin, double xMax,
double yMin, double yMax,
double zMin, double zMax);
//@}
/**
* Copy Constructor
*/
vtkBoundingBox(const vtkBoundingBox &bbox);
/**
* Assignment Operator
*/
vtkBoundingBox &operator=(const vtkBoundingBox &bbox);
//@{
/**
* Equality Operator
*/
bool operator==(const vtkBoundingBox &bbox)const;
bool operator!=(const vtkBoundingBox &bbox)const;
//@}
//@{
/**
* Set the bounds explicitly of the box (vtk Style)
* Returns 1 if the box was changed else 0
*/
void SetBounds(const double bounds[6]);
void SetBounds(double xMin, double xMax,
double yMin, double yMax,
double zMin, double zMax);
//@}
//@{
/**
* Set the minimum point of the bounding box - if the min point
* is greater than the max point then the max point will also be changed
*/
void SetMinPoint(double x, double y, double z);
void SetMinPoint(double p[3]);
//@}
//@{
/**
* Set the maximum point of the bounding box - if the max point
* is less than the min point then the min point will also be changed
*/
void SetMaxPoint(double x, double y, double z);
void SetMaxPoint(double p[3]);
//@}
//@{
/**
* Change bounding box so it includes the point p
* Note that the bounding box may have 0 volume if its bounds
* were just initialized.
*/
void AddPoint(double p[3]);
void AddPoint(double px, double py, double pz);
//@}
/**
* Change the bouding box to be the union of itself and bbox
*/
void AddBox(const vtkBoundingBox &bbox);
/**
* Change the bounding box so it includes bounds (defined by vtk standard)
*/
void AddBounds(const double bounds[]);
// Desciption:
// Intersect this box with bbox. The method returns 1 if
// both boxes are valid and they do have overlap else it will return 0.
// If 0 is returned the box has not been modified
int IntersectBox(const vtkBoundingBox &bbox);
/**
* Returns 1 if the boxes intersect else returns 0
*/
int Intersects(const vtkBoundingBox &bbox) const;
// Desciption:
// Intersect this box with the half space defined by plane.
//Returns true if there is intersection---which implies that the box has been modified
// Returns false otherwise
bool IntersectPlane(double origin[3],double normal[3]);
/**
* Returns 1 if the min and max points of bbox are contained
* within the bounds of this box, else returns 0.
*/
int Contains(const vtkBoundingBox &bbox) const;
//@{
/**
* Get the bounds of the box (defined by vtk style)
*/
void GetBounds(double bounds[6]) const;
void GetBounds(double &xMin, double &xMax,
double &yMin, double &yMax,
double &zMin, double &zMax) const;
//@}
/**
* Return the ith bounds of the box (defined by vtk style)
*/
double GetBound(int i) const;
//@{
/**
* Get the minimum point of the bounding box
*/
const double *GetMinPoint() const;
void GetMinPoint(double &x, double &y, double &z) const;
//@}
//@{
/**
* Get the maximum point of the bounding box
*/
const double *GetMaxPoint() const;
void GetMaxPoint(double &x, double &y, double &z) const;
//@}
//@{
/**
* Returns 1 if the point is contained in the box else 0;
*/
int ContainsPoint(double p[3]) const;
int ContainsPoint(double px, double py, double pz) const;
//@}
/**
* Get the center of the bounding box
*/
void GetCenter(double center[3]) const;
/**
* Get the lengths of the box
*/
void GetLengths(double lengths[3]) const;
/**
* Return the length in the ith direction
*/
double GetLength(int i) const;
/**
* Return the Max Length of the box
*/
double GetMaxLength() const;
/**
* Return the length of the diagonal.
* \pre not_empty: this->IsValid()
*/
double GetDiagonalLength() const;
/**
* Expand the Box by delta on each side, the box will grow by
* 2*delta in x,y and z
*/
void Inflate(double delta);
//@{
/**
* Returns 1 if the bounds have been set and 0 if the box is in its
* initialized state which is an inverted state
*/
int IsValid() const;
static int IsValid(const double bounds[6]);
//@}
/**
* Returns the box to its initialized state
*/
void Reset();
//@{
/**
* Scale each dimension of the box by some given factor.
* If the box is not valid, it stays unchanged.
* If the scalar factor is negative, bounds are flipped: for example,
* if (xMin,xMax)=(-2,4) and sx=-3, (xMin,xMax) becomes (-12,6).
*/
void Scale(double s[3]);
void Scale(double sx,
double sy,
double sz);
//@}
protected:
double MinPnt[3], MaxPnt[3];
};
inline void vtkBoundingBox::Reset()
{
this->MinPnt[0] = this->MinPnt[1] = this->MinPnt[2] = VTK_DOUBLE_MAX;
this->MaxPnt[0] = this->MaxPnt[1] = this->MaxPnt[2] = VTK_DOUBLE_MIN;
}
inline void vtkBoundingBox::GetBounds(double &xMin, double &xMax,
double &yMin, double &yMax,
double &zMin, double &zMax) const
{
xMin = this->MinPnt[0];
xMax = this->MaxPnt[0];
yMin = this->MinPnt[1];
yMax = this->MaxPnt[1];
zMin = this->MinPnt[2];
zMax = this->MaxPnt[2];
}
inline double vtkBoundingBox::GetBound(int i) const
{
// If i is odd then when are returning a part of the max bounds
// else part of the min bounds is requested. The exact component
// needed is i /2 (or i right shifted by 1
return ((i & 0x1) ? this->MaxPnt[i>>1] : this->MinPnt[i>>1]);
}
inline const double *vtkBoundingBox::GetMinPoint() const
{
return this->MinPnt;
}
inline const double *vtkBoundingBox::GetMaxPoint() const
{
return this->MaxPnt;
}
inline int vtkBoundingBox::IsValid() const
{
return ((this->MinPnt[0] <= this->MaxPnt[0]) &&
(this->MinPnt[1] <= this->MaxPnt[1]) &&
(this->MinPnt[2] <= this->MaxPnt[2]));
}
inline int vtkBoundingBox::IsValid(const double bounds[6])
{
return (bounds[0] <= bounds[1] &&
bounds[2] <= bounds[3] &&
bounds[4] <= bounds[5]);
}
inline double vtkBoundingBox::GetLength(int i) const
{
return this->MaxPnt[i] - this->MinPnt[i];
}
inline void vtkBoundingBox::GetLengths(double lengths[3]) const
{
lengths[0] = this->GetLength(0);
lengths[1] = this->GetLength(1);
lengths[2] = this->GetLength(2);
}
inline void vtkBoundingBox::GetCenter(double center[3]) const
{
center[0] = 0.5 * (this->MaxPnt[0] + this->MinPnt[0]);
center[1] = 0.5 * (this->MaxPnt[1] + this->MinPnt[1]);
center[2] = 0.5 * (this->MaxPnt[2] + this->MinPnt[2]);
}
inline void vtkBoundingBox::SetBounds(const double bounds[6])
{
this->SetBounds(bounds[0], bounds[1], bounds[2],
bounds[3], bounds[4], bounds[5]);
}
inline void vtkBoundingBox::GetBounds(double bounds[6]) const
{
this->GetBounds(bounds[0], bounds[1], bounds[2],
bounds[3], bounds[4], bounds[5]);
}
inline vtkBoundingBox::vtkBoundingBox()
{
this->Reset();
}
inline vtkBoundingBox::vtkBoundingBox(const double bounds[6])
{
this->Reset();
this->SetBounds(bounds);
}
inline vtkBoundingBox::vtkBoundingBox(double xMin, double xMax,
double yMin, double yMax,
double zMin, double zMax)
{
this->Reset();
this->SetBounds(xMin, xMax, yMin, yMax, zMin, zMax);
}
inline vtkBoundingBox::vtkBoundingBox(const vtkBoundingBox &bbox)
{
this->MinPnt[0] = bbox.MinPnt[0];
this->MinPnt[1] = bbox.MinPnt[1];
this->MinPnt[2] = bbox.MinPnt[2];
this->MaxPnt[0] = bbox.MaxPnt[0];
this->MaxPnt[1] = bbox.MaxPnt[1];
this->MaxPnt[2] = bbox.MaxPnt[2];
}
inline vtkBoundingBox &vtkBoundingBox::operator=(const vtkBoundingBox &bbox)
{
this->MinPnt[0] = bbox.MinPnt[0];
this->MinPnt[1] = bbox.MinPnt[1];
this->MinPnt[2] = bbox.MinPnt[2];
this->MaxPnt[0] = bbox.MaxPnt[0];
this->MaxPnt[1] = bbox.MaxPnt[1];
this->MaxPnt[2] = bbox.MaxPnt[2];
return *this;
}
inline bool vtkBoundingBox::operator==(const vtkBoundingBox &bbox)const
{
return ((this->MinPnt[0] == bbox.MinPnt[0]) &&
(this->MinPnt[1] == bbox.MinPnt[1]) &&
(this->MinPnt[2] == bbox.MinPnt[2]) &&
(this->MaxPnt[0] == bbox.MaxPnt[0]) &&
(this->MaxPnt[1] == bbox.MaxPnt[1]) &&
(this->MaxPnt[2] == bbox.MaxPnt[2]));
}
inline bool vtkBoundingBox::operator!=(const vtkBoundingBox &bbox)const
{
return !((*this) == bbox);
}
inline void vtkBoundingBox::SetMinPoint(double p[3])
{
this->SetMinPoint(p[0], p[1], p[2]);
}
inline void vtkBoundingBox::SetMaxPoint(double p[3])
{
this->SetMaxPoint(p[0], p[1], p[2]);
}
inline void vtkBoundingBox::GetMinPoint(double &x, double &y, double &z) const
{
x = this->MinPnt[0];
y = this->MinPnt[1];
z = this->MinPnt[2];
}
inline void vtkBoundingBox::GetMaxPoint(double &x, double &y, double &z) const
{
x = this->MaxPnt[0];
y = this->MaxPnt[1];
z = this->MaxPnt[2];
}
inline int vtkBoundingBox::ContainsPoint(double px, double py,
double pz) const
{
if ((px < this->MinPnt[0]) || (px > this->MaxPnt[0]))
{
return 0;
}
if ((py < this->MinPnt[1]) || (py > this->MaxPnt[1]))
{
return 0;
}
if ((pz < this->MinPnt[2]) || (pz > this->MaxPnt[2]))
{
return 0;
}
return 1;
}
inline int vtkBoundingBox::ContainsPoint(double p[3]) const
{
return this->ContainsPoint(p[0], p[1], p[2]);
}
#endif
// VTK-HeaderTest-Exclude: vtkBoundingBox.h
|