00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023
00024
#ifndef VHDSCENECONVERTERABTTREE_H
00025
#define VHDSCENECONVERTERABTTREE_H
00026
00027
class vhdABTTree;
00028
00029
#include <vector>
00030
#include <map>
00031
#include <string>
00032
#include <list>
00033
#include "vhdSingleton.h"
00034
#include "vhdAxisAlignedBox.h"
00035
00041 class vhdSceneConverterABTTree :
public vhdSingleton<vhdSceneConverterABTTree>
00042 {
00043
public:
00047 class NodeChildStruct
00048 {
00049
public:
00050
NodeChildStruct(
const vhdAxisAlignedBox & _bbox,
const std::string & _strPath):bbox(_bbox),strPath(_strPath){}
00051
vhdAxisAlignedBox bbox;
00052 std::string strPath;
00053 };
00054
00055
typedef std::list<NodeChildStruct> ListAABB;
00056
00057
00058
00059
00060
00061
class vhdSceneABTTreeNode
00062 {
00063
public:
00064 vhdSceneABTTreeNode()
00065 {
00066 pLeft=pRight=NULL;
00067 }
00068 ListAABB listAABB;
00069 vhdSceneABTTreeNode* pLeft;
00070 vhdSceneABTTreeNode* pRight;
00071 };
00072
00073
typedef std::map<unsigned int, vhdSceneABTTreeNode> MapNodeChild;
00074
00075 MapNodeChild mapNodeChild;
00076
00077
00078
public:
00085
static vhdAxisAlignedBox findGlobalAABB(
const ListAABB & listAABB);
00086
00087
00088
00089
public:
00093
vhdSceneConverterABTTree();
00097
~vhdSceneConverterABTTree();
00098
00099
00100
private:
00104
static const unsigned int ABTTREE_AXISX;
00105
static const unsigned int ABTTREE_AXISY;
00106
static const unsigned int ABTTREE_AXISZ;
00107
static const unsigned int ABTTREE_AXISINVALID;
00108
00109
00110
00121
float _findBestSplitLocation (vhdSceneABTTreeNode *pParentNode ,
int axis,
float& fSplitLoc,
unsigned int uiNodeIndex);
00122
00123
public:
00124
00125
00126 vhdSceneABTTreeNode *pDataRootNode;
00127
00128
00137
void getChildren(vhdSceneABTTreeNode *pParentNode ,
unsigned int nCurrentChildPosition,
vhdAxisAlignedBox & boxLeft,
vhdAxisAlignedBox & boxRight);
00138
00139 };
00140
00141
#endif