Пример #1
0
 void kd_free(struct kdtree *tree)
 {
     if(tree){
         kd_clear(tree);
         delete tree;
     }
 }
Пример #2
0
void kd_free(struct kdtree *tree)
{
	if(tree) {
		kd_clear(tree);
		free(tree);
	}
}
Пример #3
0
void updateBoids()
{
	unsigned long j;
	kd_clear(k3);
	for( j=0;j<simParameters.numberOfBoids;j++)
	{
		copyVector(&(boidSet[j].nextPosition), &(boidSet[j].currentPosition));
		copyVector(&(boidSet[j].nextVelocity), &(boidSet[j].currentVelocity));
		
		// kdtree update
		kd_insert3(k3,boidSet[j].currentPosition.x, boidSet[j].currentPosition.y, boidSet[j].currentPosition.z, &boidSet[j]);
	}
}
int opttree_reinitialize (opttree_t *self) {

    // Clear the tree
    GSList *node_curr_list  = self->list_nodes; 
    while (node_curr_list) {
        node_t *node_curr = node_curr_list->data;
        
        opttree_free_node (self, node_curr);

        node_curr_list = g_slist_next (node_curr_list); 
    }

    g_slist_free (self->list_nodes);
    
    self->list_nodes = NULL;

    // Reinitialize the basics
    self->lower_bound = DBL_MAX;
    self->lower_bound_node = NULL;

    // Reinitialize the kdtree
    kd_clear (self->kdtree);

    // Initialize the root node
    self->root = opttree_new_node (self);
    optsystem_get_initial_state (self->optsys, self->root->state);
    self->root->distance_from_root = 0.0;
    self->root->distance_from_parent = 0.0;
    kd_insert (self->kdtree, optsystem_get_state_key (self->optsys, self->root->state), self->root);

    // Initialize the list of all nodes
    self->list_nodes = NULL;
    self->list_nodes = g_slist_prepend (self->list_nodes, (gpointer) (self->root));
    self->num_nodes = 1;

    return 1;
}