Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Bbox.cpp

Go to the documentation of this file.
00001 #include "Bbox.h"
00002 
00003 using namespace X3DTK;
00004 
00005 Bbox::Bbox()
00006 {
00007   center_ = SFVec3f(0.0f, 0.0f, 0.0f);
00008   size_ = SFVec3f(-1.0f, -1.0f, -1.0f);
00009 }
00010 
00011 Bbox::Bbox(const SFVec3f &center, const SFVec3f &size)
00012 {
00013   center_ = center;
00014   size_ = size;
00015 }
00016 
00017 Bbox::Bbox(const MFVec3f &coord)
00018 {
00019   if (coord.empty())
00020   {
00021     Bbox BB(SFVec3f(0.0f, 0.0f, 0.0f), SFVec3f(0.0f, 0.0f, 0.0f));
00022     return;
00023   }
00024   
00025   SFVec3f min = coord[0];
00026   SFVec3f max = coord[0];
00027   
00028   for (MFVec3f::const_iterator itVertex = coord.begin(); itVertex != coord.end(); ++itVertex)
00029   {
00030     SFVec3f min2 = *itVertex;
00031     SFVec3f max2 = *itVertex;
00032   
00033     if (min2.x < min.x)
00034       min.x = min2.x;
00035     if (min2.y < min.y)
00036       min.y = min2.y;
00037     if (min2.z < min.z)
00038       min.z = min2.z;
00039   
00040     if (max2.x < max.x)
00041       max.x = max2.x;
00042     if (max2.y < max.y)
00043       max.y = max2.y;
00044     if (max2.z < max.z)
00045       max.z = max2.z;
00046   }
00047   
00048   //computing the new center
00049   center_ = 0.5f*(min + max);
00050   size_ = 2.0f*(max - center_);
00051 }
00052 
00053 Bbox::Bbox(const Bbox &B)
00054 {
00055   center_ = B.center_;
00056   size_ = B.size_;
00057 }
00058 

Generated on Wed May 14 10:03:07 2003 for X3DToolKit by doxygen1.3