BRL-CAD
Collaboration diagram for Units:

Files

file  units.c
 

Functions

double bu_units_conversion (const char *str)
 
const char * bu_units_string (const double mm)
 
struct bu_vlsbu_units_strings_vls (void)
 
const char * bu_nearest_units_string (const double mm)
 
double bu_mm_value (const char *s)
 
void bu_mm_cvt (const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
 

Detailed Description

Function Documentation

double bu_units_conversion ( const char *  str)

Given a string representation of a unit of distance (e.g., "feet"), return the multiplier which will convert that unit into the default unit for the dimension (millimeters for length, mm^3 for volume, and grams for mass.)

Returns 0.0 on error and >0.0 on success

Definition at line 234 of file units.c.

References bu_strlcpy, conv_table::cvttab, cvt_tab::name, and cvt_tab::val.

Referenced by ged_tire(), mk_conversion(), mk_id_units(), tcl_bu_units_conversion(), and vo_units_cmd().

const char* bu_units_string ( const double  mm)

Given a conversion factor to mm, search the table to find what unit this represents.

To accommodate floating point fuzz, a "near miss" is allowed. The algorithm depends on the table being sorted small-to-large.

Returns - char* units string NULL No known unit matches this conversion factor.

Referenced by _ged_do_list(), db_fwrite_ident(), db_update_ident(), ged_bb(), ged_tables(), go_draw_faceplate(), and vo_units_cmd().

struct bu_vls* bu_units_strings_vls ( void  )

Definition at line 291 of file units.c.

References BU_ALLOC, bu_vls_init(), bu_vls_printf(), bu_vls_trunc(), cvt_tab::name, cvt_tab::val, and ZERO.

Referenced by ged_units().

Here is the call graph for this function:

const char* bu_nearest_units_string ( const double  mm)

Given a conversion factor to mm, search the table to find the closest matching unit.

Returns - char* units string NULL Invalid conversion factor (non-positive)

double bu_mm_value ( const char *  s)

Given a string of the form "25cm" or "5.2ft" returns the corresponding distance in mm.

Returns - -1 on error >0 on success

Definition at line 355 of file units.c.

References cvt_tab::name, OSL::Strings::v, and cvt_tab::val.

Referenced by bu_mm_cvt(), bu_parse_mm(), ged_dbcopy(), ged_units(), and str2mm().

void bu_mm_cvt ( const struct bu_structparse sdp,
const char *  name,
void *  base,
const char *  value,
void *  data 
)

Used primarily as a hooked function for bu_structparse tables to allow input of floating point values in other units.

Definition at line 386 of file units.c.

References bu_log(), bu_mm_value(), bu_structparse::sp_offset, and UNLIKELY.

Here is the call graph for this function: