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

BboxUpdaterShapeVisitor.cpp

Go to the documentation of this file.
00001 #include "BboxUpdaterShapeVisitor.h"
00002 #include "X3DShapeNode.h"
00003 #include "Shape.h"
00004 #include "Bbox.h"
00005 
00006 #include <iostream>
00007 
00008 using namespace X3DTK;
00009 using namespace std;
00010 
00011 BboxUpdaterShapeVisitor::BboxUpdaterShapeVisitor()
00012 : ShapeVisitor()
00013 {
00014   // WalkOn functions.
00015   defineNewWalkOnFunction<BboxUpdaterShapeVisitor, X3DShapeNode>(&BboxUpdaterShapeVisitor::walkOnX3DShapeNode);
00016 
00017   // Leave functions.
00018   defineNewLeaveFunction<BboxUpdaterShapeVisitor, Shape>(&BboxUpdaterShapeVisitor::leaveShape);
00019 
00020   // GlobalVariables assignation.
00021   globalVariables = GVManager::getInstanceOf<BboxUpdaterGlobalVariables>();
00022 }
00023 
00024 BboxUpdaterShapeVisitor::~BboxUpdaterShapeVisitor()
00025 {
00026 }
00027 
00028 bool BboxUpdaterShapeVisitor::walkOnX3DShapeNode(X3DShapeNode *N, SFNode Child) const
00029 {
00030   return true;
00031 }
00032 
00033 void BboxUpdaterShapeVisitor::leaveShape(Shape *S) const
00034 {
00035   Bbox *BB = globalVariables->getBbox(S);
00036   if (BB == 0)
00037   {
00038     BB = new Bbox(globalVariables->getShapeBbox());
00039     S->setBboxCenter(BB->getCenter());
00040     S->setBboxSize(BB->getSize());
00041     globalVariables->addBbox(S, BB); 
00042   }
00043 }
00044 

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