Helios++
Helios software for LiDAR simulations
KDTreeFactory Class Referenceabstract

Class that must be extended by any class which provides factory methods for k-dimensional trees. Notice all KDTrees should be instantiated through corresponding factories. More...

#include <KDTreeFactory.h>

Inheritance diagram for KDTreeFactory:
Collaboration diagram for KDTreeFactory:

Public Member Functions

 KDTreeFactory ()
 K dimensional tree factory default constructor.
 
virtual KDTreeFactoryclone () const =0
 Create a clone of the KDTreeFactory. More...
 
virtual KDTreeNodeRootmakeFromPrimitivesUnsafe (vector< Primitive * > &primitives, bool const computeStats=false, bool const reportStats=false)=0
 Build a KDTree from given primitives. More...
 
virtual KDTreeNodeRootmakeFromPrimitives (vector< Primitive * > const &primitives, bool const computeStats=false, bool const reportStats=false)
 Safe wrapper from makeFromPrimitivesUnsafe which handles a copy to make from primitives by default. This function behavior might be overridden by any derived/child class. It is expected that any implementation of makeFromPrimitives provides a way to implement the makeFromPrimitivesUnsafe method without modifying vector of input primitives. Notice this does not mean primitives themselves cannot be modified, that depends on the type of KDTreeFactory. It only means that the vector itself will not be modified, for instance due to sorting purposes. More...
 
virtual bool isBuildingLightNodes ()
 Check if KDTreeFactory is building light nodes. More...
 
virtual void setBuildingLightNodes (bool const buildLightNodes)
 Set KDTreeFactory so it build light nodes (true) or not (false) More...
 
virtual void setChild (LightKDTreeNode *&child, KDTreeNode *node)
 Set child to given node if and only if node is not null. It must be used to assign children nodes in a thread-safe way. More...
 

Protected Member Functions

virtual void lighten (KDTreeNodeRoot *root)
 Rebuild all children of given root KDTree node as LightKDTeeeNode nodes. More...
 
virtual LightKDTreeNode_lighten (KDTreeNode *node)
 Assist KDTreeFactory::lighten function by handling the lighten of a given non-root node. More...
 

Protected Attributes

bool buildLightNodes = true
 When it is true, the KDTreeFactory is expected to build light nodes. It is, built KDTree must have a KDTreeRootNode which children are all LightKDTreeNode. When it is false, KDTreeFactory is allowed to build KDTree with KDTreeNode children, which might require more memory. More...
 
LightKDTreeNodeBlockAllocator lkdtnBlockAllocator
 The block allocator to speed-up lighten of KDTree by reducing allocation calls when instantiating multiple LightKDTreeNode. More...
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize a KDTree factory to a stream of bytes. More...
 

Friends

class boost::serialization::access
 

Detailed Description

Class that must be extended by any class which provides factory methods for k-dimensional trees. Notice all KDTrees should be instantiated through corresponding factories.

Author
Alberto M. Esmoris Pena
Version
1.0
See also
KDTreeNodeRoot

Member Function Documentation

◆ _lighten()

LightKDTreeNode * KDTreeFactory::_lighten ( KDTreeNode node)
protectedvirtual

Assist KDTreeFactory::lighten function by handling the lighten of a given non-root node.

Parameters
nodeNode to be lighten
Returns
Light version of given node
See also
KDTreeFactory::lighten

◆ clone()

virtual KDTreeFactory* KDTreeFactory::clone ( ) const
pure virtual

◆ isBuildingLightNodes()

virtual bool KDTreeFactory::isBuildingLightNodes ( )
inlinevirtual

Check if KDTreeFactory is building light nodes.

Returns
True if KDTreeFactory is building light nodes, false otherwise
See also
KDTreeFactory::buildLightNodes

◆ lighten()

void KDTreeFactory::lighten ( KDTreeNodeRoot root)
protectedvirtual

Rebuild all children of given root KDTree node as LightKDTeeeNode nodes.

Parameters
rootKDTreeRootNode which children must be lighten
See also
KDTreeFactory::buildLightNodes
LightKDTreeNode
KDTreeNode
KDTreeRootNode

◆ makeFromPrimitives()

virtual KDTreeNodeRoot* KDTreeFactory::makeFromPrimitives ( vector< Primitive * > const &  primitives,
bool const  computeStats = false,
bool const  reportStats = false 
)
inlinevirtual

Safe wrapper from makeFromPrimitivesUnsafe which handles a copy to make from primitives by default. This function behavior might be overridden by any derived/child class. It is expected that any implementation of makeFromPrimitives provides a way to implement the makeFromPrimitivesUnsafe method without modifying vector of input primitives. Notice this does not mean primitives themselves cannot be modified, that depends on the type of KDTreeFactory. It only means that the vector itself will not be modified, for instance due to sorting purposes.

See also
KDTreeFactory::makeFromPrimitivesUnsafe

◆ makeFromPrimitivesUnsafe()

virtual KDTreeNodeRoot* KDTreeFactory::makeFromPrimitivesUnsafe ( vector< Primitive * > &  primitives,
bool const  computeStats = false,
bool const  reportStats = false 
)
pure virtual

Build a KDTree from given primitives.

Parameters
primitivesPrimitives to build KDTree splitting them
computeStatsIf true, KDTree stats will be computed. If false, they will not
reportStatsIf true, KDTree stats will be reported. If false, they will not. Notice stats can only be reported if computeStats flag is setted to true too.
Returns
Pointer to root node of built KDTree

Implemented in SimpleKDTreeFactory, and MultiThreadKDTreeFactory.

◆ serialize()

template<class Archive >
void KDTreeFactory::serialize ( Archive &  ar,
const unsigned int  version 
)
inlineprivate

Serialize a KDTree factory to a stream of bytes.

Template Parameters
ArchiveType of rendering
Parameters
arSpecific rendering for the stream of bytes
versionVersion number for the K dimensional tree factory

◆ setBuildingLightNodes()

virtual void KDTreeFactory::setBuildingLightNodes ( bool const  buildLightNodes)
inlinevirtual

Set KDTreeFactory so it build light nodes (true) or not (false)

Parameters
buildLightNodesTrue to build light nodes, false to don't
See also
KDTreeFactory::buildLightNodes

◆ setChild()

virtual void KDTreeFactory::setChild ( LightKDTreeNode *&  child,
KDTreeNode node 
)
inlinevirtual

Set child to given node if and only if node is not null. It must be used to assign children nodes in a thread-safe way.

When using a multi thread like KDTree factory, nullptr is used as a place holder for asynchronous node building tasks. But it might happen that built node is assigned before the place holder, so it will be substituted by nullptr and built node will be lost. This setter is specifically designed to prevent this scenario.

Parameters
childReference to child pointer to be setted
nodeNew value for the child pointer. If it is nullptr, then no set will be done.
See also
MultiThreadKDTreeFactory
MultiThreadSAHKDTreeFactory

Member Data Documentation

◆ buildLightNodes

bool KDTreeFactory::buildLightNodes = true
protected

When it is true, the KDTreeFactory is expected to build light nodes. It is, built KDTree must have a KDTreeRootNode which children are all LightKDTreeNode. When it is false, KDTreeFactory is allowed to build KDTree with KDTreeNode children, which might require more memory.

See also
KDTreeFactory::lighten

◆ lkdtnBlockAllocator

LightKDTreeNodeBlockAllocator KDTreeFactory::lkdtnBlockAllocator
protected

The block allocator to speed-up lighten of KDTree by reducing allocation calls when instantiating multiple LightKDTreeNode.

See also
LightKDTreeNodeBlockAllocator
KDTreeFactory::lighten

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