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

VIEWS_API 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.

VIEWS_API BOOL IsPartitionVertical()

Returns TRUE if the partition of this node is vertical.

VIEWS_API BOOL IsLeaf() const

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

VIEWS_API BOOL IsEmpty() const

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

VIEWS_API CPoint GetPartitionPoint() const

Gets the point where this node can be partitioned.

Operations

VIEWS_API void AddRects(CODBspRectArray* pRectArray, int nThreshold)

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

VIEWS_API BOOL RemoveRects(CODBspRectArray* pRectArray)

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

VIEWS_API void GetContaining(CODComponentMap* pCompMap, CPoint point)

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

VIEWS_API void GetWithin(CODComponentMap* pCompMap, CRect rect)

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

VIEWS_API void GetIntersecting(CODComponentMap* pCompMap, CRect rect)

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

Implementation

VIEWS_API virtual ~CODBspNode()

Destructor.

VIEWS_API OD_BSP_TYPE ClassifyRect(CRect rect)

Determines where a rectangle is with respect to the partition.

VIEWS_API OD_BSP_TYPE ClassifyPoint(CPoint point)

Determines where a point is with respect to the partition.

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

Divides a rectangle into two pieces using the partition.

VIEWS_API 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.