Overview
An IFC representation describes the value of a property. Geometric shape is the most common property. A representation contains a set of representation items and a context.
The representation for shape will contain geometry items and placements. A context gives precision information.
Axis Placements and Geometry
The items in a shape representation are all geometric or topologic representation item subtypes.
The "xform" and "vec" functions interface axis placements, directions, and points with the ROSE transform and vector operations. For example, ifcx_xform_put() extracts coordinates and axis directions from IFC placement or transform data, normalizes everything and puts the values into an array of sixteen doubles or RoseXform. The ifcx_vec_put() puts values from a cartesian point, direction, and similar types into an array of three doubles.
Other functions work with associated presentation information.
Contexts
The IFC geometry definitions are unitless, so unit information is supplied by the IfcProject.
A context supplies a precision, which is is the distance below which two points should be considered the same. It is important when exchanging geometry between systems that work at different precisions. In STEP models, this quantity is called the geometric uncertainty.
The ifcx_context_precision() function returns the precision declared by a context. An EXPRESS rule in the IFC model defines a default value of 1e-5 if this is omitted.
ifcx_context_precision()
double ifcx_context_precision( IfcRepresentationContext * ctx ); double ifcx_context_precision( IfcRepresentation * rep );
The ifcx_context_precision() function gets the precision
from an IFC representation context or the context of a representation,
with appropriate behavior for omitted and derived values. If a value
is not present in the data, this function will
return IFCX_DFLT_PRECISION
, which is defined as 1e-5.
ifcx_present_color()
unsigned ifcx_present_color( IfcRepresentationItem * item );
The ifcx_present_color() function gets the color of a representation item. The color comes from associated presentation information, so you must call ifcx_present_tag() before using this function.
The color is returned as a 24-bit RGB value of the form 0x00RRGGBB. If an item does not have any color information, the function return ROSE_MESH_NULL_COLOR.
unsigned rgb = ifcx_present_color(it); unsigned red = (rgb & 0xff0000) >> 16; unsigned green = (rgb & 0x00ff00) >> 8; unsigned blue = (rgb & 0x0000ff); printf (r=%x g=%x b=%x\n, red, green, blue);
ifcx_present_styled_items()
IfcxStyledItemVec * ifcx_present_styled_items( IfcRepresentationItem * item );
The ifcx_present_styled_items() function returns the IfcStyledItem instances that reference a given representation_item. Before this function can be called, you must call ifcx_present_tag().
ifcx_present_tag()
void ifcx_present_tag( RoseDesign * des );
The ifcx_present_tag() function builds indexes on an IFC data set so that ifcx_present_color() and similar functions can find presentation information related to IFC geometry.
ifcx_present_transparency()
double ifcx_present_transparency( IfcRepresentationItem * item );
The ifcx_present_transparency() function gets the transparency state of a representation item. The function returns ROSE_NULL_REAL if an item is opaque, otherwise the number indicates the transparency, with 1.0 being fully transparent.
The transparency state comes from associated presentation information, so you must call ifcx_present_tag() before using this function.
ifcx_vec_put()
int ifcx_vec_put(double xyz[], IfcPoint * pt); int ifcx_vec_put(RosePoint& xyz, IfcPoint * pt); int ifcx_vec_put(double xyz[], IfcCartesianPoint * cpt); int ifcx_vec_put(RosePoint& xyz, IfcCartesianPoint * cpt); int ifcx_vec_put(double ijk[], IfcDirection * dir); int ifcx_vec_put(RoseDirection& ijk, IfcDirection * dir); int ifcx_vec_put(double xyz[], IfcVertex * v); int ifcx_vec_put(RosePoint& xyz, IfcVertex * v); int ifcx_vec2d_put(double xy[], IfcPoint * pt); int ifcx_vec2d_put(RosePoint2D& xy, IfcPoint * pt); int ifcx_vec2d_put(double xy[], IfcCartesianPoint * pt); int ifcx_vec2d_put(RosePoint2D& xy, IfcCartesianPoint * pt); int ifcx_vec2d_put(double ij[], IfcDirection * dir); int ifcx_vec2d_put(RoseDirection2D& ij, IfcDirection * dir);
The ifcx_vec_put() function extracts IFC coordinate or direction data into a RosePoint, RoseDirection, or array of doubles for transform and vector math. The function returns nonzero if the assignment succeeded or zero if there was a problem. The ifcx_vec2d_put() versions extract a 2D result.
With a cartesian point, the coordinates list is extracted. If the point or coordinates list are null, or if the list does not contain enough coordinates, zero will be substituted for the missing values. The assignment will always succeed unless it is passed a null destination array. The version that takes an IfcPoint expects the value to be a cartesian point.
RosePoint dst_pt; IfcCartesianPoint * pt = get_some_point(); ifcx_vec_put(dst_pt, pt);
With a direction, the ratios list is extracted. If the direction or list are null, or if the list does not contain enough ratios, zero will be substituted for the missing values. The assignment will always succeed unless it is passed a null destination array. Use rose_vec_is_zero() to test for missing direction data.
RoseDirection dst_dir; IfcDirection * dir = get_some_dir(); ifcx_vec_put(dst_dir, dir); if (rose_vec_is_zero(dst_dir)) printf (MISSING DIRECTION DATA!!\n); rose_vec_normalize(dst_dir); // if you want normalized data
With a vertex, the function will cast it to a IfcVertexPoint and set the array from the cartesian point referenced as the vertex_geometry. The function will set the array to all zeros and return zero if the vertex is not a IfcVertexPoint, or of the vertex_geometry is missing or not a cartesian point.
RosePoint dst_pt; IfcVertex * vtx = get_some_topology(); if (!ifcx_vec_put(dst_pt, vtx)) printf (BAD VERTEX DATA!!\n);
ifcx_xform_compose()
void ifcx_xform_compose( RoseXform& result, const RoseXform& xform, IfcCartesianTransformationOperator * op ); void ifcx_xform_compose( RoseXform& xform, IfcCartesianTransformationOperator * op ); void ifcx_xform_compose( RoseXform& result, const RoseXform& xform, IfcAxis2Placement * ap ); void ifcx_xform_compose( RoseXform& xform, IfcAxis2Placement * ap );
The ifcx_xform_compose() function calls rose_xform_compose() to transform a matrix with a matrix built from an IFC object. The result is calculated by matrix multiplication orig_xform * ifx_obj_xform.
ifcx_xform_put()
int ifcx_xform_put(double xf[16], IfcAxis1Placement * ap); int ifcx_xform_put(RoseXform& xf, IfcAxis1Placement * ap); int ifcx_xform_put(double xf[16], IfcAxis2Placement2D * ap); int ifcx_xform_put(RoseXform& xf, IfcAxis2Placement2D * ap); int ifcx_xform_put(double xf[16], IfcAxis2Placement3D * ap); int ifcx_xform_put(RoseXform& xf, IfcAxis2Placement3D * ap); int ifcx_xform_put(double xf[16], IfcAxis2Placement * ap); int ifcx_xform_put(RoseXform& xf, IfcAxis2Placement * ap); int ifcx_xform_put(double xf[16], IfcCartesianTransformationOperator * cto); int ifcx_xform_put(RoseXform& xf, IfcCartesianTransformationOperator * cto); int ifcx_xform_put(double xf[16], IfcObjectPlacement * place); int ifcx_xform_put(RoseXform& xf, IfcObjectPlacement * place); // versions that operate with a 2D transform matrix int ifcx_xform2d_put(double xf[9], IfcAxis2Placement2D * ap); int ifcx_xform2d_put(RoseXform2D& xf, IfcAxis2Placement2D * ap); int ifcx_xform2d_put(double xf[9], IfcAxis2Placement3D * ap); int ifcx_xform2d_put(RoseXform2D& xf, IfcAxis2Placement3D * ap); int ifcx_xform2d_put(double xf[9], IfcAxis2Placement * ap); int ifcx_xform2d_put(RoseXform2D& xf, IfcAxis2Placement * ap); int ifcx_xform2d_put(double xf[9], IfcCartesianTransformationOperator * cto); int ifcx_xform2d_put(RoseXform2D& xf, IfcCartesianTransformationOperator * cto);
The ifcx_xform_put() function builds a 4x4 transform matrix from an IFC axis placement for use in transform and vector math. There are versions for each of the different ways to describe axis plancements in IFC as well as versions that populate an array of sixteen doubles or a RoseXform wrapper class.
The function returns nonzero if the assignment succeeded or zero if there was a problem. If a 2D axis placement is provided, the result will be a 3D transform at Z=0 with the default Z direction.
An axis placement will produce a normalized, right-handed, orthogonal matrix with all defaults handled properly as discussed by rose_xform_put_dirs().
A cartesian transformation operator will be normalized and may have a scaling factor applied. A CTO may also describe a left-handed coordinate system as discussed by rose_xform_put_cto().
An IfcObjectPlacement will produce a single matrix that composes together all of the transforms described by the nested "relative to" placements.
The ifcx_xform2d_put() functions build a 3x3 transform matrix, either an array of nine doubles or a RoseXform2D wrapper class.
A 3D axis placement can be provided to the 2D function. The resulting 2D matrix will be built with the given X direction. This will have similar XY directions if the Z direction is positive, but will flip the Y direction to maintain a right hand coordinate system if the original 3D placement had a negative Z direction.