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_make_direction()
IfcDirection * ifcx_vec_make_direction( RoseDesign * d, const double vec[3] ); IfcDirection * ifcx_vec_make_direction( RoseDesign * d, const RoseDirection& vec );
The ifcx_vec_make_direction() function creates a new IFC direction instance in the given design and populates it with all three components. The components are used without change, so any normalization must be done before calling this function.
RoseDirection v1 (0, 1, 0); double v2[3] = {4, 5, 6}; IfcDirection * d1 = ifcx_vec_make_direction(d, v1); // normalized IfcDirection * d2 = ifcx_vec_make_direction(d, v2); // not normalized // The call above produces the following instance data // // #34=IFCDIRECTION((0.,1.,0.)); // #35=IFCDIRECTION((4.,5.,6.));
ifcx_vec_make_point()
IfcCartesianPoint * ifcx_vec_make_point( RoseDesign * d, const double vec[3] ); IfcCartesianPoint * ifcx_vec_make_point( RoseDesign * d, const RosePoint& vec );
The ifcx_vec_make_point() function creates a new IFC cartesian point instance in the given design and populates it with all three coordinates.
RosePoint v1 (96, 97, 98); double v2[3] = {0, 0, 0}; IfcCartesianPoint * d1 = ifcx_vec_make_point(d, v1); IfcCartesianPoint * d2 = ifcx_vec_make_point(d, v2); // origin // The call above produces the following instance data // // #11=IFCCARTESIANPOINT((96.,97.,98.)); // #12=IFCCARTESIANPOINT((0.,0.,0.));
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_make_ap3d()
IfcAxis2Placement3D * ifcx_xform_make_ap3d( RoseDesign * d, const double xf[16] ); IfcAxis2Placement3D * ifcx_xform_make_ap3d( RoseDesign * d, const RoseXform& xf );
The ifcx_xform_make_ap3d() function creates a new axis2_placement_3d instance in the given design and populates it with the origin, Z direction and X direction of the given transform.
RoseXform xf; // an identity matrix by default IfcAxis2Placement3D * ap = ifcx_xform_make_ap3d(d, xf); // The call above produces the following instance data // // #13=IFCAXIS2PLACEMENT3D(#19,#28,#29); // #19=IFCCARTESIANPOINT((0.,0.,0.)); // #28=IFCDIRECTION((0.,0.,1.)); // #29=IFCDIRECTION((1.,0.,0.));
ifcx_xform_make_cto3d()
IfcCartesianTransformationOperator3D * ifcx_xform_make_cto3d( RoseDesign * d, const double xf[16] ); IfcCartesianTransformationOperator3D * ifcx_xform_make_cto3d( RoseDesign * d, const RoseXform& xf );
The ifcx_xform_make_cto3d() function creates a new cartesian transformation operator instance in the given design and populates it with the origin, and all three axis directions of the given transform. The scale factor will always be one (1.0).
RoseXform xf; // an identity matrix by default IfcCartesianTransformationOperator3D * cto = ifcx_xform_make_cto3d(d, xf); // The call above produces the following instance data // // #11=IFCCARTESIANTRANSFORMATIONOPERATOR3D(#33,#34,#21,1.,#35); // #21=IFCCARTESIANPOINT((0.,0.,0.)); // #33=IFCDIRECTION((1.,0.,0.)); // #34=IFCDIRECTION((0.,1.,0.)); // #35=IFCDIRECTION((0.,0.,1.));
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.