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