#include <poly_SVO.h>
Classes | |
struct | Summary |
Voxelization summary. More... | |
Public Member Functions | |
mobiusPoly_EXPORT | poly_SVO () |
Default ctor. | |
mobiusPoly_EXPORT | poly_SVO (const t_xyz &cornerMin, const t_xyz &cornerMax) |
mobiusPoly_EXPORT | ~poly_SVO () |
Dtor. It is not virtual to save 8 bytes of memory. | |
mobiusPoly_EXPORT void | Release () |
mobiusPoly_EXPORT bool | HasScalars () |
mobiusPoly_EXPORT void | SetScalar (const size_t id, const double s) |
mobiusPoly_EXPORT double | GetScalar (const size_t id) const |
mobiusPoly_EXPORT bool | IsLeaf () const |
mobiusPoly_EXPORT void | GetLeaves (std::vector< const poly_SVO * > &leaves, const int sm=ScalarMembership_OnInOut) const |
mobiusPoly_EXPORT bool | IsNegative () const |
mobiusPoly_EXPORT bool | IsPositive () const |
mobiusPoly_EXPORT bool | IsZeroCrossing () const |
mobiusPoly_EXPORT bool | Split () |
mobiusPoly_EXPORT void | SetChild (const size_t id, poly_SVO *pChild) |
mobiusPoly_EXPORT poly_SVO * | GetChild (const size_t id) const |
mobiusPoly_EXPORT poly_SVO * | FindChild (const std::vector< size_t > &path) const |
mobiusPoly_EXPORT unsigned | GetDepth0 () const |
mobiusPoly_EXPORT double | Eval (const t_xyz &P, const bool bndOnly=false) const |
mobiusPoly_EXPORT unsigned long long | GetMemoryInBytes (int &numNodes) const |
mobiusPoly_EXPORT void | CollectSummary (const int sm, Summary &summary) const |
const t_xyz & | GetCornerMin () const |
void | SetCornerMin (const t_xyz &P) |
Sets new coordinates for the min corner point. | |
const t_xyz & | GetCornerMax () const |
void | SetCornerMax (const t_xyz &P) |
Sets new coordinates for the max corner point. | |
const t_xyz & | GetP0 () const |
t_xyz | GetP1 () const |
t_xyz | GetP2 () const |
t_xyz | GetP3 () const |
t_xyz | GetP4 () const |
t_xyz | GetP5 () const |
t_xyz | GetP6 () const |
const t_xyz & | GetP7 () const |
double | GetCellSize () const |
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, const size_t nz) |
static mobiusPoly_EXPORT void | GetCornerLocation (const size_t id, size_t &nx, size_t &ny, size_t &nz) |
Protected Member Functions | |
mobiusPoly_EXPORT void | getLeaves (const poly_SVO *pNode, const int sm, std::vector< const poly_SVO * > &leaves, std::vector< long long > &depths, const long long depth) const |
mobiusPoly_EXPORT void | getLeaves (const poly_SVO *pNode, const int sm, std::vector< const poly_SVO * > &leaves) const |
Protected Attributes | |
poly_SVO ** | m_pChildren |
Child octree nodes (8 bytes). | |
double | m_scalars [8] |
Stored scalar values (64 bytes). | |
t_xyz | m_cornerMin |
Min corner of the SVO box. | |
t_xyz | m_cornerMax |
Max corner of the SVO box. | |
A single node in the Sparse Voxel Octree data structure. Each corner of the SVO node is associated with a scalar value.
Ctor accepting corners.
[in] | cornerMin | min corner point. |
[in] | cornerMax | max corner point. |
mobiusPoly_EXPORT void mobius::poly_SVO::CollectSummary | ( | const int | sm, |
Summary & | summary | ||
) | const |
Collects the voxelization information for the octree starting from this SVO node. The outcome statistics is available in the output summary
argument. The summary contains grains sizes and their quantities, where sizes are taken as fractions of the occupied space. E.g., for a domain D=10x8x6
, a single split would result in eight cells of 5x4x3
giving the grain size of 1/2.
[in] | sm | the membership classifier to filter SVO. |
[out] | summary | the outcome summary structure. |
mobiusPoly_EXPORT double mobius::poly_SVO::Eval | ( | const t_xyz & | P, |
const bool | bndOnly = false |
||
) | const |
For the passed xyz
point, this method evaluates the scalar field which is defined in the current SVO node. For that, the method goes down by the SVO hierarchy until it reaches the leaf voxel containing the relevant field values.
[in] | P | point of interest. |
[in] | bndOnly | indicates whether the scalar field should only be evaluated for the zero-crossing nodes. If so, then for the negative nodes, the value of -1 is returned; for the positive nodes, the value of 1 is returned. |
mobiusPoly_EXPORT poly_SVO* mobius::poly_SVO::FindChild | ( | const std::vector< size_t > & | path | ) | const |
Attempts to find a child SVO node by the specified path. If a node corresponding to the given path is not accessible, null pointer is returned.
[in] | path | ordered set of indices to access the node. |
|
inline |
mobiusPoly_EXPORT poly_SVO* mobius::poly_SVO::GetChild | ( | const size_t | id | ) | const |
Returns the child SVO node by its index in range [0,7]. If there are no children in the current node, null pointer is returned.
[in] | id | ID of the child. |
|
static |
Returns the ID of one of the 8-th cell corners. This ID is determined by the passed locations of the corresponding x
, y
and z
coordinates. The passed arguments may have values 0 and 1, hence there are 8 combinations (8 corners).
The returned ID is derived with the following rule:
//! ID = nx | (ny << 1) | (nz << 2) //!
So it gives: \verbatim
//! nx | ny | nz || id //! ====+====+====++=== //! 0 | 0 | 0 || 0 //! -—+-—+-—++— //! 1 | 0 | 0 || 1 //! -—+-—+-—++— //! 0 | 1 | 0 || 2 //! -—+-—+-—++— //! 1 | 1 | 0 || 3 //! -—+-—+-—++— //! 0 | 0 | 1 || 4 //! -—+-—+-—++— //! 1 | 0 | 1 || 5 //! -—+-—+-—++— //! 0 | 1 | 1 || 6 //! -—+-—+-—++— //! 1 | 1 | 1 || 7 //! -—+-—+-—++— //!
\param[in] nx X location (0 for min, 1 for max). \param[in] ny Y location (0 for min, 1 for max). \param[in] nz Z location (0 for min, 1 for max). \return ID of the corner in range [0,7].
|
static |
Given the corner ID in range [0,7], this static function returns the location of the corner in a cell (vertex for octant, octant for voxel).
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 //! nz = (id >> 2) & 1 //!
\verbatim
//! id || nx | ny | nz //! ====++====+====+==== //! 0 || 0 | 0 | 0 //! -—++-—+-—+-— //! 1 || 1 | 0 | 0 //! -—++-—+-—+-— //! 2 || 0 | 1 | 0 //! -—++-—+-—+-— //! 3 || 1 | 1 | 0 //! -—++-—+-—+-— //! 4 || 0 | 0 | 1 //! -—++-—+-—+-— //! 5 || 1 | 0 | 1 //! -—++-—+-—+-— //! 6 || 0 | 1 | 1 //! -—++-—+-—+-— //! 7 || 1 | 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. \param[out] nz location along OZ world axis.
|
inline |
|
inline |
mobiusPoly_EXPORT unsigned mobius::poly_SVO::GetDepth0 | ( | ) | const |
Returns the depth of the octree starting from the 0-th node. This method consults the 0-th children only, so it is only applicable when your SVO is complete (i.e., the voxelization is uniform).
|
protected |
Recursively visits SVO nodes to add leaves to the passed output collection.
[in] | pNode | SVO node to visit. |
[in] | sm | scalar membership classifier. |
[out] | leaves | collected leaves. |
|
protected |
Recursively visits SVO nodes to add leaves to the passed output collection.
[in] | pNode | SVO node to visit. |
[in] | sm | scalar membership classifier. |
[out] | leaves | collected leaves. |
[out] | depths | collected leaves' depths. |
[in,out] | depth | the currently reached depth. |
mobiusPoly_EXPORT void mobius::poly_SVO::GetLeaves | ( | std::vector< const poly_SVO * > & | leaves, |
const int | sm = ScalarMembership_OnInOut |
||
) | const |
Gathers all leaves of the octree in the passed vector.
[out] | leaves | gathered collection of leaf SVO nodes. |
[in] | sm | scalar membership to filter SVO nodes by their associated scalar values. |
mobiusPoly_EXPORT unsigned long long mobius::poly_SVO::GetMemoryInBytes | ( | int & | numNodes | ) | const |
Calculates the memory occupied by the SVO hierarchy starting from this node in bytes.
[out] | numNodes | num of corner points. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
mobiusPoly_EXPORT double mobius::poly_SVO::GetScalar | ( | const size_t | id | ) | const |
Returns the scalar value associated with the passed corner ID.
[in] | id | ID of the corner in range [0,7]. |
mobiusPoly_EXPORT bool mobius::poly_SVO::HasScalars | ( | ) |
Checks if the node is initialized with the scalar values. At construction time, the SVO node gets infinity values as scalars. If these values have not been changed later on, this method will return false.
mobiusPoly_EXPORT bool mobius::poly_SVO::IsLeaf | ( | ) | const |
Returns true if this SVO node has no children.
mobiusPoly_EXPORT bool mobius::poly_SVO::IsNegative | ( | ) | const |
Checks if all the scalars associated with this SVO node are negative.
mobiusPoly_EXPORT bool mobius::poly_SVO::IsPositive | ( | ) | const |
Checks if all the scalars associated with this SVO node are positive.
|
static |
Checks if the passed corner ID is valid.
[in] | id | ID to check. |
mobiusPoly_EXPORT bool mobius::poly_SVO::IsZeroCrossing | ( | ) | const |
Checks if the scalars associated with this SVO change sign.
mobiusPoly_EXPORT void mobius::poly_SVO::Release | ( | ) |
Releases the memory occupied by this SVO node with recursive treatment on children.
mobiusPoly_EXPORT void mobius::poly_SVO::SetChild | ( | const size_t | id, |
poly_SVO * | pChild | ||
) |
Sets the child SVO node for the octant having the given index in range [0,7]. This method should be used after Split() invocation to initialize the allocated pointers with the SVO structures constructed separately.
[in] | id | ID of the child to set. |
[in] | pChild | raw pointer to the SVO node to set as a child. |
mobiusPoly_EXPORT void mobius::poly_SVO::SetScalar | ( | const size_t | id, |
const double | s | ||
) |
Sets scalar value for the corner with the passed ID.
[in] | id | ID of the corner in range [0,7]. |
[in] | s | scalar value to set. |
mobiusPoly_EXPORT bool mobius::poly_SVO::Split | ( | ) |
Splits this node down to 8 octants.