QUAOAR STUDIO // Mobius API
mobius::poly_QuadtreeNode Class Reference

#include <poly_Quadtree.h>

Public Member Functions

mobiusPoly_EXPORT poly_QuadtreeNode ()
 Default ctor.
 
mobiusPoly_EXPORT poly_QuadtreeNode (const t_uv &cornerMin, const t_uv &cornerMax)
 
mobiusPoly_EXPORT ~poly_QuadtreeNode ()
 Dtor. It is not virtual to save 8 bytes of memory.
 

Static Public Member Functions

static mobiusPoly_EXPORT bool IsValidCornerId (const size_t id)
 
static mobiusPoly_EXPORT size_t GetCornerID (const size_t nx, const size_t ny)
 
static mobiusPoly_EXPORT void GetCornerLocation (const size_t id, size_t &nx, size_t &ny)
 

Detailed Description

A single node in our quadtree data structure.

Constructor & Destructor Documentation

◆ poly_QuadtreeNode()

mobiusPoly_EXPORT mobius::poly_QuadtreeNode::poly_QuadtreeNode ( const t_uv cornerMin,
const t_uv cornerMax 
)

Ctor accepting corners.

Parameters
[in]cornerMinmin corner point.
[in]cornerMaxmax corner point.

Member Function Documentation

◆ GetCornerID()

static mobiusPoly_EXPORT size_t mobius::poly_QuadtreeNode::GetCornerID ( const size_t  nx,
const size_t  ny 
)
static

Returns the ID of one of the 4 cell corners. This ID is determined by the passed locations of the corresponding x and y coordinates. The passed arguments may have values 0 and 1, hence there are 4 combinations (4 corners).

The returned ID is derived with the following rule:

//!  ID = nx | (ny << 1)
//! 
So it gives:

\verbatim

//! nx | ny || id //! ====+====++=== //! 0 | 0 || 0 //! -—+-—++— //! 1 | 0 || 1 //! -—+-—++— //! 0 | 1 || 2 //! -—+-—++— //! 1 | 1 || 3 //! -—+-—++— //!

\param[in] nx X location (0 for min, 1 for max).
\param[in] ny Y location (0 for min, 1 for max).
\return ID of the corner in range [0,3]. 

◆ GetCornerLocation()

static mobiusPoly_EXPORT void mobius::poly_QuadtreeNode::GetCornerLocation ( const size_t  id,
size_t &  nx,
size_t &  ny 
)
static

Given the corner ID in range [0,3], this static function returns the location of the corner in a cell.

The location is derived with the following rule (opposite to the rule which is used to derive the ID by location):

//!  nx = (id >> 0) & 1
//!  ny = (id >> 1) & 1
//! 
\verbatim

//! id || nx | ny //! ====++====+==== //! 0 || 0 | 0 //! -—++-—+-— //! 1 || 1 | 0 //! -—++-—+-— //! 2 || 0 | 1 //! -—++-—+-— //! 3 || 1 | 1 //! -—++-—+-— //!

\param[in]  id ID of the corner.
\param[out] nx location along OX world axis.
\param[out] ny location along OY world axis. 

◆ IsValidCornerId()

static mobiusPoly_EXPORT bool mobius::poly_QuadtreeNode::IsValidCornerId ( const size_t  id)
static

Checks if the passed corner ID is valid.

Parameters
[in]idID to check.
Returns
true/false.

The documentation for this class was generated from the following file: