Overview

When reading IFC data, the library will examine the schema version in the header and then try to migrate any older data to the latest IFC4 definitions. Use the ifclib_get_schema() function to find out which IFC version was used by the file. It returns an IfclibSchemaType enum, which can be changed when when writing files. If the type is "other", use the ifclib_get_schema_name() function to get the original schema name as a string.

Many entity definitions have changed in IFC4. Most of the changes add new attributes, but several modify or delete attributes. The IFC documentation on the BuildingSmart site has a summary of changes a detailed table of changes by entity. The library currently reads older IFC files and warns about the added or deleted IFC4 attributes. As time goes on, we continue to improve migration for older IFC data.

The code below reads files produced by the writing example and prints the schema information for each. It also prints a list of instances found in the file and the C++ class name of each.

#include <ifc_schema.h>

void print_info (RoseDesign *d)
{
    printf (==> schemaname: %s\n, ifclib_get_schema_name (d));

    switch (ifclib_get_schema (d)) {
    case ifclib_schema_none:	printf (==> no schema set\n);  break;
    case ifclib_schema_ifc4: 	printf (==> IFC4 file\n);  break;
    case ifclib_schema_ifc4x1: 	printf (==> IFC4x1 file\n);  break;
    case ifclib_schema_ifc2x3: 	printf (==> 2x3 file\n);  break;
    case ifclib_schema_ifc2x2: 	printf (==> 2x2 file\n);  break;
    case ifclib_schema_other:	printf (==> Other type of file\n);  break;
    }

    RoseCursor objs;
    RoseObject * obj;
    objs.traverse(d);

    while ((obj=objs.next()) != 0) {
	printf (\t#%lu instance of %s\n, 
		obj-> entity_id(), obj->className());
    }
}

void main()
{
    ifclib_init();

    printf (Using null pointer\n);
    print_info (0);
    printf (Using new design\n);
    print_info (new RoseDesign (foo));
    print_info (ROSE.findDesign (test_default.ifc));
    print_info (ROSE.findDesign (test_2x4.ifc));
    print_info (ROSE.findDesign (test_2x3.ifc));
    print_info (ROSE.findDesign (test_2x2.ifc));
}
The code will print the following output:
Using null pointer
==> schemaname: IFC4
==> no schema set
Using new design
==> schemaname: IFC4
==> no schema set
Reading: .\test_default.ifc
==> schemaname: IFC4
==> IFC4 file
        #10 instance of IfcCartesianPoint
        #11 instance of IfcCartesianPoint
        #12 instance of IfcCartesianPoint
Reading: .\test_2x4.ifc
==> schemaname: IFC4
==> IFC4 file
        #10 instance of IfcCartesianPoint
        #11 instance of IfcCartesianPoint
        #12 instance of IfcCartesianPoint
Reading: .\test_2x3.ifc
==> schemaname: IFC2X3
==> 2x3 file
        #10 instance of IfcCartesianPoint
        #11 instance of IfcCartesianPoint
        #12 instance of IfcCartesianPoint
Reading: .\test_2x2.ifc
==> schemaname: IFC2X2
==> 2x2 file
        #10 instance of IfcCartesianPoint
        #11 instance of IfcCartesianPoint
        #12 instance of IfcCartesianPoint