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

BboxUpdaterCoreVisitor.cpp

Go to the documentation of this file.
00001 #include "BboxUpdaterCoreVisitor.h"
00002 #include "X3DNode.h"
00003 #include "Scene.h"
00004 #include "Bbox.h"
00005 
00006 #include <iostream>
00007 
00008 using namespace X3DTK;
00009 using namespace std;
00010 
00011 BboxUpdaterCoreVisitor::BboxUpdaterCoreVisitor()
00012 : CoreVisitor()
00013 {
00014   // WalkOn functions.
00015   defineNewWalkOnFunction<BboxUpdaterCoreVisitor, X3DNode>(&BboxUpdaterCoreVisitor::walkOnX3DNode);
00016 
00017   // Leave functions.
00018   defineNewLeaveFunction<BboxUpdaterCoreVisitor, Scene>(&BboxUpdaterCoreVisitor::leaveScene);
00019 
00020   // GlobalVariables assignation.
00021   globalVariables = GVManager::getInstanceOf<BboxUpdaterGlobalVariables>();
00022 }
00023 
00024 BboxUpdaterCoreVisitor::~BboxUpdaterCoreVisitor()
00025 {
00026 }
00027 
00028 bool BboxUpdaterCoreVisitor::walkOnX3DNode(X3DNode *N, SFNode Child) const
00029 {
00030   return false;
00031 }
00032 
00033 void BboxUpdaterCoreVisitor::leaveScene(Scene *S) const
00034 {
00035   Bbox *BB = globalVariables->getBbox(S);
00036   if (BB == 0)
00037   {
00038     MFNode children = S->getChildren();
00039     for (MFNode::iterator it = children.begin(); it != children.end(); ++it)
00040     {
00041       X3DBoundedObject *BO = dynamic_cast<X3DBoundedObject *>(*it);
00042       if (BO != 0)
00043         globalVariables->addBboxToMergeList(Bbox(BO->getBboxCenter(), BO->getBboxSize()));
00044     }
00045     BB = new Bbox(globalVariables->mergeBbox()); 
00046     globalVariables->addBbox(S, BB);
00047     
00048     //updating the Bbox attributes.
00049     S->setBboxCenter(BB->getCenter());
00050     S->setBboxSize(BB->getSize());
00051   }
00052 }

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