// Start a bbox3 with a point
bbox3(double x, double y, double z)
: empty(false), leftBound(x), bottomBound(y), nearBound(z), rightBound(x), topBound(y), farBound(z)
{
}
// Start a bbox3 with a point
bbox3(const triple& v)
: empty(false), leftBound(v.getx()), bottomBound(v.gety()), nearBound(v.getz()),
rightBound(v.getx()), topBound(v.gety()), farBound(v.getz())
{
}
// Start a bbox3 with 2 points
bbox3(const triple& m, const triple& M)
: empty(false),
leftBound(m.getx()), bottomBound(m.gety()), nearBound(m.getz()),
rightBound(M.getx()), topBound(M.gety()), farBound(M.getz())
{
}
// Add a point to a bbox3
void add(const triple& v)
{
const double x = v.getx(), y = v.gety(), z = v.getz();
add(x,y,z);
}
void add(double x, double y, double z)
{
if (empty) {
leftBound= rightBound= x;
topBound= bottomBound= y;
nearBound= farBound= z;
empty = false;
}
else {
if(x < leftBound)
leftBound= x;
else if(x > rightBound)
rightBound= x;
if(y < bottomBound)
bottomBound= y;
else if(y > topBound)
topBound= y;
if(z < nearBound)
nearBound= z;
else if(z > farBound)
farBound= z;
}
}
// Add a point to a nonempty bbox3
void addnonempty(double x, double y, double z)
{
if(x < leftBound)
leftBound= x;
else if(x > rightBound)
rightBound= x;
if(y < bottomBound)
bottomBound= y;
else if(y > topBound)
topBound= y;
if(z < nearBound)
nearBound= z;
else if(z > farBound)
farBound= z;
}
// Add a point to a nonempty bbox3
void addnonempty(const triple& v)
{
addnonempty(v.getx(),v.gety(),v.getz());
}
// Add a point to a nonempty bbox, updating bounding times
void addnonempty(const triple& v, bbox3& times, double t)
{
double x = v.getx(), y = v.gety(), z = v.getz();