Esempio n. 1
0
void Octree::buildFullLeafsVectorAndNeighbourhoodStructure()
{
	if ( !mRoot )
		return;

	int i;
	OctreeNode* node;
	list<OctreeNode*> nodes;

	// Init
	nodes.push_back(mRoot);
	mFullLeafs.clear();
	mBoundsOfFullLeafs[0] = mBounds[1]; // set min x to the max x of the whole tree
	mBoundsOfFullLeafs[1] = mBounds[0]; // set max x to the min x of the whole tree
	mBoundsOfFullLeafs[2] = mBounds[3]; // ...
	mBoundsOfFullLeafs[3] = mBounds[2];
	mBoundsOfFullLeafs[4] = mBounds[5];
	mBoundsOfFullLeafs[5] = mBounds[4];

	while ( nodes.size() )
	{
		node = nodes.back();
		nodes.pop_back();

		if ( node->hasChildren() )
			for ( i = 0 ; i < 8 ; ++i )
				nodes.push_back(node->getChild(i));
		else if ( node->hasData() )
		{
			if ( node->getBounds()[0] < mBoundsOfFullLeafs[0] ) mBoundsOfFullLeafs[0] = node->getBounds()[0];
			if ( node->getBounds()[2] < mBoundsOfFullLeafs[2] ) mBoundsOfFullLeafs[2] = node->getBounds()[2];
			if ( node->getBounds()[4] < mBoundsOfFullLeafs[4] ) mBoundsOfFullLeafs[4] = node->getBounds()[4];

			if ( node->getBounds()[1] > mBoundsOfFullLeafs[1] ) mBoundsOfFullLeafs[1] = node->getBounds()[1];
			if ( node->getBounds()[3] > mBoundsOfFullLeafs[3] ) mBoundsOfFullLeafs[3] = node->getBounds()[3];
			if ( node->getBounds()[5] > mBoundsOfFullLeafs[5] ) mBoundsOfFullLeafs[5] = node->getBounds()[5];

			mFullLeafs.push_back(node);
			this->collectFullNeighbours(node);
		}
	}
	this->sortFullLeafsVector();
}
Esempio n. 2
0
void Octree::buildNeighbourhoodStructure()
{
	if ( !mRoot )
		return;

	int i;
	OctreeNode* node;
	list<OctreeNode*> nodes;
	nodes.push_back(mRoot);

	while ( nodes.size() )
	{
		node = nodes.back();
		nodes.pop_back();

		if ( node->hasChildren() )
			for ( i = 0 ; i < 8 ; ++i )
				nodes.push_back(node->getChild(i));
		else if ( node->hasData() )
			this->collectFullNeighbours(node);
	}
}