Gerris Flow Solver Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
FttDirection ftt_direction_from_name (const |
name : | a direction name. |
Returns : | the index of the direction name or FTT_NEIGHBORS if name is not a valid direction name. |
FttCell* ftt_cell_locate (FttCell *root, FttVector target, |
Locates the cell of the tree defined by root containing target. This is done efficiently in log(n) operations by using the topology of the tree.
typedef enum { FTT_PRE_ORDER, FTT_POST_ORDER } FttTraverseType; |
Controls the sequence in which the traversal is performed.
FTT_PRE_ORDER | Visits the parent cell and then its children. |
FTT_POST_ORDER | Visits each children and then their parent. |
typedef enum { FTT_TRAVERSE_LEAFS = 1 << 0, FTT_TRAVERSE_NON_LEAFS = 1 << 1, FTT_TRAVERSE_LEVEL = 1 << 2, FTT_TRAVERSE_BOUNDARY_FACES = 1 << 3, FTT_TRAVERSE_ALL = FTT_TRAVERSE_LEAFS | FTT_TRAVERSE_NON_LEAFS } FttTraverseFlags; |
Controls the type of cell to visit.
FTT_TRAVERSE_LEAFS | Visits only the cells which are leaves of the cell tree. |
FTT_TRAVERSE_NON_LEAFS | Visits only the cells which are not leaves of the cell tree. |
FTT_TRAVERSE_LEVEL | If FTT_TRAVERSE_LEAFS is also set, visit the leafs of the cell tree and all the cells at level max_depth. If FTT_TRAVERSE_NON_LEAFS is also set, visits only the non-leaf cells at level max_depth. Otherwise, visits all the cells at level max_depth. |
FTT_TRAVERSE_BOUNDARY_FACES | |
FTT_TRAVERSE_ALL | Visits all the cells of the cell tree. |
void (*FttCellTraverseFunc) (FttCell *cell, |
This functions is called by ftt_cell_traverse() for each of the visited cells.
cell : | a FttCell. |
data : | user-data passed to the function. |
void ftt_cell_traverse (FttCell *root, FttTraverseType order, FttTraverseFlags flags, |
Traverses a cell tree starting at the given root FttCell. Calls the given function for each cell visited. */ void ftt_cell_traverse (FttCell * root, FttTraverseType order, FttTraverseFlags flags, gint max_depth, FttCellTraverseFunc func, gpointer data) { g_return_if_fail (root != NULL); g_return_if_fail (func != NULL);
if (max_depth >= 0 && ftt_cell_level (root) > max_depth) return;
if (flags == FTT_TRAVERSE_ALL) { if (order == FTT_PRE_ORDER) cell_traverse_pre_order_all (root, max_depth, func, data); else cell_traverse_post_order_all (root, max_depth, func, data); } else if ((flags & FTT_TRAVERSE_LEVEL) != 0) { if ((flags & FTT_TRAVERSE_LEAFS) != 0) cell_traverse_level_leafs (root, max_depth, func, data); else if ((flags & FTT_TRAVERSE_NON_LEAFS) != 0) cell_traverse_level_non_leafs (root, max_depth, func, data); else cell_traverse_level (root, max_depth, func, data); } else if ((flags & FTT_TRAVERSE_LEAFS) != 0) cell_traverse_leafs (root, max_depth, func, data); else { g_return_if_fail ((flags & FTT_TRAVERSE_NON_LEAFS) != 0);
if (order == FTT_PRE_ORDER) cell_traverse_pre_order_nonleafs (root, max_depth, func, data); else cell_traverse_post_order_nonleafs (root, max_depth, func, data); } }
static void cell_traverse_boundary_pre_order_all (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { FttCell * parent;
if (max_depth >= 0 && ftt_cell_level (cell) > max_depth) return;
parent = ftt_cell_parent (cell); (* func) (cell, data); /* check that cell has not been deallocated by func */ g_assert (parent == NULL || parent->children != NULL);
if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_pre_order_all (children.c[n], d, max_depth, func, data); } }
static void cell_traverse_boundary_post_order_all (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (max_depth >= 0 && ftt_cell_level (cell) > max_depth) return;
if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_post_order_all (children.c[n], d, max_depth, func, data); }
(* func) (cell, data); }
static void cell_traverse_boundary_leafs (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (max_depth >= 0 && ftt_cell_level (cell) > max_depth) return;
if (FTT_CELL_IS_LEAF (cell)) (* func) (cell, data); else { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_leafs (children.c[n], d, max_depth, func, data); } }
static void cell_traverse_boundary_pre_order_nonleafs (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (max_depth >= 0 && ftt_cell_level (cell) > max_depth) return;
if (!FTT_CELL_IS_LEAF (cell)) { FttCell * parent = ftt_cell_parent (cell);
(* func) (cell, data); /* check that cell has not been deallocated by func */ g_assert (parent == NULL || parent->children != NULL); if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_pre_order_nonleafs (children.c[n], d, max_depth, func, data); } } }
static void cell_traverse_boundary_post_order_nonleafs (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (max_depth >= 0 && ftt_cell_level (cell) > max_depth) return;
if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_post_order_nonleafs (children.c[n], d, max_depth, func, data); (* func) (cell, data); } }
static void cell_traverse_boundary_level (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (ftt_cell_level (cell) == max_depth) (* func) (cell, data); else if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_level (children.c[n], d, max_depth, func, data); } }
static void cell_traverse_boundary_level_leafs (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (ftt_cell_level (cell) == max_depth || FTT_CELL_IS_LEAF (cell)) (* func) (cell, data); else if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_level_leafs (children.c[n], d, max_depth, func, data); } }
static void cell_traverse_boundary_level_non_leafs (FttCell * cell, FttDirection d, gint max_depth, FttCellTraverseFunc func, gpointer data) { if (ftt_cell_level (cell) == max_depth && !FTT_CELL_IS_LEAF (cell)) (* func) (cell, data); else if (!FTT_CELL_IS_LEAF (cell)) { FttCellChildren children; guint n;
ftt_cell_children_direction (cell, d, &children); for (n = 0; n < FTT_CELLS/2; n++) if (children.c[n]) cell_traverse_boundary_level_non_leafs (children.c[n], d, max_depth, func, data); } }
/** ftt_cell_traverse_boundary: root: the root FttCell of the tree to traverse. d: the direction of the boundary to traverse. order: the order in which the cells are visited - FTT_PRE_ORDER, FTT_POST_ORDER. flags: which types of children are to be visited. max_depth: the maximum depth of the traversal. Cells below this depth will not be traversed. If max_depth is -1 all cells in the tree are visited. func: the function to call for each visited FttCell. data: user data to pass to func.
Traverses the boundary of a cell tree in direction d starting at the given root FttCell. Calls the given function for each node visited.
root : | the root FttCell of the tree to traverse. |
order : | the order in which the cells are visited - FTT_PRE_ORDER, FTT_POST_ORDER. |
flags : | which types of children are to be visited. |
max_depth : | the maximum depth of the traversal. Cells below this depth will not be traversed. If max_depth is -1 all cells in the tree are visited. |
func : | the function to call for each visited FttCell. |
data : | user data to pass to func. |
void ftt_cell_traverse_boundary (FttCell *root, FttDirection d, FttTraverseType order, FttTraverseFlags flags, |
root : | |
d : | |
order : | |
flags : | |
max_depth : | |
func : | |
data : |
void ftt_cell_traverse_box (FttCell *root, |
Traverses a cell tree starting at the given root FttCell. Calls the given function for each cell visited. Only the cells partly or totally contained within box are visited.
root : | the root FttCell of the tree to traverse. |
box : | a |
order : | the order in which the cells are visited - FTT_PRE_ORDER, FTT_POST_ORDER. |
flags : | which types of children are to be visited. |
max_depth : | the maximum depth of the traversal. Cells below this depth will not be traversed. If max_depth is -1 all cells in the tree are visited. |
func : | the function to call for each visited FttCell. |
data : | user data to pass to func. |
FttCellTraverse* ftt_cell_traverse_new (FttCell *root, FttTraverseType order, FttTraverseFlags flags, |
root : | the root FttCell of the tree to traverse. |
order : | the order in which the cells are visited - FTT_PRE_ORDER, FTT_POST_ORDER. |
flags : | which types of children are to be visited. |
max_depth : | the maximum depth of the traversal. Cells below this depth will not be traversed. If max_depth is -1 all cells in the tree are visited. |
Returns : | a new FttCellTraverse. |
FttCell* ftt_cell_traverse_next (FttCellTraverse *t); |
t : | a FttCellTraverse. |
Returns : | the next cell to visit or NULL if all the cells have been visited. |
void ftt_cell_traverse_rewind (FttCellTraverse *t); |
Sets t at the begining of the traversal.
t : | a FttCellTraverse. |
void ftt_cell_traverse_destroy (FttCellTraverse *t); |
Frees all the memory associated with t.
t : | a FttCellTraverse. |
void ftt_cell_write (const FttCell *root, |
Writes in the file pointed to by fp a text representation of the cell tree starting at root. If not NULL, the user-defined function write is used to write the extra user data associated with each cell.
root : | a FttCell. |
max_depth : | the maximum depth at which to stop writing (-1 means no limit). |
fp : | a file pointer. |
write : | a FttCellWriteFunc function or NULL. |
data : | user data to pass to write. |
void (*FttCellWriteFunc) (const FttCell *cell, |
Writes in fp any user data associated with cell. It is important that this function does not output any newline caracter ('\n').
cell : | a FttCell. |
fp : | a file pointer. |
data : |
FttCell* ftt_cell_read ( |
If an error occurs (i.e. corrupted file or file format incorrect), the error field of fp is set. A possibly incomplete tree is then returned.
fp : | a |
read : | a FttCellReadFunc function or NULL. |
data : | user data to pass to read. |
Returns : | the root cell of the tree contained in the file pointed to by fp. If not NULL, the user-defined function read is used to read the extra user data associated with each cell. |
void (*FttCellReadFunc) (FttCell *cell, |
Reads in any user data associated with cell from file fp and initializes the corresponding fields.
cell : | a FttCell. |
fp : | a file pointer. |
data : |