#include "BBox.h" namespace X3DTK { BBox::BBox() : _center(SFVec3f(0.0f, 0.0f, 0.0f)), _size(SFVec3f(-1.0f, -1.0f, -1.0f)) { } BBox::BBox(const SFVec3f ¢er, const SFVec3f &size) : _center(center), _size(size) { } BBox::BBox(const BBox &B) : _center(B._center), _size(B._size) { } BBox::BBox(const MFVec3f &coord) { if (coord.empty()) return; SFVec3f min = coord[0]; SFVec3f max = coord[0]; for (MFVec3f::const_iterator itVertex = coord.begin(); itVertex != coord.end(); ++itVertex) { SFVec3f min2 = *itVertex; SFVec3f max2 = *itVertex; if (min2.x < min.x) min.x = min2.x; if (min2.y < min.y) min.y = min2.y; if (min2.z < min.z) min.z = min2.z; if (max2.x < max.x) max.x = max2.x; if (max2.y < max.y) max.y = max2.y; if (max2.z < max.z) max.z = max2.z; } //computing the new center _center = 0.5f*(min + max); _size = 2.0f*(max - _center); } }