#include namespace IMG { Bsp::Bsp() : root(NULL), countleaf(0), counttotal(0) { } Bsp::~Bsp() { } void Bsp::setRoot(NodeBspPtr node) { root = node; counttotal++; } void Bsp::print() { Ogre::LogManager::getSingleton().logMessage("\nImprimint Arbre BSP, num nodes leaf: " + Ogre::StringConverter::toString(countleaf) + ", totals: " + Ogre::StringConverter::toString(counttotal)); print(root); } void Bsp::printLeaf() { printLeaf(root); } NodeBspPtr Bsp::insert(int w, int h, int idcluster) { NodeBspPtr node = root->insert(w,h); if (idcluster != -1) { node->setId(idcluster); countleaf++; } else { counttotal++; } return node; } NodeBspPtr Bsp::get(int i) { return root->get(root, i); } void Bsp::print(NodeBspPtr node) { node->print(); this->print(node->getChild(0)); this->print(node->getChild(1)); } void Bsp::printLeaf(NodeBspPtr node) { if (node->getChild(0) == NULL && node->getChild(1) == NULL) { node->print(); } printLeaf(node->getChild(0)); printLeaf(node->getChild(1)); } }