4
/**************************************************************************\
6
* This file is part of the Coin 3D visualization library.
7
* Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License
11
* ("GPL") version 2 as published by the Free Software Foundation.
12
* See the file LICENSE.GPL at the root directory of this source
13
* distribution for additional information about the GNU GPL.
15
* For using Coin with software that can not be combined with the GNU
16
* GPL, and for taking advantage of the additional benefits of our
17
* support services, please contact Systems in Motion about acquiring
18
* a Coin Professional Edition License.
20
* See http://www.coin3d.org/ for more information.
22
* Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23
* http://www.sim.no/ sales@sim.no coin-support@coin3d.org
25
\**************************************************************************/
29
#include <Inventor/SbVec3d.h>
37
class COIN_DLL_API SbBox3d {
39
SbBox3d(void) { makeEmpty(); }
40
SbBox3d(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
41
: minpt(xmin, ymin, zmin), maxpt(xmax, ymax, zmax) { }
42
SbBox3d(const SbVec3d & minpoint, const SbVec3d & maxpoint)
43
: minpt(minpoint), maxpt(maxpoint) { }
44
explicit SbBox3d(const SbBox3f & box) { setBounds(box); }
45
explicit SbBox3d(const SbBox3s & box) { setBounds(box); }
46
explicit SbBox3d(const SbBox3i32 & box) { setBounds(box); }
48
SbBox3d & setBounds(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
49
{ minpt.setValue(xmin, ymin, zmin); maxpt.setValue(xmax, ymax, zmax); return *this; }
50
SbBox3d & setBounds(const SbVec3d & minpoint, const SbVec3d & maxpoint)
51
{ minpt = minpoint; maxpt = maxpoint; return *this; }
52
SbBox3d & setBounds(const SbBox3f & box);
53
SbBox3d & setBounds(const SbBox3s & box);
54
SbBox3d & setBounds(const SbBox3i32 & box);
56
void getBounds(double & xmin, double & ymin, double & zmin, double & xmax, double & ymax, double & zmax) const
57
{ minpt.getValue(xmin, ymin, zmin); maxpt.getValue(xmax, ymax, zmax); }
58
void getBounds(SbVec3d & minpoint, SbVec3d & maxpoint) const
59
{ minpoint = minpt; maxpoint = maxpt; }
61
const SbVec3d & getMin(void) const { return minpt; }
62
SbVec3d & getMin(void) { return minpt; }
63
const SbVec3d & getMax(void) const { return maxpt; }
64
SbVec3d & getMax(void) { return maxpt; }
66
void extendBy(const SbVec3d & pt);
67
void extendBy(const SbBox3d & box);
68
void transform(const SbDPMatrix & matrix);
70
SbBool isEmpty(void) const { return (maxpt[0] < minpt[0]); }
71
SbBool hasVolume(void) const
72
{ return ((maxpt[0] > minpt[0]) && (maxpt[1] > minpt[1]) && (maxpt[2] > minpt[2])); }
73
double getVolume(void) const
74
{ double dx = 0.0, dy = 0.0, dz = 0.0; getSize(dx, dy, dz); return (dx * dy * dz); }
76
SbBool intersect(const SbVec3d & point) const;
77
SbBool intersect(const SbBox3d & box) const;
78
SbVec3d getClosestPoint(const SbVec3d & point) const;
79
SbBool outside(const SbDPMatrix & mvp, int & cullbits) const;
81
SbVec3d getCenter(void) const { return (minpt + maxpt) * 0.5; }
82
void getOrigin(double & origoX, double & origoY, double & origoZ) const
83
{ minpt.getValue(origoX, origoY, origoZ); }
84
void getSize(double & sizeX, double & sizeY, double & sizeZ) const
85
{ if (isEmpty()) { sizeX = sizeY = sizeZ = 0.0; }
86
else { sizeX = maxpt[0] - minpt[0]; sizeY = maxpt[1] - minpt[1]; sizeZ = maxpt[2] - minpt[2]; } }
88
void getSpan(const SbVec3d & dir, double & dmin, double & dmax) const;
90
void print(FILE * file) const;
97
COIN_DLL_API inline int operator == (const SbBox3d & b1, const SbBox3d & b2) {
98
return ((b1.getMin() == b2.getMin()) && (b1.getMax() == b2.getMax()));
101
COIN_DLL_API inline int operator != (const SbBox3d & b1, const SbBox3d & b2) {
105
#endif // !COIN_SBBOX3D_H