source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGBsp.cpp @ 731

Revision 731, 1.1 KB checked in by igarcia, 19 years ago (diff)
Line 
1
2#include <IMGBsp.h>
3
4namespace IMG
5{
6
7Bsp::Bsp() : root(NULL), countleaf(0), counttotal(0)
8{
9}
10
11Bsp::~Bsp()
12{
13
14}
15
16void Bsp::setRoot(NodeBspPtr node)
17{
18    root = node;
19    counttotal++;
20}
21
22void Bsp::print()
23{
24        Ogre::LogManager::getSingleton().logMessage("\nImprimint Arbre BSP, num nodes leaf: " + Ogre::StringConverter::toString(countleaf) + ", totals: " + Ogre::StringConverter::toString(counttotal));
25    print(root);
26}
27
28void Bsp::printLeaf()
29{
30        printLeaf(root);
31}
32
33NodeBspPtr Bsp::insert(int w, int h, int idcluster)
34{
35    NodeBspPtr node = root->insert(w,h);
36
37        if (idcluster != -1)
38    {
39        node->setId(idcluster);
40        countleaf++;                   
41    }
42    else
43        {
44                counttotal++;
45        }
46       
47    return node;
48}
49
50NodeBspPtr Bsp::get(int i)
51{
52        return root->get(root, i);
53}
54
55void Bsp::print(NodeBspPtr node)
56{
57    node->print();
58    this->print(node->getChild(0));
59    this->print(node->getChild(1));
60}
61
62void Bsp::printLeaf(NodeBspPtr node)
63{       
64    if (node->getChild(0) == NULL && node->getChild(1) == NULL)
65        {
66                node->print();
67        }
68       
69    printLeaf(node->getChild(0));
70    printLeaf(node->getChild(1));       
71}
72
73}
Note: See TracBrowser for help on using the repository browser.