Showing posts with label funcparserlib. Show all posts
Showing posts with label funcparserlib. Show all posts

Thursday, July 28, 2011

IFC EXPRESS schema definitions

As you might have heard, IFC files are based on a schema that defines the things that may exist inside an IFC file and how they relate to each other. In order to get up and running quickly, till now IfcOpenShell used a more or less schema-less approach, but from this joyous day on will parse IFC files using the schema definitions provided by buildingSMART. This means we now have the entire inheritance graph at our disposal, which surely might come in handy someday. In plain English this would translate to knowing that an IfcWallStandardCase is a subtype of an IfcWall, which is a special kind of building element, etc.

To be able to generate the required C++ code from the Express schema, I have written some code in Python using Parser combinators, provided by the funcparserlib Python library. Combinatory parsing is an elegant method that combines elementary parsing routines into the complex framework required to parse these kind of files. Unfortunately the code ended up to be less elegant than what was hoped for, but it works for now. Although rules, functions and where clauses are discarded for now. Take a peek at the Python source over here: http://ifcopenshell.svn.sourceforge.net/viewvc/ifcopenshell/src/ifcexpressparser/IfcExpressParser.py?view=markup

Readers of this blog who feel shocked that adding 20.000 lines of generated C++ code to the project has added virtually no additional functionality might find consolation in the fact that it becomes easier now to add new functionality to IfcOpenShell. You go ahead and try for yourself if you don't believe me!

By the way, if you want to generate your own C++ code from the Express schema, you can grab your copy of the Industry Foundation Classes longform EXPRESS schema version 2x3 Technical Corrigendum 1, or IFC2x3_TC1.exp for short, at the buildingSMART tech site at: http://buildingsmart-tech.org/downloads/ifc/ifc2x3tc