Example #1
0
void
Node::insertNode(std::unique_ptr<Node> node)
{
	assert( env->contains(node->getEnvelope()) );

	int index = getSubnodeIndex(node->getEnvelope(), centre);
	assert(index >= 0);

	if (node->level == level-1)
	{
		// We take ownership of node
		delete subnodes[index];
		subnodes[index] = node.release();

		//System.out.println("inserted");
	}
	else
	{
		// the quad is not a direct child, so make a new child
		// quad to contain it and recursively insert the quad
		std::unique_ptr<Node> childNode ( createSubnode(index) );

		// childNode takes ownership of node
		childNode->insertNode(std::move(node));

		// We take ownership of childNode
		delete subnodes[index];
		subnodes[index] = childNode.release();
	}
}
Example #2
0
/**
 * get the subnode for the index.
 * If it doesn't exist, create it
 */
Node*
Node::getSubnode(int index)
{
	if (subnode[index]==NULL) {
		subnode[index]=createSubnode(index);
	}
	return subnode[index];
}
Example #3
0
Node*
Node::getSubnode(int index)
{
	assert(index >=0 && index < 4);
	if (subnodes[index] == nullptr)
	{
		subnodes[index] = createSubnode(index).release();
	}
	return subnodes[index];
}
Example #4
0
void
Node::insert(Node *node)
{
	assert(interval==NULL || interval->contains(node->interval));
	int index=getSubnodeIndex(node->interval,centre);
	assert(index >= 0);
	if (node->level==level-1) {
		subnode[index]=node;
	} else {
		// the node is not a direct child, so make a new child node to contain it
		// and recursively insert the node
		Node* childNode=createSubnode(index);
		childNode->insert(node);
		subnode[index]=childNode;
	}
}
Example #5
0
void Node::insertNode(Node* node) {
	assert(env==NULL || env->contains(node->env));
	//System.out.println(env);
	//System.out.println(quad.env);
	int index=getSubnodeIndex(node->env, centre);
	//System.out.println(index);
	if (node->level==level-1) {
		subnode[index]=node;
		//System.out.println("inserted");
	} else {
		// the quad is not a direct child, so make a new child quad to contain it
		// and recursively insert the quad
		Node *childNode=createSubnode(index);
		childNode->insertNode(node);
		subnode[index]=childNode;
	}
}