Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_trees.c File Reference

tree functions More...

#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_str.h"
#include "nilorea/n_trees.h"
+ Include dependency graph for n_trees.c:

Go to the source code of this file.

Functions

int compare_double (COORD_VALUE a, COORD_VALUE b)
 double comparison functions
 
int compare_float (COORD_VALUE a, COORD_VALUE b)
 float comparison function
 
int compare_int (COORD_VALUE a, COORD_VALUE b)
 int comparison function
 
QUADTREE_NODEcreate_node (COORD_VALUE x, COORD_VALUE y, void *data_ptr)
 function to create a new quad tree node
 
OCTREEcreate_octree (int type)
 Create a new OCTREE with a specified coordinate type.
 
OCTREE_NODEcreate_octree_node (POINT3D point, void *data_ptr)
 create and OCTREE node
 
QUADTREEcreate_quadtree (int coord_type)
 Function to create a new quad tree.
 
int determine_octant (POINT3D point, POINT3D center, int type)
 function to determine the octant for the given point relative to the node
 
void free_octree (OCTREE *octree)
 free the OCTREE
 
void free_octree_node (OCTREE_NODE *node)
 recursive function to free an OCTREE node and its children
 
void free_quadtree (QUADTREE_NODE *root)
 Function to free the quad tree.
 
void insert (QUADTREE *qt, QUADTREE_NODE **root, COORD_VALUE x, COORD_VALUE y, void *data_ptr)
 Function to insert a point into the quad tree.
 
void insert_octree (OCTREE *octree, POINT3D point, void *data_ptr)
 Insert a point into the OCTREE.
 
void insert_octree_node (OCTREE_NODE *node, POINT3D point, void *data_ptr, int type)
 recursive function to insert a point into the OCTREE
 
TREEnew_tree ()
 create a new TREE
 
void print_double (COORD_VALUE val)
  
 
void print_float (COORD_VALUE val)
  
 
void print_int (COORD_VALUE val)
  
 
QUADTREE_NODEsearch (QUADTREE *qt, QUADTREE_NODE *root, COORD_VALUE x, COORD_VALUE y)
 Function to search for a point in the quad tree.
 
TREE_NODEtree_create_node (NODE_DATA value, void(*destroy_func)(void *ptr))
 create a TREE node
 
int tree_delete_node (TREE *tree, TREE_NODE *node)
 delete a TREE node
 
void tree_destroy (TREE **tree)
 destroy a TREE
 
int tree_insert_child (TREE_NODE *parent, TREE_NODE *child)
 insert a child node into the parent node
 

Detailed Description

tree functions

Author
Castagnier Mickael
Version
1.0
Date
07/08/2024

Definition in file n_trees.c.

Function Documentation

◆ compare_double()

int compare_double ( COORD_VALUE  a,
COORD_VALUE  b 
)

double comparison functions

Parameters
aCOORD_VALUE double element to compare
bCOORD_VALUE double element to compare
Returns
TRUE or FALSE

Definition at line 173 of file n_trees.c.

Referenced by create_quadtree().

+ Here is the caller graph for this function:

◆ compare_float()

int compare_float ( COORD_VALUE  a,
COORD_VALUE  b 
)

float comparison function

Parameters
aCOORD_VALUE float element to compare
bCOORD_VALUE float element to compare
Returns
TRUE or FALSE

Definition at line 163 of file n_trees.c.

Referenced by create_quadtree().

+ Here is the caller graph for this function:

◆ compare_int()

int compare_int ( COORD_VALUE  a,
COORD_VALUE  b 
)

int comparison function

Parameters
aCOORD_VALUE int element to compare
bCOORD_VALUE int element to compare
Returns
TRUE or FALSE

Definition at line 153 of file n_trees.c.

Referenced by create_quadtree().

+ Here is the caller graph for this function:

◆ determine_octant()

int determine_octant ( POINT3D  point,
POINT3D  center,
int  type 
)

function to determine the octant for the given point relative to the node

Parameters
pointPOINT3D coordinates of the target point
centerPOINT3D coordinates of the center point
typethe type of coordinate used by the OCTREE (COORD_INT,COORD_FLOAT,COORD_DOUBLE)
Returns
TRUE or FALSE

Definition at line 354 of file n_trees.c.

References POINT3D::x, POINT3D::y, and POINT3D::z.

Referenced by insert_octree_node().

+ Here is the caller graph for this function:

◆ insert_octree_node()

void insert_octree_node ( OCTREE_NODE node,
POINT3D  point,
void *  data_ptr,
int  type 
)

recursive function to insert a point into the OCTREE

Parameters
nodethe target OCTREE_NODE *node
pointthe POINT3D point to insert
data_ptreventual private data forthe point, can be NULL
typethe type of coordinate used by the OCTREE (COORD_INT,COORD_FLOAT,COORD_DOUBLE)

Definition at line 379 of file n_trees.c.

References OCTREE_NODE::children, create_octree_node(), determine_octant(), insert_octree_node(), and OCTREE_NODE::point.

Referenced by insert_octree(), and insert_octree_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_double()

void print_double ( COORD_VALUE  val)

 

print double function

Parameters
valthe COORD_VALUE from which to read the double to print

Definition at line 198 of file n_trees.c.

Referenced by create_quadtree().

+ Here is the caller graph for this function:

◆ print_float()

void print_float ( COORD_VALUE  val)

 

print float function

Parameters
valthe COORD_VALUE from which to read the float to print

Definition at line 190 of file n_trees.c.

Referenced by create_quadtree().

+ Here is the caller graph for this function:

◆ print_int()

void print_int ( COORD_VALUE  val)

 

print int function

Parameters
valthe COORD_VALUE from which to read the int to print

Definition at line 181 of file n_trees.c.

Referenced by create_quadtree().

+ Here is the caller graph for this function: