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

Revision 169, 1.6 KB checked in by bittner, 19 years ago (diff)
Line 
1#ifndef _ViewCellBsp_H__
2#define _ViewCellBsp_H__
3
4#include "Plane3.h"
5
6
7class BSPInterior;
8
9/**
10     BSPNode abstract class serving for interior and leaf node implementation
11  */
12class BSPNode {
13public:
14  /** Determines whether this node is a leaf or not
15      @return true if leaf
16  */
17  virtual bool IsLeaf() const = 0;
18   
19  /** Determines whether this node is a root
20      @return true if root
21  */
22  virtual bool IsRoot() const {
23    return parent == NULL;
24  }
25protected:
26  /// parent of this node
27  BSPInterior *parent;
28};
29
30/** BSP interior node implementation */
31class BSPInterior : public BSPNode {
32   
33  /** @return false since it is an interior node */
34  virtual bool IsLeaf() const { return false; }
35
36protected:
37  /// Splitting plane corresponding to this node
38  Plane3 mPlane;
39  /// back node
40  BSPNode *mBack;
41  /// front node
42  BSPNode *mFront;
43};
44 
45 
46/** BSP leaf node implementation */
47class BSPLeaf : public BSPNode {
48public:
49  BSPLeaf(ViewCell *viewCell = NULL):mViewCell(viewCell) {}
50  /** @return true since it is an interior node */
51  virtual bool IsLeaf() const { return true; }
52
53protected:
54  /// polygonal representation of this viewcell
55  /// if NULL this note does not correspond to feasible viewcell
56  ViewCell *mViewCell;
57};
58 
59/** Implementation of the ViewCell BSP tree */
60class BSPTree {
61public:
62  /** Constructor takes a pointer to the cell corresponding to the whole
63      viewspace */
64  BSPTree(ViewCell *cell) {
65    mRootCell = cell;
66    mRoot = new BSPLeaf(mRootCell);
67  }
68   
69   
70protected:
71  /// Pointer to the root of the tree
72  BSPNode *mRoot;
73  /// Pointer to the root cell of the viewspace */
74  ViewCell *mRootCell;
75};
76 
77
78
79
80#endif
Note: See TracBrowser for help on using the repository browser.