Line | |
---|
1 | |
---|
2 | #include <IMGBsp.h> |
---|
3 | |
---|
4 | namespace IMG |
---|
5 | { |
---|
6 | |
---|
7 | Bsp::Bsp() : root(NULL), countleaf(0), counttotal(0) |
---|
8 | { |
---|
9 | } |
---|
10 | |
---|
11 | Bsp::~Bsp() |
---|
12 | { |
---|
13 | |
---|
14 | } |
---|
15 | |
---|
16 | void Bsp::setRoot(NodeBspPtr node) |
---|
17 | { |
---|
18 | root = node; |
---|
19 | counttotal++; |
---|
20 | } |
---|
21 | |
---|
22 | void 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 | |
---|
28 | void Bsp::printLeaf() |
---|
29 | { |
---|
30 | printLeaf(root); |
---|
31 | } |
---|
32 | |
---|
33 | NodeBspPtr 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 | |
---|
50 | NodeBspPtr Bsp::get(int i) |
---|
51 | { |
---|
52 | return root->get(root, i); |
---|
53 | } |
---|
54 | |
---|
55 | void Bsp::print(NodeBspPtr node) |
---|
56 | { |
---|
57 | node->print(); |
---|
58 | this->print(node->getChild(0)); |
---|
59 | this->print(node->getChild(1)); |
---|
60 | } |
---|
61 | |
---|
62 | void 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.