iMSTK
Interactive Medical Simulation Toolkit
Public Member Functions | Public Attributes | Friends | List of all members
imstk::OctreeNode Class Reference

The OctreeNode class. More...

#include <imstkLooseOctree.h>

Collaboration diagram for imstk::OctreeNode:
Collaboration graph
[legend]

Public Member Functions

 OctreeNode (const OctreeNode &)=delete
 
OctreeNodeoperator= (const OctreeNode &)=delete
 
 OctreeNode ()
 Dummy constructor, called only during memory allocation in memory pool.
 
 OctreeNode (LooseOctree *const tree, OctreeNode *const pParent, const Vec3d &nodeCenter, const double halfWidth, const uint32_t depth)
 OctreeNode constructor, called during node splitting when initializing children node.
 
bool isLeaf () const
 Check if this node is a leaf node.
 
OctreeNodegetChildNode (const uint32_t childIdx) const
 Get a child node. More...
 
OctreePrimitivegetPrimitiveList (const OctreePrimitiveType type) const
 For the given primitive type, return the head node of the primitive list of that type.
 
uint32_t getPrimitiveCount (const OctreePrimitiveType type) const
 Get the number of primitives of the given type in this node.
 
const Vec6d getBounds ()
 Get the bounds of the node.
 
const Vec6d getLooseBounds ()
 Get the loose bounds of the node.
 
void clearPrimitiveData (const OctreePrimitiveType type)
 Recursively clear primitive data (linked lists and counters) Note that the primitives are still exist in the octree primitive list, they are just removed from the node. More...
 
void split ()
 Split node (requesting 8 children nodes from memory pool)
 
void removeAllDescendants ()
 Recursively remove all descendant nodes (return them back to memory pool) As a result, after calling to this function, the current node will become a leaf node.
 
void removeEmptyDescendants ()
 Recursively remove all descendant nodes that do not contain primitives (all 8 children of a node are removed at the same time)
 
void keepPrimitive (OctreePrimitive *const pPrimitive, const OctreePrimitiveType type)
 Keep the primitive at this node as cannot pass it down further to any child node.
 
void insertPoint (OctreePrimitive *const pPrimitive)
 Insert a point primitive into the subtree in a top-down manner.
 
void insertNonPointPrimitive (OctreePrimitive *const pPrimitive, const OctreePrimitiveType type)
 Insert a non-point primitive into the subtree in a top-down manner.
 
bool contains (const Vec3d &point)
 Check if the given point is contained exactly in the node boundary (bounding box)
 
bool contains (const std::array< double, 3 > &point)
 
bool contains (const double x, const double y, const double z)
 
bool contains (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &upperCorner)
 Check if the given non-point primitive (triangle/analytical geometry) is exactly contained in the node boundary (bounding box) More...
 
bool looselyContains (const Vec3d &point)
 Check if the given point is contained in the node loose boundary (which is 2X bigger than the bounding box)
 
bool looselyContains (const std::array< double, 3 > &point)
 
bool looselyContains (const double x, const double y, const double z)
 
bool looselyContains (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &upperCorner)
 Check if the given non-point primitive (triangle/analytical geometry) is contained in the node loose boundary (which is 2X bigger than the bounding box) More...
 
bool looselyOverlaps (const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &upperCorner)
 Check if the bounding box of the given primitive (triangle/analytical geometry) overlaps with the loose boundary of this tree node (which is 2X bigger than the bounding box) More...
 

Public Attributes

LooseOctreem_pTree
 Pointer to the octree, used to request children from memory pool during splitting node.
 
OctreeNodem_pParent
 Pointer to the parent node.
 
OctreeNodeBlockm_pChildren = nullptr
 Pointer to a memory block containing 8 children nodes.
 
const Vec3d m_Center
 Center of this node.
 
const Vec3d m_LowerBound
 The AABB's lower corner of the node.
 
const Vec3d m_UpperBound
 The AABB's upper corner of the node.
 
const Vec3d m_LowerExtendedBound
 The extended AABB's lower corner of the node, which is 2X bigger than the exact AABB.
 
const Vec3d m_UpperExtendedBound
 The extended AABB's upper corner of the node, which is 2X bigger than the exact AABB.
 
const double m_HalfWidth
 Half width of the node AABB.
 
const uint32_t m_Depth
 Depth of this node (depth > 0, depth = 1 starting at the root node)
 
uint32_t m_MaxDepth
 Cache the max depth of the tree (maximum depth level possible)
 
bool m_bIsLeaf = true
 True if this node does not have any child node (a node should have either 0 or 8 children)
 
OctreePrimitivem_pPrimitiveListHeads [OctreePrimitiveType::NumPrimitiveTypes]
 Heads of the link lists storing (Classified) primitives.
 
uint32_t m_PrimitiveCounts [OctreePrimitiveType::NumPrimitiveTypes]
 Count the number of (classified) primitives stored in this node.
 
ParallelUtils::SpinLock m_PrimitiveLock [OctreePrimitiveType::NumPrimitiveTypes]
 Mutex lock for thread-safe primitive list modification.
 
ParallelUtils::SpinLock m_NodeSplitingLock
 Mutex lock for thread-safe splitting node.
 

Friends

class LooseOctree
 
class OctreeBasedCD
 
class LooseOctreeTest
 

Detailed Description

The OctreeNode class.

Definition at line 83 of file imstkLooseOctree.h.

Member Function Documentation

◆ clearPrimitiveData()

void imstk::OctreeNode::clearPrimitiveData ( const OctreePrimitiveType  type)

Recursively clear primitive data (linked lists and counters) Note that the primitives are still exist in the octree primitive list, they are just removed from the node.

Parameters
typeThe type of primitives that will be clear

Definition at line 44 of file imstkLooseOctree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains()

bool imstk::OctreeNode::contains ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  upperCorner 
)
inline

Check if the given non-point primitive (triangle/analytical geometry) is exactly contained in the node boundary (bounding box)

Parameters
lowerCornerThe AABB's lower corner of the primitive
upperCornerThe AABB's upper corner of the primitive

Definition at line 209 of file imstkLooseOctree.h.

◆ getChildNode()

OctreeNode * imstk::OctreeNode::getChildNode ( const uint32_t  childIdx) const

Get a child node.

Parameters
childIdxThe index of child node (from 0 to 7)

Definition at line 35 of file imstkLooseOctree.cpp.

◆ looselyContains()

bool imstk::OctreeNode::looselyContains ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  upperCorner 
)
inline

Check if the given non-point primitive (triangle/analytical geometry) is contained in the node loose boundary (which is 2X bigger than the bounding box)

Parameters
lowerCornerThe AABB's lower corner of the primitive
upperCornerThe AABB's upper corner of the primitive

Definition at line 240 of file imstkLooseOctree.h.

◆ looselyOverlaps()

bool imstk::OctreeNode::looselyOverlaps ( const std::array< double, 3 > &  lowerCorner,
const std::array< double, 3 > &  upperCorner 
)
inline

Check if the bounding box of the given primitive (triangle/analytical geometry) overlaps with the loose boundary of this tree node (which is 2X bigger than the bounding box)

Parameters
lowerCornerThe AABB's lower corner of the primitive
upperCornerThe AABB's upper corner of the primitive

Definition at line 256 of file imstkLooseOctree.h.


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