#include "X3D_MyBBoxUpdaterGeometry3DVisitor.h" #include "X3D_Icosahedron.h" #include using namespace std; namespace X3DTK { namespace X3D { MyBBoxUpdaterGeometry3DVisitor::MyBBoxUpdaterGeometry3DVisitor() : BBoxUpdaterGeometry3DVisitor() { // Defines the new enter function for the X3DAbstractNode. define(Recorder::getEnterFunction(&MyBBoxUpdaterGeometry3DVisitor::enterIcosahedron)); } void MyBBoxUpdaterGeometry3DVisitor::enterIcosahedron(Icosahedron *I) { // StateVariables assignation BBoxUpdaterStateVariables *stateVariables = Singleton::getInstance(); // Checking whether the BBox of the node has already been computed or not. BBox *BB = stateVariables->getBBox(I); if (BB == 0) { // Creating a new BBox. BB = new BBox(SFVec3f(0.0f, 0.0f, 0.0f), SFVec3f(I->getRadius(), I->getRadius(), I->getRadius())); // Recording the couple (I, BB) to avoid to create a new BBox // if I is visited a second time. stateVariables->addBBox(I, BB); // Setting the current BBox. stateVariables->setShapeBBox(*BB); } } } }