BRL-CAD
Collaboration diagram for Database4:

Files

file  db_comb.c
 
file  db_alloc.c
 
file  db_flags.c
 
file  db_io.c
 
file  db_scan.c
 

Macros

#define STAT_ROT   1
 
#define STAT_XLATE   2
 
#define STAT_PERSP   4
 
#define STAT_SCALE   8
 
#define DEBUG_PR(aaa, rrr)
 

Functions

size_t db_tree_nleaves (const union tree *tp)
 
struct rt_tree_arraydb_flatten_tree (struct rt_tree_array *rt_tree_array, union tree *tp, int op, int freeflag, struct resource *resp)
 
int rt_comb_import4 (struct rt_db_internal *ip, const struct bu_external *ep, const mat_t matrix, const struct db_i *dbip, struct resource *resp)
 
int rt_comb_export4 (struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip, struct resource *resp)
 
void db_tree_flatten_describe (struct bu_vls *vls, const union tree *tp, int indented, int lvl, double mm2local, struct resource *resp)
 
void db_tree_describe (struct bu_vls *vls, const union tree *tp, int indented, int lvl, double mm2local)
 
void db_comb_describe (struct bu_vls *str, const struct rt_comb_internal *comb, int verbose, double mm2local, struct resource *resp)
 
void rt_comb_ifree (struct rt_db_internal *ip)
 
int rt_comb_describe (struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local, struct resource *resp, struct db_i *dbip)
 
void db_wrap_v4_external (struct bu_external *op, const char *name)
 
int db_ck_left_heavy_tree (const union tree *tp, int no_unions)
 
int db_ck_v4gift_tree (const union tree *tp)
 
union treedb_mkbool_tree (struct rt_tree_array *rt_tree_array, size_t howfar, struct resource *resp)
 
union treedb_mkgift_tree (struct rt_tree_array *trees, size_t subtreecount, struct resource *resp)
 
int rt_comb_get_color (unsigned char rgb[3], const struct rt_comb_internal *comb)
 
int db_comb_mvall (struct directory *dp, struct db_i *dbip, const char *old_name, const char *new_name, struct bu_ptbl *stack)
 
int db_alloc (register struct db_i *dbip, register struct directory *dp, size_t count)
 
int db_delrec (struct db_i *dbip, register struct directory *dp, int recnum)
 
int db_delete (struct db_i *dbip, struct directory *dp)
 
int db_zapper (struct db_i *dbip, struct directory *dp, size_t start)
 
void db_alloc_directory_block (struct resource *resp)
 
void rt_alloc_seg_block (register struct resource *res)
 
int db_flags_internal (const struct rt_db_internal *intern)
 
int db_flags_raw_internal (const struct db5_raw_internal *raw)
 
HIDDEN int db_read (const struct db_i *dbip, void *addr, size_t count, off_t offset)
 
union record * db_getmrec (const struct db_i *dbip, const struct directory *dp)
 
int db_get (const struct db_i *dbip, const struct directory *dp, union record *where, off_t offset, size_t len)
 
int db_write (struct db_i *dbip, const void *addr, size_t count, off_t offset)
 
int db_put (struct db_i *dbip, const struct directory *dp, union record *where, off_t offset, size_t len)
 
int db_get_external (register struct bu_external *ep, const struct directory *dp, const struct db_i *dbip)
 
int db_put_external (struct bu_external *ep, struct directory *dp, struct db_i *dbip)
 
int db_fwrite_external (FILE *fp, const char *name, struct bu_external *ep)
 
int db_scan (struct db_i *dbip, int(*handler)(struct db_i *, const char *, off_t, size_t, int, void *), int do_old_matter, void *client_data)
 
int db_update_ident (struct db_i *dbip, const char *new_title, double local2mm)
 
int db_fwrite_ident (FILE *fp, const char *title, double local2mm)
 
void db_conversions (struct db_i *dbip, int local)
 
int db_v4_get_units_code (const char *str)
 

Detailed Description

Macro Definition Documentation

#define STAT_ROT   1

Definition at line 54 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define STAT_XLATE   2

Definition at line 55 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define STAT_PERSP   4

Definition at line 56 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define STAT_SCALE   8

Definition at line 57 of file db_comb.c.

Referenced by db_tree_describe(), and db_tree_flatten_describe().

#define DEBUG_PR (   aaa,
  rrr 
)
Value:
{\
if (RT_G_DEBUG&DEBUG_DB) bu_log("db_scan %ld %c (0%o)\n", \
aaa, rrr.u_id, rrr.u_id); }
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
if(share_geom)
Definition: nmg_mod.c:3829
#define RT_G_DEBUG
Definition: raytrace.h:1718
#define DEBUG_DB
5 Database debugging
Definition: raytrace.h:88

Definition at line 44 of file db_scan.c.

Referenced by db_scan().

Function Documentation

size_t db_tree_nleaves ( const union tree tp)

Return count of number of leaf nodes in this tree.

Definition at line 99 of file db_comb.c.

References bu_bomb(), bu_log(), OP_DB_LEAF, OP_GUARD, OP_INTERSECT, OP_NOP, OP_NOT, OP_REGION, OP_SOLID, OP_SUBTRACT, OP_UNION, OP_XNOP, OP_XOR, RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tr_b, and TREE_NULL.

Referenced by _ged_combadd2(), _ged_print_node(), db_tree_flatten_describe(), f_nnodes(), ged_get_comb(), mk_tree_gift(), rt_comb_export4(), tables_new(), and write_comb().

Here is the call graph for this function:

struct rt_tree_array* db_flatten_tree ( struct rt_tree_array rt_tree_array,
union tree tp,
int  op,
int  avail,
struct resource resp 
)

Take a binary tree in "V4-ready" layout (non-unions pushed below unions, left-heavy), and flatten it into an array layout, ready for conversion back to the GIFT-inspired V4 database format.

This is done using the db_non_union_push() routine.

If argument 'free' is non-zero, then the non-leaf nodes are freed along the way, to prevent memory leaks. In this case, the caller's copy of 'tp' will be invalid upon return.

When invoked at the very top of the tree, the op argument must be OP_UNION.

Definition at line 138 of file db_comb.c.

References bu_bomb(), bu_log(), OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, RT_CK_RESOURCE, RT_CK_TREE, RT_FREE_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, rt_tree_array::tl_op, rt_tree_array::tl_tree, tree::tr_b, and TREE_NULL.

Referenced by _ged_combadd2(), _ged_print_node(), db_tree_flatten_describe(), ged_get_comb(), mk_tree_gift(), rt_comb_export4(), tables_new(), and write_comb().

Here is the call graph for this function:

int rt_comb_import4 ( struct rt_db_internal ip,
const struct bu_external ep,
const mat_t  matrix,
const struct db_i dbip,
struct resource resp 
)
void db_tree_flatten_describe ( struct bu_vls vls,
const union tree tp,
int  indented,
int  lvl,
double  mm2local,
struct resource resp 
)

Produce a GIFT-compatible listing, one "member" per line, regardless of the structure of the tree we've been given.

Definition at line 568 of file db_comb.c.

References bn_ae_vec(), bn_mat_identity, BU_ASSERT_LONG, BU_ASSERT_PTR, bu_bomb(), bu_calloc(), BU_CK_VLS, bu_free(), bu_vls_printf(), bu_vls_spaces(), bu_vls_strcat(), db_ck_v4gift_tree(), db_dup_subtree(), db_flatten_tree(), db_free_tree(), db_non_union_push(), DB_OP_INTERSECT, DB_OP_SUBTRACT, DB_OP_UNION, db_tree_nleaves(), OP_DB_LEAF, OP_INTERSECT, OP_NOP, OP_SUBTRACT, OP_UNION, RT_CK_RESOURCE, RT_CK_TREE, STAT_PERSP, STAT_ROT, STAT_SCALE, STAT_XLATE, tree::tree_db_leaf::tl_mat, tree::tree_db_leaf::tl_name, rt_tree_array::tl_tree, and tree::tr_l.

Referenced by db_comb_describe().

Here is the call graph for this function:

void db_tree_describe ( struct bu_vls vls,
const union tree tp,
int  indented,
int  lvl,
double  mm2local 
)
void db_comb_describe ( struct bu_vls str,
const struct rt_comb_internal comb,
int  verbose,
double  mm2local,
struct resource resp 
)
void rt_comb_ifree ( struct rt_db_internal ip)

Free the storage associated with the rt_db_internal version of this combination.

Definition at line 844 of file db_comb.c.

References bu_free(), db_free_tree(), rt_db_internal::idb_ptr, if(), RT_CK_DB_INTERNAL, RT_FREE_COMB_INTERNAL, rt_uniresource, and rt_comb_internal::tree.

Here is the call graph for this function:

int rt_comb_describe ( struct bu_vls str,
const struct rt_db_internal ip,
int  verbose,
double  mm2local,
struct resource resp,
struct db_i db_i 
)

OBJ[ID_COMBINATION].ft_describe() method

Definition at line 862 of file db_comb.c.

References db_comb_describe(), rt_db_internal::idb_ptr, RT_CK_COMB, RT_CK_DB_INTERNAL, RT_CK_DBI, and RT_CK_RESOURCE.

Here is the call graph for this function:

void db_wrap_v4_external ( struct bu_external op,
const char *  name 
)

As the v4 database does not really have the notion of "wrapping", this function writes the object name into the proper place (a standard location in all granules).

Definition at line 885 of file db_comb.c.

References BU_CK_EXTERNAL, and bu_external::ext_buf.

Referenced by db_fwrite_external(), db_put_external(), nmg_stash_model_to_file(), wdb_export_external(), and wdb_put_internal().

int db_ck_left_heavy_tree ( const union tree tp,
int  no_unions 
)

Support routine for db_ck_v4gift_tree(). Ensure that the tree below 'tp' is left-heavy, i.e. that there are nothing but solids on the right side of any binary operations.

Returns - -1 ERROR 0 OK

Definition at line 898 of file db_comb.c.

References bu_bomb(), bu_log(), OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, and tree::tr_b.

Referenced by db_ck_v4gift_tree().

Here is the call graph for this function:

int db_ck_v4gift_tree ( const union tree tp)

Look a gift-tree in the mouth.

Ensure that this boolean tree conforms to the GIFT convention that union operations must bind the loosest.

There are two stages to this check: 1) Ensure that if unions are present they are all at the root of tree, 2) Ensure non-union children of union nodes are all left-heavy (nothing but solid nodes permitted on rhs of binary operators).

Returns - -1 ERROR 0 OK

Definition at line 927 of file db_comb.c.

References bu_bomb(), bu_log(), db_ck_left_heavy_tree(), OP_DB_LEAF, OP_INTERSECT, OP_SUBTRACT, OP_UNION, OP_XOR, RT_CK_TREE, tree::tree_node::tb_left, tree::tree_node::tb_right, and tree::tr_b.

Referenced by _ged_combadd2(), _ged_print_node(), db_tree_flatten_describe(), ged_get_comb(), main(), mk_tree_gift(), rt_comb_export4(), tables_new(), and write_comb().

Here is the call graph for this function:

union tree* db_mkbool_tree ( struct rt_tree_array rt_tree_array,
size_t  howfar,
struct resource resp 
)

Given a rt_tree_array array, build a tree of "union tree" nodes appropriately connected together. Every element of the rt_tree_array array used is replaced with a TREE_NULL. Elements which are already TREE_NULL are ignored. Returns a pointer to the top of the tree.

Definition at line 954 of file db_comb.c.

References bu_log(), DEBUG_TREEWALK, OP_UNION, RT_CK_RESOURCE, RT_G_DEBUG, RT_GET_TREE, tree::tree_node::tb_left, tree::tree_node::tb_regionp, tree::tree_node::tb_right, rt_tree_array::tl_op, rt_tree_array::tl_tree, tree::tr_b, and TREE_NULL.

Referenced by db_mkgift_tree().

Here is the call graph for this function:

union tree* db_mkgift_tree ( struct rt_tree_array trees,
size_t  subtreecount,
struct resource resp 
)

Definition at line 1016 of file db_comb.c.

References BU_ASSERT_SIZE_T, bu_log(), db_mkbool_tree(), DEBUG_TREEWALK, OP_UNION, RT_CK_RESOURCE, RT_G_DEBUG, rt_pr_tree(), and rt_tree_array::tl_op.

Referenced by _ged_combadd2(), build_comb(), mk_tree_gift(), and rt_comb_import4().

Here is the call graph for this function:

int rt_comb_get_color ( unsigned char  rgb[3],
const struct rt_comb_internal comb 
)

fills in rgb with the color for a given comb combination

returns truthfully if a color could be got

Definition at line 1077 of file db_comb.c.

References rt_comb_internal::region_id, rt_comb_internal::rgb, rt_comb_internal::rgb_valid, RT_CK_COMB, and rt_material_head().

Here is the call graph for this function:

int db_comb_mvall ( struct directory dp,
struct db_i dbip,
const char *  old_name,
const char *  new_name,
struct bu_ptbl stack 
)

change all matching object names in the comb tree from old_name to new_name

calling function must supply an initialized bu_ptbl, and free it once done.

Definition at line 1107 of file db_comb.c.

References bu_free(), BU_PTBL_END, BU_PTBL_GET, bu_ptbl_ins(), bu_ptbl_reset(), bu_ptbl_rm(), BU_STR_EQUAL, bu_strdup, directory::d_flags, rt_db_internal::idb_ptr, if(), OP_DB_LEAF, rt_db_free_internal(), rt_db_get_internal(), rt_db_put_internal(), RT_DIR_COMB, rt_uniresource, tree::tree_node::tb_left, tree::tree_node::tb_right, tree::tree_db_leaf::tl_name, tree::tr_b, tree::tr_l, and rt_comb_internal::tree.

Referenced by comb_lift_region(), and move_all_func().

Here is the call graph for this function:

int db_alloc ( register struct db_i dbip,
register struct directory dp,
size_t  count 
)

Find a block of database storage of "count" granules.

Returns: 0 OK non-0 failure

Definition at line 46 of file db_alloc.c.

References bu_log(), bu_malloc(), bu_realloc(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_get(), db_zapper(), db_i::dbi_eof, db_i::dbi_freep, db_i::dbi_nrec, db_i::dbi_read_only, DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, RT_G_DEBUG, and rt_memalloc().

Here is the call graph for this function:

int db_delrec ( struct db_i dbip,
register struct directory dp,
int  recnum 
)

Delete a specific record from database entry No longer supported.

Definition at line 109 of file db_alloc.c.

References bu_log(), directory::d_namep, DEBUG_DB, RT_CK_DBI, RT_CK_DIR, and RT_G_DEBUG.

Here is the call graph for this function:

int db_delete ( struct db_i dbip,
struct directory dp 
)

Delete the indicated database record(s). Arrange to write "free storage" database markers in its place, positively erasing what had been there before.

Returns: 0 on success non-zero on failure

Definition at line 132 of file db_alloc.c.

References bu_bomb(), bu_free(), bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db5_write_free(), db_version(), db_zapper(), db_i::dbi_freep, DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, RT_G_DEBUG, and rt_memfree().

Referenced by color_zaprec(), comb_flatten(), db_put_external(), ged_kill(), and killtree_callback().

Here is the call graph for this function:

int db_zapper ( struct db_i dbip,
struct directory dp,
size_t  start 
)

Using a single call to db_put(), write multiple zeroed records out, all with u_id field set to ID_FREE. This will zap all records from "start" to the end of this entry.

Returns: 0 on success (from db_put()) non-zero on failure

Definition at line 174 of file db_alloc.c.

References BU_ASSERT_LONG, bu_bomb(), bu_free(), bu_log(), bu_malloc(), directory::d_flags, directory::d_len, directory::d_namep, db_put(), db_i::dbi_read_only, db_i::dbi_version, DEBUG_DB, memset(), RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, and RT_G_DEBUG.

Referenced by db_alloc(), and db_delete().

Here is the call graph for this function:

void db_alloc_directory_block ( struct resource resp)

This routine is called by the RT_GET_DIRECTORY macro when the freelist is exhausted. Rather than simply getting one additional structure, we get a whole batch, saving overhead.

Definition at line 211 of file db_alloc.c.

References BU_ASSERT_PTR, bu_calloc(), BU_CK_PTBL, BU_FLSTR, bu_malloc_len_roundup(), bu_ptbl_ins(), directory::d_forw, directory::d_magic, resource::re_directory_blocks, resource::re_directory_hd, RT_CK_RESOURCE, and RT_DIR_MAGIC.

Here is the call graph for this function:

void rt_alloc_seg_block ( register struct resource res)

Definition at line 239 of file db_alloc.c.

References BU_LIST_INIT, BU_LIST_INSERT, BU_LIST_IS_INITIALIZED, bu_malloc(), bu_malloc_len_roundup(), bu_ptbl_init(), bu_ptbl_ins(), seg::l, bu_list::magic, resource::re_seg, resource::re_seg_blocks, resource::re_seglen, RT_CK_RESOURCE, and RT_SEG_MAGIC.

Here is the call graph for this function:

int db_flags_internal ( const struct rt_db_internal intern)

Given the internal form of a database object, return the appropriate 'flags' word for stashing in the in-memory directory of objects.

Definition at line 43 of file db_flags.c.

References ID_COMBINATION, rt_db_internal::idb_ptr, rt_comb_internal::region_flag, RT_CK_COMB, RT_CK_DB_INTERNAL, RT_DIR_COMB, RT_DIR_REGION, and RT_DIR_SOLID.

Referenced by nmg_stash_model_to_file(), and wdb_put_internal().

int db_flags_raw_internal ( const struct db5_raw_internal *  intern)

Given a database object in "raw" internal form, return the appropriate 'flags' word for stashing in the in-memory directory of objects.

Definition at line 61 of file db_flags.c.

References bu_avs_get(), bu_avs_init_empty(), bu_attribute_value_set::count, db5_import_attributes(), RT_DIR_COMB, RT_DIR_NON_GEOM, RT_DIR_REGION, and RT_DIR_SOLID.

Here is the call graph for this function:

HIDDEN int db_read ( const struct db_i dbip,
void *  addr,
size_t  count,
off_t  offset 
)

Reads 'count' bytes at file offset 'offset' into buffer at 'addr'. A wrapper for the UNIX read() sys-call that takes into account syscall semaphores, stdio-only machines, and in-memory buffering.

Returns - 0 OK -1 FAILURE

Definition at line 52 of file db_io.c.

References bu_bomb(), bu_fseek(), bu_log(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), db_i::dbi_eof, db_i::dbi_filename, db_i::dbi_fp, db_i::dbi_inmem, DEBUG_DB, RT_CK_DBI, and RT_G_DEBUG.

Referenced by db_get(), db_get_external(), and db_getmrec().

Here is the call graph for this function:

union record* db_getmrec ( const struct db_i ,
const struct directory dp 
)

Retrieve all records in the database pertaining to an object, and place them in malloc()'ed storage, which the caller is responsible for free()'ing.

This loads the combination into a local record buffer. This is in external v4 format.

Returns - union record * - OK (union record *)0 - FAILURE

Definition at line 97 of file db_io.c.

References bu_free(), bu_log(), bu_malloc(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_read(), db_i::dbi_version, DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, and RT_G_DEBUG.

Referenced by db_functree(), and db_preorder_traverse().

Here is the call graph for this function:

int db_get ( const struct db_i ,
const struct directory dp,
union record *  where,
off_t  offset,
size_t  len 
)

Retrieve 'len' records from the database, "offset" granules into this entry.

Returns - 0 OK -1 FAILURE

Definition at line 134 of file db_io.c.

References bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_read(), DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, and RT_G_DEBUG.

Referenced by db_alloc(), and db_update_ident().

Here is the call graph for this function:

int db_write ( struct db_i dbip,
const void *  addr,
size_t  count,
off_t  offset 
)

Definition at line 170 of file db_io.c.

References bu_fseek(), bu_log(), bu_restore_interrupts(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), bu_suspend_interrupts(), db_i::dbi_filename, db_i::dbi_fp, db_i::dbi_inmem, db_i::dbi_read_only, DEBUG_DB, RT_CK_DBI, and RT_G_DEBUG.

Referenced by db5_write_free(), db_put(), db_put_external(), db_put_external5(), and rt_db_put_internal5().

Here is the call graph for this function:

int db_put ( struct db_i ,
const struct directory dp,
union record *  where,
off_t  offset,
size_t  len 
)

Store 'len' records to the database, "offset" granules into this entry.

Returns: 0 OK non-0 FAILURE

Definition at line 212 of file db_io.c.

References bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_write(), db_i::dbi_filename, db_i::dbi_read_only, DEBUG_DB, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, and RT_G_DEBUG.

Referenced by color_putrec(), db_update_ident(), and db_zapper().

Here is the call graph for this function:

int db_get_external ( register struct bu_external ep,
const struct directory dp,
const struct db_i dbip 
)

Definition at line 248 of file db_io.c.

References BU_EXTERNAL_INIT, bu_free(), bu_log(), bu_malloc(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_read(), db_i::dbi_version, DEBUG_DB, bu_external::ext_buf, bu_external::ext_nbytes, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, and RT_G_DEBUG.

Here is the call graph for this function:

int db_put_external ( struct bu_external ep,
struct directory dp,
struct db_i dbip 
)

Given that caller already has an external representation of the database object, update it to have a new name (taken from dp->d_namep) in that external representation, and write the new object into the database, obtaining different storage if the size has changed.

Caller is responsible for freeing memory of external representation, using bu_free_external().

This routine is used to efficiently support MGED's "cp" and "keep" commands, which don't need to import objects just to rename and copy them.

Returns - <0 error 0 success

Definition at line 281 of file db_io.c.

References bu_bomb(), BU_CK_EXTERNAL, bu_log(), directory::d_flags, directory::d_len, directory::d_namep, directory::d_un, db_alloc(), db_delete(), db_put_external5(), db_version(), db_wrap_v4_external(), db_write(), db_i::dbi_filename, db_i::dbi_read_only, DEBUG_DB, bu_external::ext_buf, bu_external::ext_nbytes, directory::ptr, RT_CK_DBI, RT_CK_DIR, RT_DIR_INMEM, RT_DIR_PHONY_ADDR, and RT_G_DEBUG.

Referenced by db5_update_ident(), ged_hide(), ged_unhide(), rt_db_put_internal(), and wdb_export_external().

Here is the call graph for this function:

int db_fwrite_external ( FILE *  fp,
const char *  name,
struct bu_external ep 
)

Add name from dp->d_namep to external representation of solid, and write it into a file.

Caller is responsible for freeing memory of external representation, using bu_free_external().

The 'name' field of the external representation is modified to contain the desired name. The 'ep' parameter cannot be const.

THIS ROUTINE ONLY SUPPORTS WRITING V4 GEOMETRY.

Returns - <0 error 0 OK

NOTE: Callers of this should be using wdb_export_external() instead.

Definition at line 337 of file db_io.c.

References BU_CK_EXTERNAL, bu_fwrite_external(), bu_log(), db_wrap_v4_external(), DEBUG_DB, and RT_G_DEBUG.

Referenced by rt_fwrite_internal().

Here is the call graph for this function:

int db_scan ( struct db_i dbip,
int(*)(struct db_i *, const char *, off_t, size_t, int, void *)  handler,
int  do_old_matter,
void *  client_data 
)

This routine sequentially reads through the model database file and builds a directory of the object names, to allow rapid named access to objects.

Note that some multi-record database items include length fields. These length fields are not used here. Instead, the sizes of multi-record items are determined by reading ahead and computing the actual size. This prevents difficulties arising from external "adjustment" of the number of records without corresponding adjustment of the length fields. In the future, these length fields will be phased out.

The handler will be called with a variety of args. The handler is responsible for handling name strings of exactly NAMESIZE chars. The most common example of such a function is db_diradd().

Note that the handler may do I/O, including repositioning the file pointer, so this must be taken into account.

Returns - 0 Success -1 Fatal Error

Definition at line 73 of file db_scan.c.

References bu_fseek(), bu_ftell(), bu_log(), BU_STR_EQUAL, bu_strdup, db_conversions(), db_i::dbi_eof, db_i::dbi_fp, db_i::dbi_freep, db_i::dbi_nrec, db_i::dbi_title, db_i::dbi_version, DEBUG_DB, DEBUG_PR, flip_short(), RT_CK_DBI, rt_color_addrec(), RT_DIR_COMB, RT_DIR_REGION, RT_DIR_SOLID, RT_G_DEBUG, and rt_memfree().

Here is the call graph for this function:

int db_update_ident ( struct db_i dbip,
const char *  new_title,
double  local2mm 
)

Update the existing v4 IDENT record with new title and units. To permit using db_get and db_put, a custom directory entry is crafted.

Note: Special care is required, because the "title" arg may actually be passed in as dbip->dbi_title.

Definition at line 367 of file db_scan.c.

References bu_free(), bu_log(), bu_strdup, bu_strlcpy, bu_units_string(), directory::d_flags, directory::d_len, directory::d_magic, db5_update_ident(), db_get(), db_put(), db_v4_get_units_code(), db_version(), db_i::dbi_read_only, db_i::dbi_title, DEBUG_DB, RT_CK_DBI, RT_DIR_MAGIC, RT_DIR_SET_NAMEP, and RT_G_DEBUG.

Referenced by ged_keep(), ged_title(), ged_units(), and mk_id_editunits().

Here is the call graph for this function:

int db_fwrite_ident ( FILE *  fp,
const char *  title,
double  local2mm 
)

Fwrite an IDENT record with given title and editing scale. Attempts to map the editing scale into a v4 database unit as best it can. No harm done if it doesn't map.

This should be called by db_create() only. All others should call db_update_ident().

Returns - 0 Success -1 Fatal Error

Definition at line 446 of file db_scan.c.

References bu_log(), bu_strlcpy, bu_units_string(), code(), db_v4_get_units_code(), DEBUG_DB, memset(), and RT_G_DEBUG.

Referenced by db_create().

Here is the call graph for this function:

void db_conversions ( struct db_i ,
int  units 
)

Initialize conversion factors given the v4 database unit

Definition at line 468 of file db_scan.c.

References db_i::dbi_base2local, db_i::dbi_local2base, and RT_CK_DBI.

Referenced by db_scan().

int db_v4_get_units_code ( const char *  str)

Given a string, return the V4 database code representing the user's preferred editing units. The v4 database format does not have many choices.

Returns - -1 Not a legal V4 database code

The V4 database code number

Definition at line 535 of file db_scan.c.

References BU_STR_EQUAL.

Referenced by db_fwrite_ident(), and db_update_ident().