CODBspNode Class

class CODBspNode

This is a single node of the binary space partitioning tree. A BSP node represents a rectangle in space which can be further divided up into two smaller rectangles. This partition of space always happens on the horizontal or vertical center of the node's rectangle. The two smaller rectangles are then represented by BSP node themselves, which are children of the current node.

Each node can can have an array of rectangles which are within its section of space. Typically, only the leaf nodes will have anything in their arrays.

Defined in: OdBspNode.h

See Also

CODBspTree,  CODBspRect

Class Members

Construction

 CODBspNode(CRect rcSpace)

Constructor.

Attributes

CRect  m_rcSpace

The rectangle of space that this node represents.

CODBspRectArray  m_arBspRects

An array of rectangles that are in this section of space.

CODBspNode*  m_pBackNode

BSP node containing rectangles in back of the partition.

CODBspNode*  m_pFrontNode

BSP node containing rectangles in front of the partition.

BOOL  IsPartitionVertical()

Returns TRUE if the partition of this node is vertical.

BOOL  IsLeaf() const

Returns TRUE if this is a leaf node of the BSP tree.

BOOL  IsEmpty() const

Returns TRUE if this node is empty and can be removed.

CPoint  GetPartitionPoint() const

Gets the point where this node can be partitioned.

Operations

void  AddRects(CODBspRectArray* pRectArray, int nThreshold)

Adds an array of rectangles to this section of the tree.

BOOL  RemoveRects(CODBspRectArray* pRectArray)

Removes a list of rectangles from this section of the tree.

void  GetContaining(CODComponentMap* pCompMap, CPoint point)

Retrieves all of the components in this section of the tree that contain the point passed in.

void  GetWithin(CODComponentMap* pCompMap, CRect rect)

Retrieves all of the components in this section of the tree that are within the rectangle passed in.

void  GetIntersecting(CODComponentMap* pCompMap, CRect rect)

Retrieves all of the components in this section of the tree that intersect the rectangle passed in.

Implementation

virtual  ~CODBspNode()

Destructor.

OD_BSP_TYPE  ClassifyRect(CRect rect)

Determines where a rectangle is with respect to the partition.

OD_BSP_TYPE  ClassifyPoint(CPoint point)

Determines where a point is with respect to the partition.

void  SplitRect(CRect* pOriginalRect, CRect* pBackRect, CRect* pFrontRect)

Divides a rectangle into two pieces using the partition.

void  SplitBspRect(CODBspRect* pOriginalRect, CODBspRect* pBackRect, CODBspRect* pFrontRect)

Divides a rectangle into two pieces using the partition. This method also maintains the component associations of the rectangles.