FANDOM


Octree

ImageNets Octree

Point Clouds in ImageNets are stored in Octrees. Octrees have the advantage over lists that search is very fast.

How to use an Octree Edit

Initialization Edit

CImage::CLayer::COctree* pOctree = new CImage::CLayer::COctree();
pOctree->setMinRadius( 0.01 );
pOctree->setMaxRadius( 8.0 );


Add a colored 3D point Edit

pOctree->addPoint( QColor( r, g, b ).rgb(), x, y, z );


Save the Octree in port 0 Edit

setOctree( pOctree, 0, 0 );


Search in the Octree Edit

You have to write a recursive function, e.g.

void recursiveFunction(COctLeaf* pParent, float parentX, float ParentY, float parentZ, float parentRadius)

CImage::CLayer::COctree::COctBranch* pBranch = dynamic_cast<
	CImage::CLayer::COctree::COctBranch*>( pParent );

if( pBranch == 0 ) //This is a leaf
{
	//You reached a leaf of the tree, do something with it
	//You reached a leaf of the tree, do something with it
	//You reached a leaf of the tree, do something with it
	
	return;
}
else  //This is a branch --> search deeper
{
	//Do something here with the branch
	//Do something here with the branch
	//Do something here with the branch


	//Next: go deeper into the tree!

	double childRadius = parentRadius / 2;
	
	//Call recursively for all 8 children
	if( pBranch->pChildren[0] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[0],
			parentX + childRadius, parentY + childRadius,
			parentZ + childRadius, childRadius );
	}
	if( pBranch->pChildren[1] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[1],
			parentX + childRadius, parentY + childRadius,
			parentZ - childRadius, childRadius );
	}
	if( pBranch->pChildren[2] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[2],
			parentX + childRadius, parentY - childRadius,
			parentZ + childRadius, childRadius );
	}
	if( pBranch->pChildren[3] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[3],
			parentX + childRadius, parentY - childRadius,
			parentZ - childRadius, childRadius );
	}
	if( pBranch->pChildren[4] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[4],
			parentX - childRadius, parentY + childRadius,
			parentZ + childRadius, childRadius );
	}
	if( pBranch->pChildren[5] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[5],
			parentX - childRadius, parentY + childRadius,
			parentZ - childRadius, childRadius );
	}
	if( pBranch->pChildren[6] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[6],
			parentX - childRadius, parentY - childRadius,
			parentZ + childRadius, childRadius );
	}
	if( pBranch->pChildren[7] != 0 )
	{
		//Recursive call
		recursiveFunction( pBranch->pChildren[7],
			parentX - childRadius, parentY - childRadius,
			parentZ - childRadius, childRadius );
	}
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.