BRL-CAD
libwdb (Database Writing)

Interface structures and routines for libwdb. More...

Files

file  wdb.h
 

Data Structures

struct  wmember
 

Macros

#define WMEMBER_INIT_ZERO   { BU_LIST_INIT_ZERO, 0, MAT_INIT_IDN, NULL }
 
#define WMEMBER_INIT(x)   { BU_LIST_INIT(&((x)->l)); (x)->wm_op = 0; MAT_IDN((x)->wm_mat); (x)->wm_name = NULL; }
 
#define WMEMBER_NULL   ((struct wmember *)0)
 
#define WDB_CK_WMEMBER(_p)   BU_CKMAG(_p, WMEMBER_MAGIC, "wmember");
 
#define mk_lcomb(_fp, _name, _headp, _rf, _shadername, _shaderargs, _rgb, _inh)
 
#define mk_lrcomb(fp, name, _headp, region_flag, shadername, shaderargs, rgb, id, air, material, los, inherit_flag)
 
#define WMOP_INTERSECT   DB_OP_INTERSECT
 must track db.h More...
 
#define WMOP_SUBTRACT   DB_OP_SUBTRACT
 must track db.h More...
 
#define WMOP_UNION   DB_OP_UNION
 must track db.h More...
 
#define mk_lfcomb(fp, name, headp, region)    mk_lcomb(fp, name, headp, region, (char *)0, (char *)0, (unsigned char *)0, 0);
 
#define mk_export_fwrite(wdbp, name, gp, id)   wdb_export(wdbp, name, gp, id, mk_conv2mm)
 

Enumerations

enum  wdb_binunif {
  WDB_BINUNIF_FLOAT , WDB_BINUNIF_DOUBLE , WDB_BINUNIF_CHAR , WDB_BINUNIF_UCHAR ,
  WDB_BINUNIF_SHORT , WDB_BINUNIF_USHORT , WDB_BINUNIF_INT , WDB_BINUNIF_UINT ,
  WDB_BINUNIF_LONG , WDB_BINUNIF_ULONG , WDB_BINUNIF_LONGLONG , WDB_BINUNIF_ULONGLONG ,
  WDB_BINUNIF_INT8 , WDB_BINUNIF_UINT8 , WDB_BINUNIF_INT16 , WDB_BINUNIF_UINT16 ,
  WDB_BINUNIF_INT32 , WDB_BINUNIF_UINT32 , WDB_BINUNIF_INT64 , WDB_BINUNIF_UINT64 ,
  WDB_BINUNIF_FILE_FLOAT , WDB_BINUNIF_FILE_DOUBLE , WDB_BINUNIF_FILE_CHAR , WDB_BINUNIF_FILE_UCHAR ,
  WDB_BINUNIF_FILE_SHORT , WDB_BINUNIF_FILE_USHORT , WDB_BINUNIF_FILE_INT , WDB_BINUNIF_FILE_UINT ,
  WDB_BINUNIF_FILE_LONG , WDB_BINUNIF_FILE_ULONG , WDB_BINUNIF_FILE_LONGLONG , WDB_BINUNIF_FILE_ULONGLONG ,
  WDB_BINUNIF_FILE_INT8 , WDB_BINUNIF_FILE_UINT8 , WDB_BINUNIF_FILE_INT16 , WDB_BINUNIF_FILE_UINT16 ,
  WDB_BINUNIF_FILE_INT32 , WDB_BINUNIF_FILE_UINT32 , WDB_BINUNIF_FILE_INT64 , WDB_BINUNIF_FILE_UINT64
}
 

Functions

int mk_id (struct rt_wdb *fp, const char *title)
 
int mk_id_units (struct rt_wdb *fp, const char *title, const char *units)
 
int mk_id_editunits (struct rt_wdb *fp, const char *title, double local2mm)
 
int mk_half (struct rt_wdb *fp, const char *name, const vect_t norm, fastf_t d)
 
int mk_grip (struct rt_wdb *wdbp, const char *name, const point_t center, const vect_t normal, const fastf_t magnitude)
 
int mk_rpp (struct rt_wdb *fp, const char *name, const point_t min, const point_t max)
 
int mk_wedge (struct rt_wdb *fp, const char *name, const point_t vert, const vect_t xdirv, const vect_t zdirv, fastf_t xlen, fastf_t ylen, fastf_t zlen, fastf_t x_top_len)
 
int mk_arb4 (struct rt_wdb *fp, const char *name, const fastf_t *pts4)
 
int mk_arb5 (struct rt_wdb *fp, const char *name, const fastf_t *pts5)
 
int mk_arb6 (struct rt_wdb *fp, const char *name, const fastf_t *pts6)
 
int mk_arb7 (struct rt_wdb *fp, const char *name, const fastf_t *pts7)
 
int mk_arb8 (struct rt_wdb *fp, const char *name, const fastf_t *pts8)
 
int mk_sph (struct rt_wdb *fp, const char *name, const point_t center, fastf_t radius)
 
int mk_ell (struct rt_wdb *fp, const char *name, const point_t center, const vect_t a, const vect_t b, const vect_t c)
 
int mk_tor (struct rt_wdb *fp, const char *name, const point_t center, const vect_t inorm, double r1, double r2)
 
int mk_rcc (struct rt_wdb *fp, const char *name, const point_t base, const vect_t height, fastf_t radius)
 
int mk_tgc (struct rt_wdb *fp, const char *name, const point_t base, const vect_t height, const vect_t a, const vect_t b, const vect_t c, const vect_t d)
 
int mk_cone (struct rt_wdb *fp, const char *name, const point_t base, const vect_t dirv, fastf_t height, fastf_t base_radius, fastf_t nose_radius)
 
int mk_trc_h (struct rt_wdb *fp, const char *name, const point_t base, const vect_t height, fastf_t radbase, fastf_t radtop)
 
int mk_trc_top (struct rt_wdb *fp, const char *name, const point_t ibase, const point_t itop, fastf_t radbase, fastf_t radtop)
 
int mk_rpc (struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, double half_w)
 
int mk_rhc (struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, fastf_t half_w, fastf_t asymp)
 
int mk_epa (struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, fastf_t r1, fastf_t r2)
 
int mk_ehy (struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, fastf_t r1, fastf_t r2, fastf_t c)
 
int mk_hyp (struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height_vector, const vect_t vectA, fastf_t magB, fastf_t base_neck_ratio)
 
int mk_eto (struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t norm, const vect_t smajor, fastf_t rrot, fastf_t sminor)
 
int mk_metaball (struct rt_wdb *wdbp, const char *name, const size_t nctlpt, const int method, const fastf_t threshold, const fastf_t *verts[5])
 
int mk_arbn (struct rt_wdb *fp, const char *name, size_t neqn, const plane_t *eqn)
 
int mk_ars (struct rt_wdb *fp, const char *name, size_t ncurves, size_t pts_per_curve, fastf_t *curves[])
 
int mk_constraint (struct rt_wdb *wdbp, const char *name, const char *expr)
 
int mk_material (struct rt_wdb *wdbp, const char *db_name, const char *name, const char *parent, const char *source, struct bu_attribute_value_set *physicalProperties, struct bu_attribute_value_set *mechanicalProperties, struct bu_attribute_value_set *opticalProperties, struct bu_attribute_value_set *thermalProperties)
 
int mk_binunif (struct rt_wdb *fp, const char *name, const void *data, wdb_binunif data_type, long count)
 
int mk_bot (struct rt_wdb *fp, const char *name, unsigned char mode, unsigned char orientation, unsigned char error_mode, size_t num_vertices, size_t num_faces, fastf_t *vertices, int *faces, fastf_t *thickness, struct bu_bitv *face_mode)
 
int mk_bot_w_normals (struct rt_wdb *fp, const char *name, unsigned char mode, unsigned char orientation, unsigned char flags, size_t num_vertices, size_t num_faces, const fastf_t *vertices, const int *faces, const fastf_t *thickness, struct bu_bitv *face_mode, size_t num_normals, fastf_t *normals, int *face_normals)
 
int mk_bot_w_normals_and_uvs (struct rt_wdb *fp, const char *name, unsigned char mode, unsigned char orientation, unsigned char flags, size_t num_vertices, size_t num_faces, const fastf_t *vertices, const int *faces, const fastf_t *thickness, struct bu_bitv *face_mode, size_t num_normals, fastf_t *normals, int *face_normals, size_t num_uvs, fastf_t *uvs, int *face_uvs)
 
int mk_brep (struct rt_wdb *wdbp, const char *name, void *vbrep)
 
int mk_bspline (struct rt_wdb *wdbp, const char *name, struct face_g_snurb **surfs)
 
int mk_nmg (struct rt_wdb *filep, const char *name, struct model *m)
 
int mk_bot_from_nmg (struct rt_wdb *ofp, const char *name, struct shell *s)
 
int mk_sketch (struct rt_wdb *fp, const char *name, const struct rt_sketch_internal *skt)
 
int mk_annot (struct rt_wdb *fp, const char *name, const struct rt_annot_internal *ann)
 
int mk_script (struct rt_wdb *fp, const char *name, const struct rt_script_internal *scr)
 
int mk_extrusion (struct rt_wdb *fp, const char *name, const char *sketch_name, const point_t V, const vect_t h, const vect_t u_vec, const vect_t v_vec, int keypoint)
 
int mk_cline (struct rt_wdb *fp, const char *name, const point_t V, const vect_t height, fastf_t radius, fastf_t thickness)
 
int mk_particle (struct rt_wdb *fp, const char *name, point_t vertex, vect_t height, double vradius, double hradius)
 
int mk_pipe (struct rt_wdb *fp, const char *name, struct bu_list *headp)
 
void mk_pipe_free (struct bu_list *headp)
 
void mk_add_pipe_pnt (struct bu_list *headp, const point_t coord, double od, double id, double bendradius)
 
void mk_pipe_init (struct bu_list *headp)
 
int mk_dsp (struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, const matp_t mat)
 
int mk_ebm (struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, fastf_t tallness, const matp_t mat)
 
int mk_hrt (struct rt_wdb *fp, const char *name, const point_t center, const vect_t x, const vect_t y, const vect_t z, const fastf_t dist)
 
int mk_vol (struct rt_wdb *fp, const char *name, char datasrc, const char *file, size_t xdim, size_t ydim, size_t zdim, size_t lo, size_t hi, const vect_t cellsize, const matp_t mat)
 
int mk_submodel (struct rt_wdb *fp, const char *name, const char *file, const char *treetop, int meth)
 
int mk_write_color_table (struct rt_wdb *ofp)
 
struct wmembermk_addmember (const char *name, struct bu_list *headp, mat_t mat, int op)
 
int mk_comb (struct rt_wdb *wdbp, const char *combname, struct bu_list *headp, int region_kind, const char *shadername, const char *shaderargs, const unsigned char *rgb, int id, int air, int material, int los, int inherit, int append_ok, int gift_semantics)
 Combination (region and group) construction: first you build a list of nodes with mk_addmember, then you output the combination. More...
 
int mk_comb1 (struct rt_wdb *fp, const char *combname, const char *membname, int regflag)
 
int mk_region1 (struct rt_wdb *fp, const char *combname, const char *membname, const char *shadername, const char *shaderargs, const unsigned char *rgb)
 
int mk_conversion (char *units_string)
 
int mk_set_conversion (double val)
 
void mk_freemembers (struct bu_list *headp)
 
int make_hole (struct rt_wdb *wdbp, point_t hole_start, vect_t hole_depth, fastf_t hole_radius, int num_objs, struct directory **dp)
 This routine is intended to be used to make a hole in some geometry. More...
 
int make_hole_in_prepped_regions (struct rt_wdb *wdbp, struct rt_i *rtip, point_t hole_start, vect_t hole_depth, fastf_t radius, struct bu_ptbl *regions)
 This routine provides a quick approach to simply adding a hole to existing prepped geometry. More...
 

Variables

double mk_conv2mm
 Conversion factor to mm. More...
 
int mk_version
 Which version database to write. More...
 

Detailed Description

Interface structures and routines for libwdb.

Library for writing MGED database objects from arbitrary procedures. Assumes that some of the structure of such databases are known by the calling routines.

It is expected that this library will grow as experience is gained. Routines for writing every permissible solid do not yet exist.

Note that routines which are passed point_t or vect_t or mat_t parameters (which are call-by-address) must be VERY careful to leave those parameters unmodified (e.g., by scaling), so that the calling routine is not surprised.

Return codes of 0 are OK, -1 signal an error.

Note - Rather than using a stdio (FILE *), we now use a (struct rt_wdb *) parameter. Rather than calling fopen(), call wdb_fopen();

Macro Definition Documentation

◆ WMEMBER_INIT_ZERO

#define WMEMBER_INIT_ZERO   { BU_LIST_INIT_ZERO, 0, MAT_INIT_IDN, NULL }

Definition at line 85 of file wdb.h.

◆ WMEMBER_INIT

#define WMEMBER_INIT (   x)    { BU_LIST_INIT(&((x)->l)); (x)->wm_op = 0; MAT_IDN((x)->wm_mat); (x)->wm_name = NULL; }

Definition at line 86 of file wdb.h.

◆ WMEMBER_NULL

#define WMEMBER_NULL   ((struct wmember *)0)

Definition at line 87 of file wdb.h.

◆ WDB_CK_WMEMBER

#define WDB_CK_WMEMBER (   _p)    BU_CKMAG(_p, WMEMBER_MAGIC, "wmember");

Definition at line 88 of file wdb.h.

◆ mk_lcomb

#define mk_lcomb (   _fp,
  _name,
  _headp,
  _rf,
  _shadername,
  _shaderargs,
  _rgb,
  _inh 
)
Value:
mk_comb(_fp, _name, &((_headp)->l), _rf, _shadername, _shaderargs, \
_rgb, 0, 0, 0, 0, _inh, 0, 0)
int mk_comb(struct rt_wdb *wdbp, const char *combname, struct bu_list *headp, int region_kind, const char *shadername, const char *shaderargs, const unsigned char *rgb, int id, int air, int material, int los, int inherit, int append_ok, int gift_semantics)
Combination (region and group) construction: first you build a list of nodes with mk_addmember,...

Definition at line 700 of file wdb.h.

◆ mk_lrcomb

#define mk_lrcomb (   fp,
  name,
  _headp,
  region_flag,
  shadername,
  shaderargs,
  rgb,
  id,
  air,
  material,
  los,
  inherit_flag 
)
Value:
mk_comb(fp, name, &((_headp)->l), region_flag, shadername, shaderargs, \
rgb, id, air, material, los, inherit_flag, 0, 0)

Definition at line 706 of file wdb.h.

◆ WMOP_INTERSECT

#define WMOP_INTERSECT   DB_OP_INTERSECT

must track db.h

Definition at line 762 of file wdb.h.

◆ WMOP_SUBTRACT

#define WMOP_SUBTRACT   DB_OP_SUBTRACT

must track db.h

Definition at line 763 of file wdb.h.

◆ WMOP_UNION

#define WMOP_UNION   DB_OP_UNION

must track db.h

Definition at line 764 of file wdb.h.

◆ mk_lfcomb

#define mk_lfcomb (   fp,
  name,
  headp,
  region 
)     mk_lcomb(fp, name, headp, region, (char *)0, (char *)0, (unsigned char *)0, 0);

Definition at line 767 of file wdb.h.

◆ mk_export_fwrite

#define mk_export_fwrite (   wdbp,
  name,
  gp,
  id 
)    wdb_export(wdbp, name, gp, id, mk_conv2mm)

Definition at line 802 of file wdb.h.

Enumeration Type Documentation

◆ wdb_binunif

Enumerator
WDB_BINUNIF_FLOAT 
WDB_BINUNIF_DOUBLE 
WDB_BINUNIF_CHAR 
WDB_BINUNIF_UCHAR 
WDB_BINUNIF_SHORT 
WDB_BINUNIF_USHORT 
WDB_BINUNIF_INT 
WDB_BINUNIF_UINT 
WDB_BINUNIF_LONG 
WDB_BINUNIF_ULONG 
WDB_BINUNIF_LONGLONG 
WDB_BINUNIF_ULONGLONG 
WDB_BINUNIF_INT8 
WDB_BINUNIF_UINT8 
WDB_BINUNIF_INT16 
WDB_BINUNIF_UINT16 
WDB_BINUNIF_INT32 
WDB_BINUNIF_UINT32 
WDB_BINUNIF_INT64 
WDB_BINUNIF_UINT64 
WDB_BINUNIF_FILE_FLOAT 
WDB_BINUNIF_FILE_DOUBLE 
WDB_BINUNIF_FILE_CHAR 
WDB_BINUNIF_FILE_UCHAR 
WDB_BINUNIF_FILE_SHORT 
WDB_BINUNIF_FILE_USHORT 
WDB_BINUNIF_FILE_INT 
WDB_BINUNIF_FILE_UINT 
WDB_BINUNIF_FILE_LONG 
WDB_BINUNIF_FILE_ULONG 
WDB_BINUNIF_FILE_LONGLONG 
WDB_BINUNIF_FILE_ULONGLONG 
WDB_BINUNIF_FILE_INT8 
WDB_BINUNIF_FILE_UINT8 
WDB_BINUNIF_FILE_INT16 
WDB_BINUNIF_FILE_UINT16 
WDB_BINUNIF_FILE_INT32 
WDB_BINUNIF_FILE_UINT32 
WDB_BINUNIF_FILE_INT64 
WDB_BINUNIF_FILE_UINT64 

Definition at line 365 of file wdb.h.

Function Documentation

◆ mk_id()

int mk_id ( struct rt_wdb fp,
const char *  title 
)

Make a database header (ID) record.

◆ mk_id_units()

int mk_id_units ( struct rt_wdb fp,
const char *  title,
const char *  units 
)

Make a database header (ID) record, and note the user's preferred editing units (specified as a string).

Returns
<0 error, 0 success

◆ mk_id_editunits()

int mk_id_editunits ( struct rt_wdb fp,
const char *  title,
double  local2mm 
)

Make a database header (ID) record, and note the user's preferred editing units (specified as a conversion factor).

Note that the v4 database format offers only a limited number of choices for the preferred editing units. If the user is editing in unusual units (like 2.5feet), don't fail to create the database header.

In the v5 database, the conversion factor will be stored intact.

Note that the database-layer header record will have already been written by db_create(). All we have to do here is update it.

Returns
<0 error, 0 success

◆ mk_half()

int mk_half ( struct rt_wdb fp,
const char *  name,
const vect_t  norm,
fastf_t  d 
)

Make a halfspace. Specified by distance from origin, and outward pointing normal vector.

◆ mk_grip()

int mk_grip ( struct rt_wdb wdbp,
const char *  name,
const point_t  center,
const vect_t  normal,
const fastf_t  magnitude 
)

Make a grip pseudo solid. Specified by a center, normal vector, and magnitude.

◆ mk_rpp()

int mk_rpp ( struct rt_wdb fp,
const char *  name,
const point_t  min,
const point_t  max 
)

Make a right parallelepiped. Specified by minXYZ, maxXYZ.

◆ mk_wedge()

int mk_wedge ( struct rt_wdb fp,
const char *  name,
const point_t  vert,
const vect_t  xdirv,
const vect_t  zdirv,
fastf_t  xlen,
fastf_t  ylen,
fastf_t  zlen,
fastf_t  x_top_len 
)

Makes a right angular wedge given a starting vertex located in the, lower left corner, an x and a z direction vector, x, y, and z lengths, and an x length for the top. The y direction vector is x cross z.

◆ mk_arb4()

int mk_arb4 ( struct rt_wdb fp,
const char *  name,
const fastf_t pts4 
)

◆ mk_arb5()

int mk_arb5 ( struct rt_wdb fp,
const char *  name,
const fastf_t pts5 
)

◆ mk_arb6()

int mk_arb6 ( struct rt_wdb fp,
const char *  name,
const fastf_t pts6 
)

◆ mk_arb7()

int mk_arb7 ( struct rt_wdb fp,
const char *  name,
const fastf_t pts7 
)

◆ mk_arb8()

int mk_arb8 ( struct rt_wdb fp,
const char *  name,
const fastf_t pts8 
)

All plates with 4 points must be co-planar. If there are degeneracies (i.e., all 8 vertices are not distinct), then certain requirements must be met. If we think of the ARB8 as having a top and a bottom plate, the first four points listed must lie on one plate, and the second four points listed must lie on the other plate.

◆ mk_sph()

int mk_sph ( struct rt_wdb fp,
const char *  name,
const point_t  center,
fastf_t  radius 
)

Make a sphere with the given center point and radius.

◆ mk_ell()

int mk_ell ( struct rt_wdb fp,
const char *  name,
const point_t  center,
const vect_t  a,
const vect_t  b,
const vect_t  c 
)

Make an ellipsoid at the given center point with 3 perp. radius vectors. The eccentricity of the ellipsoid is controlled by the relative lengths of the three radius vectors.

◆ mk_tor()

int mk_tor ( struct rt_wdb fp,
const char *  name,
const point_t  center,
const vect_t  inorm,
double  r1,
double  r2 
)

Make a torus. Specify center, normal, r1: distance from center point to center of solid part, r2: radius of solid part.

◆ mk_rcc()

int mk_rcc ( struct rt_wdb fp,
const char *  name,
const point_t  base,
const vect_t  height,
fastf_t  radius 
)

Make a Right Circular Cylinder (special case of the TGC).

◆ mk_tgc()

int mk_tgc ( struct rt_wdb fp,
const char *  name,
const point_t  base,
const vect_t  height,
const vect_t  a,
const vect_t  b,
const vect_t  c,
const vect_t  d 
)

Make a Truncated General Cylinder.

◆ mk_cone()

int mk_cone ( struct rt_wdb fp,
const char *  name,
const point_t  base,
const vect_t  dirv,
fastf_t  height,
fastf_t  base_radius,
fastf_t  nose_radius 
)

Makes a right circular cone given the center point of the base circle, a direction vector, a scalar height, and the radii at each end of the cone.

◆ mk_trc_h()

int mk_trc_h ( struct rt_wdb fp,
const char *  name,
const point_t  base,
const vect_t  height,
fastf_t  radbase,
fastf_t  radtop 
)

Make a truncated right cylinder, with base and height. Not just called mk_trc() to avoid conflict with a previous routine of that name with different calling sequence.

◆ mk_trc_top()

int mk_trc_top ( struct rt_wdb fp,
const char *  name,
const point_t  ibase,
const point_t  itop,
fastf_t  radbase,
fastf_t  radtop 
)

Convenience wrapper for mk_trc_h().

◆ mk_rpc()

int mk_rpc ( struct rt_wdb wdbp,
const char *  name,
const point_t  vert,
const vect_t  height,
const vect_t  breadth,
double  half_w 
)

Makes a right parabolic cylinder given the origin, or main vertex, a height vector, a breadth vector (B . H must be 0), and a scalar rectangular half-width (for the top of the rpc).

◆ mk_rhc()

int mk_rhc ( struct rt_wdb wdbp,
const char *  name,
const point_t  vert,
const vect_t  height,
const vect_t  breadth,
fastf_t  half_w,
fastf_t  asymp 
)

Makes a right hyperbolic cylinder given the origin, or main vertex, a height vector, a breadth vector (B . H must be 0), a scalar rectangular half-width (for the top of the rpc), and the scalar distance from the tip of the hyperbola to the intersection of the asymptotes.

◆ mk_epa()

int mk_epa ( struct rt_wdb wdbp,
const char *  name,
const point_t  vert,
const vect_t  height,
const vect_t  breadth,
fastf_t  r1,
fastf_t  r2 
)

Makes an elliptical paraboloid given the origin, a height vector H, a unit vector A along the semi-major axis (A . H must equal 0), and the scalar lengths, r1 and r2, of the semi-major and -minor axes.

◆ mk_ehy()

int mk_ehy ( struct rt_wdb wdbp,
const char *  name,
const point_t  vert,
const vect_t  height,
const vect_t  breadth,
fastf_t  r1,
fastf_t  r2,
fastf_t  c 
)

Makes an elliptical hyperboloid given the origin, a height vector H, a unit vector A along the semi-major axis (A . H must equal 0), the scalar lengths, r1 and r2, of the semi-major and -minor axes, and the distance c between the tip of the hyperboloid and the vertex of the asymptotic cone.

◆ mk_hyp()

int mk_hyp ( struct rt_wdb wdbp,
const char *  name,
const point_t  vert,
const vect_t  height_vector,
const vect_t  vectA,
fastf_t  magB,
fastf_t  base_neck_ratio 
)

Make a hyperboloid at the given center point with a vertex, height vector, A vector, magnitude of the B vector, and neck to base ratio.

◆ mk_eto()

int mk_eto ( struct rt_wdb wdbp,
const char *  name,
const point_t  vert,
const vect_t  norm,
const vect_t  smajor,
fastf_t  rrot,
fastf_t  sminor 
)

Makes an elliptical torus given the origin, a plane normal vector N, a vector C along the semi-major axis of the elliptical cross-section, the scalar lengths r and rd, of the radius of revolution and length of semi-minor axis of the elliptical cross section.

◆ mk_metaball()

int mk_metaball ( struct rt_wdb wdbp,
const char *  name,
const size_t  nctlpt,
const int  method,
const fastf_t  threshold,
const fastf_t verts[5] 
)

Makes a metaball.

◆ mk_arbn()

int mk_arbn ( struct rt_wdb fp,
const char *  name,
size_t  neqn,
const plane_t eqn 
)

Caller is responsible for freeing eqn[]

Returns
<0 error, 0 success

◆ mk_ars()

int mk_ars ( struct rt_wdb fp,
const char *  name,
size_t  ncurves,
size_t  pts_per_curve,
fastf_t curves[] 
)

◆ mk_constraint()

int mk_constraint ( struct rt_wdb wdbp,
const char *  name,
const char *  expr 
)

Given the appropriate parameters, makes the non-geometric constraint object and writes it to the database using wdb_put_internal. Only supported on database version 5 or above

◆ mk_material()

int mk_material ( struct rt_wdb wdbp,
const char *  db_name,
const char *  name,
const char *  parent,
const char *  source,
struct bu_attribute_value_set physicalProperties,
struct bu_attribute_value_set mechanicalProperties,
struct bu_attribute_value_set opticalProperties,
struct bu_attribute_value_set thermalProperties 
)

◆ mk_binunif()

int mk_binunif ( struct rt_wdb fp,
const char *  name,
const void *  data,
wdb_binunif  data_type,
long  count 
)

Make a uniform binary data object from an array or a data file. Read 'count' values from 'data'. If 'data_type' is a file, 'count' may be used to only read a subset of a file's contents. If 'data' is already an in-memory buffer of memory, 'count' values will be copied (which is count * sizeof(data_type) bytes).

Files can use a non-positive 'count' to mean "read the whole file", pre-loaded data, however, must provide a positive 'count' otherwise an empty binunif will be created.

◆ mk_bot()

int mk_bot ( struct rt_wdb fp,
const char *  name,
unsigned char  mode,
unsigned char  orientation,
unsigned char  error_mode,
size_t  num_vertices,
size_t  num_faces,
fastf_t vertices,
int *  faces,
fastf_t thickness,
struct bu_bitv face_mode 
)

Create a BOT (Bag O'Triangles) solid

Parameters
fpdatabase file pointer to write to
namename of bot object to write out
modebot mode
orientationbot orientation
error_modemay be used to indicate error handling (ignored for now)
num_verticesnumber of vertices
num_facesnumber of faces
verticesarray of floats for vertices [num_vertices*3]
facesarray of ints for faces [num_faces*3]
thicknessarray of plate mode thicknesses (corresponds to array of faces) NULL for modes RT_BOT_SURFACE and RT_BOT_SOLID.
face_modea flag for each face indicating thickness is appended to hit point, otherwise thickness is centered about hit point

◆ mk_bot_w_normals()

int mk_bot_w_normals ( struct rt_wdb fp,
const char *  name,
unsigned char  mode,
unsigned char  orientation,
unsigned char  flags,
size_t  num_vertices,
size_t  num_faces,
const fastf_t vertices,
const int *  faces,
const fastf_t thickness,
struct bu_bitv face_mode,
size_t  num_normals,
fastf_t normals,
int *  face_normals 
)

Create a BOT (Bag O'Triangles) solid with face normals

Parameters
fpdatabase file pointer to write to
namename of bot object to write out
modebot mode
orientationbot orientation
flagsadditional bot flags
num_verticesnumber of bot vertices
num_facesnumber of bot faces
verticesarray of floats for vertices [num_vertices*3]
facesarray of ints for faces [num_faces*3]
thicknessarray of plate mode thicknesses (corresponds to array of faces) NULL for modes RT_BOT_SURFACE and RT_BOT_SOLID.
face_modea flag for each face indicating thickness is appended to hit point, otherwise thickness is centered about hit point
num_normalsnumber of unit normals in normals array
normalsarray of floats for normals [num_normals*3]
face_normalsarray of ints (indices into normals array), must have 3*num_faces entries

◆ mk_bot_w_normals_and_uvs()

int mk_bot_w_normals_and_uvs ( struct rt_wdb fp,
const char *  name,
unsigned char  mode,
unsigned char  orientation,
unsigned char  flags,
size_t  num_vertices,
size_t  num_faces,
const fastf_t vertices,
const int *  faces,
const fastf_t thickness,
struct bu_bitv face_mode,
size_t  num_normals,
fastf_t normals,
int *  face_normals,
size_t  num_uvs,
fastf_t uvs,
int *  face_uvs 
)

Create a BOT (Bag O'Triangles) solid with face normals and uv texture coordinates

Parameters
fpdatabase file pointer to write to
namename of bot object to write out
modebot mode
orientationbot orientation
flagsadditional bot flags
num_verticesnumber of bot vertices
num_facesnumber of bot faces
verticesarray of floats for vertices [num_vertices*3]
facesarray of ints for faces [num_faces*3]
thicknessarray of plate mode thicknesses (corresponds to array of faces) NULL for modes RT_BOT_SURFACE and RT_BOT_SOLID.
face_modea flag for each face indicating thickness is appended to hit point, otherwise thickness is centered about hit point
num_normalsnumber of unit normals in normals array
normalsarray of floats for normals [num_normals*3]
face_normalsarray of ints (indices into normals array), must have 3*num_faces entries
num_uvsnumber of uv texture coordinates in uvs array
uvsarray of floats for uv texture coordinates [num_uvs*3]
face_uvsarray of ints (indices into uvs array), must have 3*num_faces entries

◆ mk_brep()

int mk_brep ( struct rt_wdb wdbp,
const char *  name,
void *  vbrep 
)

Create a brep in the geometry file. vbrep must be a void cast pointer to an ON_Brep shape.

◆ mk_bspline()

int mk_bspline ( struct rt_wdb wdbp,
const char *  name,
struct face_g_snurb **  surfs 
)

Output an array of B-spline (NURBS) surfaces which comprise a solid. The surface is freed when it is written.

Note: unless there is a specific need to work with the older BRL-CAD NURBS objects, mk_brep should be used instead of this routine.

◆ mk_nmg()

int mk_nmg ( struct rt_wdb filep,
const char *  name,
struct model m 
)

The NMG is freed after being written.

Returns
<0 error, 0 success

◆ mk_bot_from_nmg()

int mk_bot_from_nmg ( struct rt_wdb ofp,
const char *  name,
struct shell s 
)

For ray-tracing speed, many database conversion routines like to offer the option of converting NMG objects to bags of triangles (BoT). Here is a convenience routine to replace the old routine write_shell_as_polysolid. (obsolete since BRL-CAD 6.0)

◆ mk_sketch()

int mk_sketch ( struct rt_wdb fp,
const char *  name,
const struct rt_sketch_internal skt 
)

Make a sketch

◆ mk_annot()

int mk_annot ( struct rt_wdb fp,
const char *  name,
const struct rt_annot_internal ann 
)

Make a annotation

◆ mk_script()

int mk_script ( struct rt_wdb fp,
const char *  name,
const struct rt_script_internal scr 
)

Make a script

◆ mk_extrusion()

int mk_extrusion ( struct rt_wdb fp,
const char *  name,
const char *  sketch_name,
const point_t  V,
const vect_t  h,
const vect_t  u_vec,
const vect_t  v_vec,
int  keypoint 
)

Make an extrusion solid

◆ mk_cline()

int mk_cline ( struct rt_wdb fp,
const char *  name,
const point_t  V,
const vect_t  height,
fastf_t  radius,
fastf_t  thickness 
)

Support for cline solids (kludges from FASTGEN)

Note: cline should not be used in .g models unless specifically needed for FASTGEN compatibility.

◆ mk_particle()

int mk_particle ( struct rt_wdb fp,
const char *  name,
point_t  vertex,
vect_t  height,
double  vradius,
double  hradius 
)

Make a particle primitive.

Returns
<0 error, 0 success

◆ mk_pipe()

int mk_pipe ( struct rt_wdb fp,
const char *  name,
struct bu_list headp 
)

Make a pipe primitive.

Note that the linked list of pipe segments headed by 'headp' must be freed by the caller. mk_pipe_free() can be used.

Returns
<0 error, 0 success

◆ mk_pipe_free()

void mk_pipe_free ( struct bu_list headp)

Release the storage from a list of pipe segments. The head is left in initialized state (i.e., forward & back point to head).

◆ mk_add_pipe_pnt()

void mk_add_pipe_pnt ( struct bu_list headp,
const point_t  coord,
double  od,
double  id,
double  bendradius 
)

Add another pipe segment to the linked list of pipe segments.

◆ mk_pipe_init()

void mk_pipe_init ( struct bu_list headp)

initialize a linked list of pipe segments with the first segment

◆ mk_dsp()

int mk_dsp ( struct rt_wdb fp,
const char *  name,
const char *  file,
size_t  xdim,
size_t  ydim,
const matp_t  mat 
)

Displacement map primitive.

◆ mk_ebm()

int mk_ebm ( struct rt_wdb fp,
const char *  name,
const char *  file,
size_t  xdim,
size_t  ydim,
fastf_t  tallness,
const matp_t  mat 
)

Extruded bitmap primitive.

◆ mk_hrt()

int mk_hrt ( struct rt_wdb fp,
const char *  name,
const point_t  center,
const vect_t  x,
const vect_t  y,
const vect_t  z,
const fastf_t  dist 
)

Heart primitive.

◆ mk_vol()

int mk_vol ( struct rt_wdb fp,
const char *  name,
char  datasrc,
const char *  file,
size_t  xdim,
size_t  ydim,
size_t  zdim,
size_t  lo,
size_t  hi,
const vect_t  cellsize,
const matp_t  mat 
)

3-D Volume primitive.

◆ mk_submodel()

int mk_submodel ( struct rt_wdb fp,
const char *  name,
const char *  file,
const char *  treetop,
int  meth 
)

Create a submodel solid. If file is NULL or "", the treetop refers to the current database. Treetop is the name of a single database object in 'file'. meth is normally 0 (RT_PART_NUBSPT) and unused.

◆ mk_write_color_table()

int mk_write_color_table ( struct rt_wdb ofp)

Interface for writing region-id-based color tables to the database. Given that the color table has been built up by successive calls to rt_color_addrec(), write it into the database.

◆ mk_addmember()

struct wmember * mk_addmember ( const char *  name,
struct bu_list headp,
mat_t  mat,
int  op 
)

Obtain dynamic storage for a new wmember structure, fill in the name, default the operation and matrix, and add to doubly linked list. In typical use, a one-line call is sufficient. To change the defaults, catch the pointer that is returned, and adjust the structure to taste.

The name must be a non-zero length string.

The caller is responsible for initializing the header structures forward and backward links.

◆ mk_comb()

int mk_comb ( struct rt_wdb wdbp,
const char *  combname,
struct bu_list headp,
int  region_kind,
const char *  shadername,
const char *  shaderargs,
const unsigned char *  rgb,
int  id,
int  air,
int  material,
int  los,
int  inherit,
int  append_ok,
int  gift_semantics 
)

Combination (region and group) construction: first you build a list of nodes with mk_addmember, then you output the combination.

The members are described by a linked list of wmember structs.

The linked list is freed when it has been output.

Has many operating modes.

Returns
<0 error, 0 success
Parameters
wdbpdatabase to write to
combnamename of the combination
headpMade by mk_addmember()
region_kind1 => region. 'P' and 'V' for FASTGEN
shadernameshader name, or NULL
shaderargsshader args, or NULL
rgbNULL => no color
idregion_id
airaircode
materialGIFTmater
losline-of-sight thickness equivalence
inheritwhether objects below inherit from this comb
append_ok0 = obj must not exit
gift_semantics0 = pure, 1 = gift

◆ mk_comb1()

int mk_comb1 ( struct rt_wdb fp,
const char *  combname,
const char *  membname,
int  regflag 
)

Convenience interface to make a combination with a single member.

◆ mk_region1()

int mk_region1 ( struct rt_wdb fp,
const char *  combname,
const char *  membname,
const char *  shadername,
const char *  shaderargs,
const unsigned char *  rgb 
)

Convenience routine to make a region with shader and rgb possibly set.

◆ mk_conversion()

int mk_conversion ( char *  units_string)

Given a string conversion value, find the appropriate factor, and establish it.

Returns
-1 error, 0 OK

◆ mk_set_conversion()

int mk_set_conversion ( double  val)

Establish a new conversion factor for LIBWDB routines.

Returns
-1 error, 0 success

◆ mk_freemembers()

void mk_freemembers ( struct bu_list headp)

TODO - document this...

◆ make_hole()

int make_hole ( struct rt_wdb wdbp,
point_t  hole_start,
vect_t  hole_depth,
fastf_t  hole_radius,
int  num_objs,
struct directory **  dp 
)

This routine is intended to be used to make a hole in some geometry.

The hole is described using the same parameters as an RCC, and the hole is represented as an RCC. The objects to be "holed" are passed in as a list of "struct directory" pointers. The objects pointed at by this list must be combinations. The "struct rt_wdb" pointer passed in indicates what model this hole should appear in.

The end state after this routine runs is a modified model with a new RCC primitive having a name of the form "make_hole_X" (where X is some integer). The combinations specified in the list will be modified as follows:

   before                          after
     |                              /\
     u                             u  -

orig_comb_tree orig_comb_tree make_hole_X

The modified combination is written to the struct rt_wdb. Note that to do dynamic geometry a "wdb_dbopen" would normally be called on an already existing (and possibly prepped) model. Using the RT_WDB_TYPE_DB_INMEM parameter in this call will result in geometry changes that only exist in memory and will not be permanently stored in the original database.

This routine should be preceded by a call to "rt_unprep" and followed by a call to "rt_reprep".

◆ make_hole_in_prepped_regions()

int make_hole_in_prepped_regions ( struct rt_wdb wdbp,
struct rt_i rtip,
point_t  hole_start,
vect_t  hole_depth,
fastf_t  radius,
struct bu_ptbl regions 
)

This routine provides a quick approach to simply adding a hole to existing prepped geometry.

The geometry must already be prepped prior to calling this routine. After calling this routine, the geometry is ready for raytracing (no other routine need to be called).

A new RCC primitive is created and written to the database (wdbp). Note that this will be temporary if the wdbp pointer was created by a call to wdb_dbopen with the RT_WDB_TYPE_DB_INMEM flag.

The "regions" parameter is a list of "struct region" pointers (prepped regions) to get holed. The regions structures are modified, but the on disk region records are never modified, so the actual holes will never be permanent regardless of how "wdbp" was opened.

There is no need to call "rt_unprep" nor "rt_reprep" with this routine.

Variable Documentation

◆ mk_conv2mm

double mk_conv2mm
extern

Conversion factor to mm.

This internal variable should not be directly modified; call mk_conversion() or mk_set_conversion() instead.

◆ mk_version

int mk_version
extern

Which version database to write.

Set this variable to either 4 or 5, depending on which version of the database you wish to write.