#ifndef _ViewCellBsp_H__ #define _ViewCellBsp_H__ #include "Plane3.h" class BSPInterior; /** BSPNode abstract class serving for interior and leaf node implementation */ class BSPNode { public: /** Determines whether this node is a leaf or not @return true if leaf */ virtual bool IsLeaf() const = 0; /** Determines whether this node is a root @return true if root */ virtual bool IsRoot() const { return parent == NULL; } protected: /// parent of this node BSPInterior *parent; }; /** BSP interior node implementation */ class BSPInterior : public BSPNode { /** @return false since it is an interior node */ virtual bool IsLeaf() const { return false; } protected: /// Splitting plane corresponding to this node Plane3 mPlane; /// back node BSPNode *mBack; /// front node BSPNode *mFront; }; /** BSP leaf node implementation */ class BSPLeaf : public BSPNode { public: BSPLeaf(ViewCell *viewCell = NULL):mViewCell(viewCell) {} /** @return true since it is an interior node */ virtual bool IsLeaf() const { return true; } protected: /// polygonal representation of this viewcell /// if NULL this note does not correspond to feasible viewcell ViewCell *mViewCell; }; /** Implementation of the ViewCell BSP tree */ class BSPTree { public: /** Constructor takes a pointer to the cell corresponding to the whole viewspace */ BSPTree(ViewCell *cell) { mRootCell = cell; mRoot = new BSPLeaf(mRootCell); } protected: /// Pointer to the root of the tree BSPNode *mRoot; /// Pointer to the root cell of the viewspace */ ViewCell *mRootCell; }; #endif