1 | /*! |
---|
2 | \file proto_class.h |
---|
3 | * Definition of ... |
---|
4 | |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _QUADTREE_NODE_H |
---|
8 | #define _QUADTREE_NODE_H |
---|
9 | |
---|
10 | #include "base_object.h" |
---|
11 | #include "vector.h" |
---|
12 | #include "abstract_model.h" |
---|
13 | |
---|
14 | // FORWARD DEFINITION |
---|
15 | class Quadtree; |
---|
16 | |
---|
17 | |
---|
18 | //! A class for a Quadtree Node representation |
---|
19 | class QuadtreeNode : public BaseObject { |
---|
20 | |
---|
21 | public: |
---|
22 | QuadtreeNode(sTriangleExt** triangles, int numTriangles, |
---|
23 | const float* pVertices, int numVertices, |
---|
24 | Quadtree* quadtree, QuadtreeNode* parent, |
---|
25 | Rectangle* rect, int treeDepth, const int maxDepth, int index); |
---|
26 | QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth); |
---|
27 | virtual ~QuadtreeNode(); |
---|
28 | |
---|
29 | void buildHashTable(QuadtreeNode** nodeList, int* index); |
---|
30 | |
---|
31 | float getHeight(const Vector& position); |
---|
32 | Rectangle* getDimension() { return this->pDimension; } |
---|
33 | |
---|
34 | bool includesPoint(const Vector& v); |
---|
35 | |
---|
36 | void drawTree(int depth, int drawMode) const; |
---|
37 | |
---|
38 | |
---|
39 | private: |
---|
40 | void init(); |
---|
41 | |
---|
42 | void separateNode(float minLength); |
---|
43 | void separateNode(); |
---|
44 | |
---|
45 | Rectangle* getDimFromModel(); |
---|
46 | |
---|
47 | protected: |
---|
48 | QuadtreeNode* parent; //!< reference to the paren QuadtreeNode (NULL if rootnode) |
---|
49 | QuadtreeNode* nodeA; //!< reference to the node A |
---|
50 | QuadtreeNode* nodeB; //!< reference to the node B |
---|
51 | QuadtreeNode* nodeC; //!< reference to the node C |
---|
52 | QuadtreeNode* nodeD; //!< reference to the node D |
---|
53 | QuadtreeNode** nodes; //!< reference to the quadtree nodes |
---|
54 | int nodeIter; //!< temp helping variable for the hashing algorithm |
---|
55 | |
---|
56 | private: |
---|
57 | Quadtree* quadtree; //!< reference to the quadtree |
---|
58 | Vector center; //!< center coordinate of the quadtree node - relative coordinates in model space(!) |
---|
59 | float axisLength; //!< axis length of the quadtree |
---|
60 | float maxHeigth; //!< max height of the model in the quadtree |
---|
61 | float offset; //!< offset of the actual quadtree rectangle |
---|
62 | |
---|
63 | int treeDepth; //!< the depth of the tree |
---|
64 | int maxDepth; //!< the maximal depth of the tree |
---|
65 | int indexNode; //!< the index number of the node |
---|
66 | |
---|
67 | sTriangleExt** pTriangles; //!< reference to the triangles of the node |
---|
68 | const float* pVertices; //!< reference to vertices data |
---|
69 | unsigned int numTriangles; //!< number of triangles of the Node |
---|
70 | unsigned int numVertices; //!< number of vertices of the node |
---|
71 | modelInfo* pModelInfo; //!< reference to the modelInfo of the object |
---|
72 | Rectangle* pDimension; //!< pointer to the local rectangle properties |
---|
73 | }; |
---|
74 | |
---|
75 | #endif /* _QUADTREE_NODE_H */ |
---|