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

Revision 721, 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    Print(node->GetChild(0));
59    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.