BRL-CAD

Structures and routines for collecting and manipulating paths through the database tree. More...

Collaboration diagram for Full Paths:

Files

file  db_fp.h
 
file  db_fullpath.h
 

Data Structures

struct  db_fp_pool
 
struct  db_fp
 
struct  db_full_path
 

Macros

#define DB_FP_STR_BOOL   0x1 /* boolean labels flag */
 
#define DB_FP_STR_TYPE   0x2 /* object type flag */
 
#define DB_FP_STR_MATRIX   0x4 /* matrix flag */
 
#define RT_CK_FULL_PATH(_p)   BU_CKMAG(_p, DB_FULL_PATH_MAGIC, "db_full_path")
 
#define DB_FULL_PATH_CUR_DIR(_pp)   (((_pp)->fp_len > 0) ? (_pp)->fp_names[(_pp)->fp_len-1] : NULL)
 
#define DB_FULL_PATH_CUR_BOOL(_pp)   ((_pp)->fp_bool[(_pp)->fp_len-1])
 
#define DB_FULL_PATH_SET_CUR_BOOL(_pp, _i)   ((_pp)->fp_bool[(_pp)->fp_len-1]) = _i
 
#define DB_FULL_PATH_LEN(_pp)   ((_pp)->fp_len)
 
#define DB_FULL_PATH_POP(_pp)   ((_pp)->fp_len > 0) ? (_pp)->fp_len-- : (_pp)->fp_len
 
#define DB_FULL_PATH_GET(_pp, _i)   ((_pp)->fp_names[(_i)])
 
#define DB_FULL_PATH_GET_BOOL(_pp, _i)   ((_pp)->fp_bool[(_i)])
 
#define DB_FULL_PATH_SET_BOOL(_pp, _i, _j)   ((_pp)->fp_bool[(_i)] = _j)
 
#define DB_FULL_PATH_ROOT_DIR(_pp)   ((_pp)->fp_names[0])
 
#define DB_FP_PRINT_BOOL   0x1 /* print boolean operations */
 
#define DB_FP_PRINT_TYPE   0x2 /* print object types */
 
#define DB_FP_PRINT_MATRIX   0x4 /* print notice that a matrix is present */
 

Functions

int db_fp_pool_init (struct db_fp_pool *p)
 
int db_fp_pool_create (struct db_fp_pool **p)
 
void db_fp_pool_gc (struct db_fp_pool *p)
 
void db_fp_pool_clear (struct db_fp_pool *p)
 
void db_fp_pool_destroy (struct db_fp_pool *p)
 
struct db_fpdb_fp_create (struct db_fp_pool *p)
 
void db_fp_destroy (struct db_fp *fp)
 
size_t db_fp_len (struct db_fp *fp)
 
void db_fp_pop (struct db_fp *fp)
 
void db_fp_push (struct db_fp *dest, const struct db_fp *src, size_t start_offset)
 
int db_fp_append (struct db_fp *fp, struct directory *dp, db_op_t op, mat_t mat)
 
int db_fp_set (struct db_fp *fp, int i, struct directory *dp, db_op_t op, mat_t mat)
 
void db_fp_cpy (struct db_fp *curr_fp, const struct db_fp *old_fp)
 
struct directorydb_fp_get_dir (const struct db_fp *fp, int index)
 
db_op_t db_fp_get_bool (const struct db_fp *fp, int index)
 
matp_t db_fp_get_mat (const struct db_fp *fp, int index)
 
void db_fp_push_data (struct db_fp *fp, void *data)
 
void * db_fp_get_data (struct db_fp *fp)
 
void db_fp_pop_data (struct db_fp *fp)
 
void db_fp_push_node_data (struct db_fp *fp, int index, void *data)
 
void * db_fp_get_node_data (struct db_fp *fp, int index)
 
void db_fp_pop_node_data (struct db_fp *fp, int index)
 
char * db_fp_to_str (const struct db_fp *fp, int flags)
 
void db_fp_to_vls (struct bu_vls *v, const struct db_fp *fp, int flags)
 
int db_str_to_fp (struct db_fp **fp, const struct db_i *dbip, const char *str, struct db_fp_pool *p)
 
int db_argv_to_fp (struct db_fp **fp, const struct db_i *dbip, int argc, const char *const *argv, struct db_fp_pool *p)
 
int db_fp_identical (const struct db_fp *a, const struct db_fp *b)
 
int db_fp_identical_solid (const struct db_fp *a, const struct db_fp *b)
 
int db_fp_match (const struct db_fp *a, const struct db_fp *b, unsigned int skip_first, int leaf_to_root)
 
int db_fp_search (const struct db_fp *p, const char *n, unsigned int skip_first, int leaf_to_root)
 
void db_fp_eval_mat (mat_t mat, const struct db_fp *fp, unsigned int depth)
 
void db_full_path_init (struct db_full_path *pathp)
 
void db_add_node_to_full_path (struct db_full_path *pp, struct directory *dp)
 
void db_dup_full_path (struct db_full_path *newp, const struct db_full_path *oldp)
 
void db_extend_full_path (struct db_full_path *pathp, size_t incr)
 
void db_append_full_path (struct db_full_path *dest, const struct db_full_path *src)
 
void db_dup_path_tail (struct db_full_path *newp, const struct db_full_path *oldp, b_off_t start)
 
char * db_path_to_string (const struct db_full_path *pp)
 
void db_path_to_vls (struct bu_vls *str, const struct db_full_path *pp)
 
void db_fullpath_to_vls (struct bu_vls *vls, const struct db_full_path *full_path, const struct db_i *dbip, int fp_flags)
 
void db_pr_full_path (const char *msg, const struct db_full_path *pathp)
 
int db_string_to_path (struct db_full_path *pp, const struct db_i *dbip, const char *str)
 
int db_argv_to_path (struct db_full_path *pp, struct db_i *dbip, int argc, const char *const *argv)
 
void db_free_full_path (struct db_full_path *pp)
 
int db_identical_full_paths (const struct db_full_path *a, const struct db_full_path *b)
 
int db_full_path_subset (const struct db_full_path *a, const struct db_full_path *b, const int skip_first)
 
int db_full_path_match_top (const struct db_full_path *a, const struct db_full_path *b)
 
int db_full_path_search (const struct db_full_path *a, const struct directory *dp)
 
int db_full_path_cyclic (const struct db_full_path *fp, const char *lname, int full_check)
 
int db_path_to_mat (struct db_i *dbip, struct db_full_path *pathp, mat_t mat, int depth, struct resource *resp)
 
void db_full_path_color (struct bu_color *c, struct db_full_path *pathp, struct db_i *dbip, struct resource *resp)
 

Detailed Description

Structures and routines for collecting and manipulating paths through the database tree.

Macro Definition Documentation

◆ DB_FP_STR_BOOL

#define DB_FP_STR_BOOL   0x1 /* boolean labels flag */

Definition at line 157 of file db_fp.h.

◆ DB_FP_STR_TYPE

#define DB_FP_STR_TYPE   0x2 /* object type flag */

Definition at line 158 of file db_fp.h.

◆ DB_FP_STR_MATRIX

#define DB_FP_STR_MATRIX   0x4 /* matrix flag */

Definition at line 159 of file db_fp.h.

◆ RT_CK_FULL_PATH

#define RT_CK_FULL_PATH (   _p)    BU_CKMAG(_p, DB_FULL_PATH_MAGIC, "db_full_path")

Definition at line 62 of file db_fullpath.h.

◆ DB_FULL_PATH_CUR_DIR

#define DB_FULL_PATH_CUR_DIR (   _pp)    (((_pp)->fp_len > 0) ? (_pp)->fp_names[(_pp)->fp_len-1] : NULL)

Definition at line 64 of file db_fullpath.h.

◆ DB_FULL_PATH_CUR_BOOL

#define DB_FULL_PATH_CUR_BOOL (   _pp)    ((_pp)->fp_bool[(_pp)->fp_len-1])

Definition at line 65 of file db_fullpath.h.

◆ DB_FULL_PATH_SET_CUR_BOOL

#define DB_FULL_PATH_SET_CUR_BOOL (   _pp,
  _i 
)    ((_pp)->fp_bool[(_pp)->fp_len-1]) = _i

Definition at line 66 of file db_fullpath.h.

◆ DB_FULL_PATH_LEN

#define DB_FULL_PATH_LEN (   _pp)    ((_pp)->fp_len)

Definition at line 68 of file db_fullpath.h.

◆ DB_FULL_PATH_POP

#define DB_FULL_PATH_POP (   _pp)    ((_pp)->fp_len > 0) ? (_pp)->fp_len-- : (_pp)->fp_len

Definition at line 69 of file db_fullpath.h.

◆ DB_FULL_PATH_GET

#define DB_FULL_PATH_GET (   _pp,
  _i 
)    ((_pp)->fp_names[(_i)])

Definition at line 71 of file db_fullpath.h.

◆ DB_FULL_PATH_GET_BOOL

#define DB_FULL_PATH_GET_BOOL (   _pp,
  _i 
)    ((_pp)->fp_bool[(_i)])

Definition at line 72 of file db_fullpath.h.

◆ DB_FULL_PATH_SET_BOOL

#define DB_FULL_PATH_SET_BOOL (   _pp,
  _i,
  _j 
)    ((_pp)->fp_bool[(_i)] = _j)

Definition at line 73 of file db_fullpath.h.

◆ DB_FULL_PATH_ROOT_DIR

#define DB_FULL_PATH_ROOT_DIR (   _pp)    ((_pp)->fp_names[0])

Definition at line 75 of file db_fullpath.h.

◆ DB_FP_PRINT_BOOL

#define DB_FP_PRINT_BOOL   0x1 /* print boolean operations */

Append a string representation of the path onto the vls, with options to decorate nodes with additional information.

Definition at line 124 of file db_fullpath.h.

◆ DB_FP_PRINT_TYPE

#define DB_FP_PRINT_TYPE   0x2 /* print object types */

Definition at line 125 of file db_fullpath.h.

◆ DB_FP_PRINT_MATRIX

#define DB_FP_PRINT_MATRIX   0x4 /* print notice that a matrix is present */

Definition at line 126 of file db_fullpath.h.

Function Documentation

◆ db_fp_pool_init()

int db_fp_pool_init ( struct db_fp_pool p)

◆ db_fp_pool_create()

int db_fp_pool_create ( struct db_fp_pool **  p)

◆ db_fp_pool_gc()

void db_fp_pool_gc ( struct db_fp_pool p)

◆ db_fp_pool_clear()

void db_fp_pool_clear ( struct db_fp_pool p)

◆ db_fp_pool_destroy()

void db_fp_pool_destroy ( struct db_fp_pool p)

◆ db_fp_create()

struct db_fp * db_fp_create ( struct db_fp_pool p)

◆ db_fp_destroy()

void db_fp_destroy ( struct db_fp fp)

◆ db_fp_len()

size_t db_fp_len ( struct db_fp fp)

◆ db_fp_pop()

void db_fp_pop ( struct db_fp fp)

◆ db_fp_push()

void db_fp_push ( struct db_fp dest,
const struct db_fp src,
size_t  start_offset 
)

◆ db_fp_append()

int db_fp_append ( struct db_fp fp,
struct directory dp,
db_op_t  op,
mat_t  mat 
)

◆ db_fp_set()

int db_fp_set ( struct db_fp fp,
int  i,
struct directory dp,
db_op_t  op,
mat_t  mat 
)

◆ db_fp_cpy()

void db_fp_cpy ( struct db_fp curr_fp,
const struct db_fp old_fp 
)

◆ db_fp_get_dir()

struct directory * db_fp_get_dir ( const struct db_fp fp,
int  index 
)

◆ db_fp_get_bool()

db_op_t db_fp_get_bool ( const struct db_fp fp,
int  index 
)

◆ db_fp_get_mat()

matp_t db_fp_get_mat ( const struct db_fp fp,
int  index 
)

◆ db_fp_push_data()

void db_fp_push_data ( struct db_fp fp,
void *  data 
)

◆ db_fp_get_data()

void * db_fp_get_data ( struct db_fp fp)

◆ db_fp_pop_data()

void db_fp_pop_data ( struct db_fp fp)

◆ db_fp_push_node_data()

void db_fp_push_node_data ( struct db_fp fp,
int  index,
void *  data 
)

◆ db_fp_get_node_data()

void * db_fp_get_node_data ( struct db_fp fp,
int  index 
)

◆ db_fp_pop_node_data()

void db_fp_pop_node_data ( struct db_fp fp,
int  index 
)

◆ db_fp_to_str()

char * db_fp_to_str ( const struct db_fp fp,
int  flags 
)

◆ db_fp_to_vls()

void db_fp_to_vls ( struct bu_vls v,
const struct db_fp fp,
int  flags 
)

◆ db_str_to_fp()

int db_str_to_fp ( struct db_fp **  fp,
const struct db_i dbip,
const char *  str,
struct db_fp_pool p 
)

◆ db_argv_to_fp()

int db_argv_to_fp ( struct db_fp **  fp,
const struct db_i dbip,
int  argc,
const char *const *  argv,
struct db_fp_pool p 
)

◆ db_fp_identical()

int db_fp_identical ( const struct db_fp a,
const struct db_fp b 
)

◆ db_fp_identical_solid()

int db_fp_identical_solid ( const struct db_fp a,
const struct db_fp b 
)

◆ db_fp_match()

int db_fp_match ( const struct db_fp a,
const struct db_fp b,
unsigned int  skip_first,
int  leaf_to_root 
)

◆ db_fp_search()

int db_fp_search ( const struct db_fp p,
const char *  n,
unsigned int  skip_first,
int  leaf_to_root 
)

◆ db_fp_eval_mat()

void db_fp_eval_mat ( mat_t  mat,
const struct db_fp fp,
unsigned int  depth 
)

◆ db_full_path_init()

void db_full_path_init ( struct db_full_path pathp)

◆ db_add_node_to_full_path()

void db_add_node_to_full_path ( struct db_full_path pp,
struct directory dp 
)

◆ db_dup_full_path()

void db_dup_full_path ( struct db_full_path newp,
const struct db_full_path oldp 
)

◆ db_extend_full_path()

void db_extend_full_path ( struct db_full_path pathp,
size_t  incr 
)

Extend "pathp" so that it can grow from current fp_len by incr more names.

This is intended primarily as an internal method.

◆ db_append_full_path()

void db_append_full_path ( struct db_full_path dest,
const struct db_full_path src 
)

◆ db_dup_path_tail()

void db_dup_path_tail ( struct db_full_path newp,
const struct db_full_path oldp,
b_off_t  start 
)

Dup old path from starting index to end.

◆ db_path_to_string()

char * db_path_to_string ( const struct db_full_path pp)

Unlike rt_path_str(), this version can be used in parallel. Caller is responsible for freeing the returned buffer.

◆ db_path_to_vls()

void db_path_to_vls ( struct bu_vls str,
const struct db_full_path pp 
)

Append a string representation of the path onto the vls. Must have exactly the same formatting conventions as db_path_to_string().

◆ db_fullpath_to_vls()

void db_fullpath_to_vls ( struct bu_vls vls,
const struct db_full_path full_path,
const struct db_i dbip,
int  fp_flags 
)

◆ db_pr_full_path()

void db_pr_full_path ( const char *  msg,
const struct db_full_path pathp 
)

◆ db_string_to_path()

int db_string_to_path ( struct db_full_path pp,
const struct db_i dbip,
const char *  str 
)

Reverse the effects of db_path_to_string().

The db_full_path structure will be initialized. If it was already in use, user should call db_free_full_path() first.

Returns - -1 One or more components of path did not exist in the directory. 0 OK

◆ db_argv_to_path()

int db_argv_to_path ( struct db_full_path pp,
struct db_i dbip,
int  argc,
const char *const *  argv 
)

Treat elements from argv[0] to argv[argc-1] as a path specification.

The path structure will be fully initialized. If it was already in use, user should call db_free_full_path() first.

Returns - -1 One or more components of path did not exist in the directory. 0 OK

◆ db_free_full_path()

void db_free_full_path ( struct db_full_path pp)

Free the contents of the db_full_path structure, but not the structure itself, which might be automatic.

◆ db_identical_full_paths()

int db_identical_full_paths ( const struct db_full_path a,
const struct db_full_path b 
)

Returns - 1 match 0 different

◆ db_full_path_subset()

int db_full_path_subset ( const struct db_full_path a,
const struct db_full_path b,
const int  skip_first 
)

Returns - 1 if 'b' is a proper subset of 'a' 0 if not.

◆ db_full_path_match_top()

int db_full_path_match_top ( const struct db_full_path a,
const struct db_full_path b 
)

Returns - 1 if 'a' matches the top part of 'b' 0 if not.

For example, /a/b matches both the top part of /a/b/c and /a/b.

◆ db_full_path_search()

int db_full_path_search ( const struct db_full_path a,
const struct directory dp 
)

Returns - 1 'dp' is found on this path 0 not found

◆ db_full_path_cyclic()

int db_full_path_cyclic ( const struct db_full_path fp,
const char *  lname,
int  full_check 
)

Function to test whether a path has a cyclic entry in it.

Parameters
fp[i] Full path to test
lname[i] String to use when checking path (optional). If NULL, use the name of the current directory pointer in fp.
full_check[i] Flag to instruct the cyclic test to check using all directory pointers in fp, not just the lname/current dp test.
Returns
1 if the path is cyclic, 0 if it is not.

By default, only the leaf (or test_name if supplied) will be used to test if the path is cyclic. If full_check is set, all object names in the path will be checked, as well as lname if set. This more expensive check is not necessary if calling code is checking for cyclic paths as paths are being built, but is necessary to fully "clear" a db_full_path from an arbitrary source. Calling code must use its knowledge of the origins of the full path (or lack thereof) to determine how much validation work is needed.

◆ db_path_to_mat()

int db_path_to_mat ( struct db_i dbip,
struct db_full_path pathp,
mat_t  mat,
int  depth,
struct resource resp 
)

Build the transformation matrix obtained when traversing the path to the specified depth.

Returns - 1 OK, path matrix written into 'mat'. 0 FAIL

Called in librt/db_tree.c, mged/dodraw.c, and mged/animedit.c

◆ db_full_path_color()

void db_full_path_color ( struct bu_color c,
struct db_full_path pathp,
struct db_i dbip,
struct resource resp 
)

Determine the color operative at the current directory pointer (the leaf node) of the path according to available information and rules.

If nothing can be determined default color is set.