ASCOT5
|
Header file for octree.c. More...
Go to the source code of this file.
Data Structures | |
struct | octree_node |
Struct representing single octree node. More... | |
Typedefs | |
typedef struct octree_node | octree_node |
Struct representing single octree node. | |
Functions | |
void | octree_create (octree_node **node, real x_min, real x_max, real y_min, real y_max, real z_min, real z_max, int depth) |
Create octree of given depth. | |
void | octree_free (octree_node **node) |
Free octree node and all its child nodes. | |
void | octree_add (octree_node *node, real t1[3], real t2[3], real t3[3], int id) |
Add triangle to the node(s) it belongs to. | |
list_int_node * | octree_get (octree_node *node, real p[3]) |
Get that leaf node's linked list the given coordinate belongs to. | |
typedef struct octree_node octree_node |
Struct representing single octree node.
Stores eight child nodes, bounding box of the volume this node encloses, and a linked list containing IDs of triangles belonging to this node.
void octree_create | ( | octree_node ** | node, |
real | x_min, | ||
real | x_max, | ||
real | y_min, | ||
real | y_max, | ||
real | z_min, | ||
real | z_max, | ||
int | depth ) |
Create octree of given depth.
This function creates recursively a complete octree hierarchy with given number of levels. Each node have bounding box asigned and there is a small overlap between the boxes to avoid numerical artifact where a point is exactly between two boxes but belongs to neither.
The linked lists on leaf nodes are initialized.
node | pointer to parent node from which the octree sprawls |
x_min | minimum x coordinate of the parent node |
x_max | maximum x coordinate of the parent node |
y_min | minimum y coordinate of the parent node |
y_max | maximum y coordinate of the parent node |
z_min | minimum z coordinate of the parent node |
z_max | maximum z coordinate of the parent node |
depth | levels of octree nodes to be created. If depth=1, this node will be a leaf node. Final volume will be 1/8^(depth-1) th of the initial volume. |
void octree_free | ( | octree_node ** | node | ) |
void octree_add | ( | octree_node * | node, |
real | t1[3], | ||
real | t2[3], | ||
real | t3[3], | ||
int | id ) |
Add triangle to the node(s) it belongs to.
This function uses recursion to travel the octree and find all leaf nodes the given triangle belongs to.In other words, at each step this function determines the child node(s) the triangle belongs to and calls this function for that/those node(s).
node | octree node to which or to which child nodes triangle is added to |
t1 | triangle first vertex xyz coordinates |
t2 | triangle second vertex xyz coordinates |
t3 | triangle third vertex xyz coordinates |
id | triangle id which is stored in the node(s) the triangle belongs to |
list_int_node * octree_get | ( | octree_node * | node, |
real | p[3] ) |
Get that leaf node's linked list the given coordinate belongs to.
This function uses recursion to travel through the octree, determining at each step the correct branch to follow next until the leaf node is found. In other words, at each step this function determines the child node the point belongs to and calls this function for that node.
The point is assumed to belong to the volume of the node used in the argument.
node | octree node that is traversed |
p | xyz coordinates of the point |