Overview
The IFC data model for units covers SI units, units based on conversion factors and ones derived from multiple base units. For easier use, the functions described below analyze the IFC data and mark common units using the unit enums provided by the ROSE Math library.
All definitions are in the ifcx_unit.h header file.
The RoseUnit enumeration identifies commonly used units, and simplifies reasoning with IFC unit descriptions. Before these can be used, the units in a file must be recognized and annotated with ifcx_unit_tag(). Once the units are tagged, the ifcx_unit_get_type() function returns the unit enum value for unit, measure, and context data types.
The following project functions return the units that apply to an IFC data set.
- ifcx_project_angle_unit()
- ifcx_project_length_unit()
- ifcx_project_solid_angle_unit()
- ifcx_project_find_unit() for other units
ifcx_unit_get_fullname()
const char * ifcx_unit_get_fullname (IfcUnit * u); const char * ifcx_unit_get_fullname (IfcNamedUnit * u); const char * ifcx_unit_get_fullname (IfcDerivedUnit * u); const char * ifcx_unit_get_fullname (IfcMeasureWithUnit * mwu); const char * ifcx_unit_get_fullname (RoseUnit u);
The ifcx_unit_get_fullname() function returns a formal name
for the unit, such as millimetre
. There are several overloaded
versions of this function for the different types of unit values.
This simply
calls ifcx_unit_get_type() to find
the unit enum and passes that to
rose_get_unit_fullname()
ifcx_unit_get_measure_type()
RoseMeasureType ifcx_unit_get_measure_type (IfcUnit * u); RoseMeasureType ifcx_unit_get_measure_type (IfcNamedUnit * u); RoseMeasureType ifcx_unit_get_measure_type (IfcDerivedUnit * u); RoseMeasureType ifcx_unit_get_measure_type (IfcMeasureWithUnit * mwu); RoseMeasureType ifcx_unit_get_measure_type (RoseUnit u);
The ifcx_unit_get_measure_type() function returns the RoseMeasureType enum that describes the type of quantity for a unit or measure. There are several overloaded versions of this function for the different types of IFC unit data objects. If given a measure object, this function will extract the unit description from it.
This function expects the units to have been previously recognized and tagged with the ifcx_unit_tag() function. It will return rosemeasure_unknown if the units have not been tagged or if the unit described by the data object was not recognized.
The version that takes a unit enum is simply an for rose_get_measure_type()
ifcx_unit_get_name()
const char * ifcx_unit_get_name (IfcUnit * u); const char * ifcx_unit_get_name (IfcNamedUnit * u); const char * ifcx_unit_get_name (IfcDerivedUnit * u); const char * ifcx_unit_get_name (IfcMeasureWithUnit * mwu); const char * ifcx_unit_get_name (RoseUnit u);
The ifcx_unit_get_name() function returns a concise name for
the unit, such as mm
. There are several overloaded versions of
this function for the different types of unit values. This simply
calls ifcx_unit_get_type() to find
the unit enum and passes that to
rose_get_unit_name()
ifcx_unit_get_ifcenum/derenum()
IfcUnitEnum ifcx_unit_get_ifcenum (RoseMeasureType vt); IfcDerivedUnitEnum ifcx_unit_get_ifcderenum (RoseMeasureType vt);
The ifcx_unit_get_ifcenum() and ifcx_unit_get_ifcderenum() functions map between the quantity type enum used by the ROSE Math library and the quantity type enums defined by the IFC schema. These are primarily used by ifcx_unit_make() when authoring unit data but are also available for use by application code.
ifcx_unit_get_type()
RoseUnit ifcx_unit_get_type (IfcUnit * u); RoseUnit ifcx_unit_get_type (IfcNamedUnit * u); RoseUnit ifcx_unit_get_type (IfcDerivedUnit * u); RoseUnit ifcx_unit_get_type (IfcMeasureWithUnit * mwu);
The ifcx_unit_get_type() function returns the RoseUnit enum value identifying a unit. There are several overloaded versions of this function for the different types of unit data objects. If given a measure object, this function will extract the unit description from it.
This function expects the units to have been previously recognized and tagged with the ifcx_unit_tag() function. It will return roseunit_unknown if the units have not been tagged or if the unit described by the data object was not recognized.
ifcx_unit_make()
RoseObject * ifcx_unit_make( RoseDesign * d, RoseUnit ut );
The ifcx_unit_make() function returns the IFC instance for a particular RoseUnit enum value. The function returns an existing instance if one is present, otherwise it creates one. Since the IFC instance might be an IfcNamedUnit or IfcDerivedUnit, the function returns a pointer of the more general RoseObject type.
See ifcx_unit_make_select() and ifcx_unit_make_named() for versions that return values convenient for other situations.
ifcx_unit_make_named()
IfcNamedUnit * ifcx_unit_make_named( RoseDesign * d, RoseUnit ut );
The ifcx_unit_make_named() function is a wrapper around ifcx_unit_make() that casts the return value to the named_unit type for more convenient use in cartain contexts. The function will return null if you request a unit that is represented by the derived unit type.
ifcx_unit_make_select()
IfcUnit * ifcx_unit_make_select( RoseDesign * d, RoseUnit ut );
The ifcx_unit_make_select() function is a wrapper around ifcx_unit_make() that creates a unit definition and wraps it in the IfcUnit SELECT type for more convenient use. Since the named unit and derived unit definitions do not share a common supertype, the select is used in many places in the IFC models that reference a unit.
ifcx_unit_tag()
void ifcx_unit_tag (RoseDesign * d);
The ifcx_unit_tag function analyzes all IFC unit definitions in a file and calculates a RoseUnit and RoseMeasureType enum value for each one. Use the ifcx_unit_get_type() and ifcx_unit_get_measure_type() functions to get these values for a particular data object.