source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h @ 221

Revision 221, 2.4 KB checked in by mattausch, 19 years ago (diff)

changed notation for bsp trees

Line 
1#ifndef _ViewCellBsp_H__
2#define _ViewCellBsp_H__
3
4#include "Mesh.h"
5class ViewCell;
6class Plane3;
7//class Mesh;
8
9//namespace GtpVisibilityPreprocessor {
10 
11class BspInterior;
12
13
14  /**
15     BspNode abstract class serving for interior and leaf node implementation
16  */
17  class BspNode
18  {
19  public:
20          /** Determines whether this node is a leaf or not
21          @return true if leaf
22          */
23          virtual bool IsLeaf() const = 0;
24   
25          /** Determines whether this node is a root
26          @return true if root
27          */
28          virtual bool IsRoot() const;
29
30  protected:
31
32          /// parent of this node
33          BspInterior *mParent;
34  };
35
36  /** BSP interior node implementation */
37  class BspInterior : public BspNode
38  {   
39  public:
40          BspInterior(Plane3 plane): mPlane(plane) {}
41          /** @return false since it is an interior node */
42          bool IsLeaf() const;
43
44          BspNode *GetBack() {return mBack;}
45          BspNode *GetFront() {return mFront;}
46
47          void ReplaceChildLink(BspNode *oldChild, BspNode *newChild);
48          void SetupChildLinks(BspNode *b, BspNode *f);
49
50  protected:
51               
52          /// Splitting plane corresponding to this node
53          Plane3 mPlane;
54          /// back node
55          BspNode *mBack;
56          /// front node
57          BspNode *mFront;
58  };
59 
60 
61  /** BSP leaf node implementation */
62  class BspLeaf : public BspNode
63  {
64  public:
65          BspLeaf(ViewCell *viewCell = NULL);
66   
67          /** @return true since it is an interior node */
68          bool IsLeaf() const;
69
70  protected:
71   
72          /// polygonal representation of this viewcell
73          /// if NULL this note does not correspond to feasible viewcell
74          ViewCell *mViewCell;
75  };
76 
77  /** Implementation of the ViewCell BSP tree */
78  class BspTree
79  {
80  public:
81          struct BspTraversalData
82          { 
83                  BspNode *mNode;
84                  BspInterior *mParent;
85
86                  Mesh mViewCell;
87                  int mDepth;
88                     
89                  BspTraversalData() {}
90                  BspTraversalData(BspNode *n, BspInterior *p, const Mesh &m, const int d):
91                  mNode(n), mParent(p), mViewCell(m), mDepth(d) {}
92      };
93         
94          /** Constructor takes a pointer to the cell corresponding to the whole
95          viewspace */
96          BspTree(ViewCell *cell);
97       
98  protected:
99
100          Plane3 *SelectPlane(Mesh *viewcell);
101          void Subdivide();
102           
103          BspNode *SubdivideNode(BspLeaf *leaf, BspInterior *parent,
104                                                         Mesh *viewCell, const int depth,
105                                                         Mesh &frontPolys, Mesh &backPolys);
106
107          /// Pointer to the root of the tree
108          BspNode *mRoot;
109          /// Pointer to the root cell of the viewspace
110          ViewCell *mRootCell;
111  };
112 
113//}; // GtpVisibilityPreprocessor
114
115#endif
Note: See TracBrowser for help on using the repository browser.