BRL-CAD
wdb.h File Reference
#include "common.h"
#include "vmath.h"
#include "bu/magic.h"
#include "bu/list.h"
#include "bu/vls.h"
#include "bu/observer.h"
#include "rt/db_instance.h"
#include "rt/tree.h"
Include dependency graph for wdb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rt_wdb
 

Macros

#define RT_WDB_TYPE_DB_DEFAULT   0
 
#define RT_WDB_TYPE_DB_DEFAULT_APPEND_ONLY   1
 
#define RT_WDB_TYPE_DB_DISK   2
 
#define RT_WDB_TYPE_DB_DISK_APPEND_ONLY   3
 
#define RT_WDB_TYPE_DB_INMEM   4
 
#define RT_WDB_TYPE_DB_INMEM_APPEND_ONLY   5
 
#define RT_CHECK_WDB(_p)   BU_CKMAG(_p, RT_WDB_MAGIC, "rt_wdb")
 
#define RT_CK_WDB(_p)   RT_CHECK_WDB(_p)
 
#define RT_WDB_INIT_ZERO   { {RT_WDB_MAGIC, BU_LIST_NULL, BU_LIST_NULL}, 0, NULL, RT_DBTS_INIT_ZERO, BG_TESS_TOL_INIT_ZERO, BN_TOL_INIT_ZERO, NULL, BU_VLS_INIT_ZERO, 0, 0, 0, 0, 0, 0, BU_VLS_INIT_ZERO, BU_OBSERVER_LIST_INIT_ZERO, NULL }
 
#define RT_WDB_NULL   ((struct rt_wdb *)NULL)
 

Functions

struct rt_wdbwdb_fopen (const char *filename)
 
struct rt_wdbwdb_fopen_v (const char *filename, int version)
 
struct rt_wdbwdb_dbopen (struct db_i *dbip, int mode)
 
int wdb_import (struct rt_wdb *wdbp, struct rt_db_internal *internp, const char *name, const mat_t mat)
 
int wdb_export_external (struct rt_wdb *wdbp, struct bu_external *ep, const char *name, int flags, unsigned char minor_type)
 
int wdb_put_internal (struct rt_wdb *wdbp, const char *name, struct rt_db_internal *ip, double local2mm)
 
int wdb_export (struct rt_wdb *wdbp, const char *name, void *gp, int id, double local2mm)
 
void wdb_init (struct rt_wdb *wdbp, struct db_i *dbip, int mode)
 
void wdb_close (struct rt_wdb *wdbp)
 
int wdb_import_from_path (struct bu_vls *logstr, struct rt_db_internal *ip, const char *path, struct rt_wdb *wdb)
 
int wdb_import_from_path2 (struct bu_vls *logstr, struct rt_db_internal *ip, const char *path, struct rt_wdb *wdb, matp_t matp)
 

Macro Definition Documentation

◆ RT_WDB_TYPE_DB_DEFAULT

#define RT_WDB_TYPE_DB_DEFAULT   0

Definition at line 48 of file wdb.h.

◆ RT_WDB_TYPE_DB_DEFAULT_APPEND_ONLY

#define RT_WDB_TYPE_DB_DEFAULT_APPEND_ONLY   1

Definition at line 49 of file wdb.h.

◆ RT_WDB_TYPE_DB_DISK

#define RT_WDB_TYPE_DB_DISK   2

Definition at line 50 of file wdb.h.

◆ RT_WDB_TYPE_DB_DISK_APPEND_ONLY

#define RT_WDB_TYPE_DB_DISK_APPEND_ONLY   3

Definition at line 51 of file wdb.h.

◆ RT_WDB_TYPE_DB_INMEM

#define RT_WDB_TYPE_DB_INMEM   4

Definition at line 52 of file wdb.h.

◆ RT_WDB_TYPE_DB_INMEM_APPEND_ONLY

#define RT_WDB_TYPE_DB_INMEM_APPEND_ONLY   5

Definition at line 53 of file wdb.h.

◆ RT_CHECK_WDB

#define RT_CHECK_WDB (   _p)    BU_CKMAG(_p, RT_WDB_MAGIC, "rt_wdb")

Definition at line 89 of file wdb.h.

◆ RT_CK_WDB

#define RT_CK_WDB (   _p)    RT_CHECK_WDB(_p)

Definition at line 90 of file wdb.h.

◆ RT_WDB_INIT_ZERO

Definition at line 91 of file wdb.h.

◆ RT_WDB_NULL

#define RT_WDB_NULL   ((struct rt_wdb *)NULL)

Definition at line 92 of file wdb.h.

Function Documentation

◆ wdb_fopen()

struct rt_wdb * wdb_fopen ( const char *  filename)

Routines to allow libwdb to use librt's import/export interface, rather than having to know about the database formats directly.

◆ wdb_fopen_v()

struct rt_wdb * wdb_fopen_v ( const char *  filename,
int  version 
)

Create a libwdb output stream destined for a disk file. This will destroy any existing file by this name, and start fresh. The file is then opened in the normal "update" mode and an in-memory directory is built along the way, allowing retrievals and object replacements as needed.

The rt_wdb type returned is RT_WDB_TYPE_DB_DISK.

Users can change the database title by calling: ???

◆ wdb_dbopen()

struct rt_wdb * wdb_dbopen ( struct db_i dbip,
int  mode 
)

Create a libwdb output stream destined for an existing BRL-CAD database, already opened via a db_open() call.

Note: there can be only one rt_wdb container of each type per dbip - if an rt_wdb of the specified type is already associated with the database, the pre-existing stream will be returned.

RT_WDB_TYPE_DB_DISK Add to on-disk database RT_WDB_TYPE_DB_DISK_APPEND_ONLY Add to on-disk database, don't clobber existing names, use prefix RT_WDB_TYPE_DB_INMEM Add to in-memory database only RT_WDB_TYPE_DB_INMEM_APPEND_ONLY Ditto, but give errors if name in use.

◆ wdb_import()

int wdb_import ( struct rt_wdb wdbp,
struct rt_db_internal internp,
const char *  name,
const mat_t  mat 
)

Returns - 0 and modified *internp; -1 ft_import failure (from rt_db_get_internal) -2 db_get_external failure (from rt_db_get_internal) -3 Attempt to import from write-only (stream) file. -4 Name not found in database TOC.

NON-PARALLEL because of rt_uniresource

◆ wdb_export_external()

int wdb_export_external ( struct rt_wdb wdbp,
struct bu_external ep,
const char *  name,
int  flags,
unsigned char  minor_type 
)

The caller must free "ep".

Returns - 0 OK <0 error

◆ wdb_put_internal()

int wdb_put_internal ( struct rt_wdb wdbp,
const char *  name,
struct rt_db_internal ip,
double  local2mm 
)

Convert the internal representation of a solid to the external one, and write it into the database.

The internal representation is always freed. This is the analog of rt_db_put_internal() for rt_wdb objects.

Use this routine in preference to wdb_export() whenever the caller already has an rt_db_internal structure handy.

NON-PARALLEL because of rt_uniresource

Returns - 0 OK <0 error

◆ wdb_export()

int wdb_export ( struct rt_wdb wdbp,
const char *  name,
void *  gp,
int  id,
double  local2mm 
)

Export an in-memory representation of an object, as described in the file h/rtgeom.h, into the indicated database.

The internal representation (gp) is always freed.

WARNING: The caller must be careful not to double-free gp, particularly if it's been extracted from an rt_db_internal, e.g. by passing intern.idb_ptr for gp.

If the caller has an rt_db_internal structure handy already, they should call wdb_put_internal() directly – this is a convenience routine intended primarily for internal use in LIBWDB.

Returns - 0 OK <0 error

◆ wdb_init()

void wdb_init ( struct rt_wdb wdbp,
struct db_i dbip,
int  mode 
)

◆ wdb_close()

void wdb_close ( struct rt_wdb wdbp)

Close a database created with wdb_fopen or wdb_fopen_v.

◆ wdb_import_from_path()

int wdb_import_from_path ( struct bu_vls logstr,
struct rt_db_internal ip,
const char *  path,
struct rt_wdb wdb 
)

Given the name of a database object or a full path to a leaf object, obtain the internal form of that leaf. Packaged separately mainly to make available nice Tcl error handling.

Returns - BRLCAD_OK BRLCAD_ERROR

◆ wdb_import_from_path2()

int wdb_import_from_path2 ( struct bu_vls logstr,
struct rt_db_internal ip,
const char *  path,
struct rt_wdb wdb,
matp_t  matp 
)

Given the name of a database object or a full path to a leaf object, obtain the internal form of that leaf. Packaged separately mainly to make available nice Tcl error handling. Additionally, copies ts.ts_mat to matp.

Returns - BRLCAD_OK BRLCAD_ERROR