/* * Copyright (c) 1991-2023 by STEP Tools Inc. * All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation is hereby granted, provided that this copyright * notice and license appear on all copies of the software. * * STEP TOOLS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. STEP TOOLS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. * * Author: Dave Loffredo (loffredo@steptools.com) */ #include #include // PRINT SPATIAL STRUCTURE - This IFC program recursively prints the // spatial structure defined in a file, beginning with the IfcProject // root. Use this as the starting point for a more sophisticated // program. void printStruct (IfcObjectDefinition * elem, unsigned indent = 0); int main(int /*argc*/, char** /*argv*/) { ifclib_init(); // force optimizing linkers to use all C++ classes RoseCursor objs; RoseObject * obj; // read file, change to your own as needed RoseDesign * design = ROSE.findDesign("geometry_out.ifc"); if (!design) { printf ("Could not open IFC file\n"); return 1; } // Find the project and print all children objs.traverse(design); objs.domain(ROSE_DOMAIN(IfcProject)); while ((obj=objs.next()) != 0) { IfcProject * root = ROSE_CAST(IfcProject,obj); printStruct (root); } return 0; } void printStruct (IfcObjectDefinition * elem, unsigned indent) { unsigned i, sz; // Print info about the current object for (i=0; idomain()->name(), elem->entity_id(), (elem-> Name()? elem-> Name(): "") ); // Find all related substructures RoseObject * obj; RoseCursor objs; objs.traverse (elem-> design()); objs.domain (ROSE_DOMAIN(IfcRelAggregates)); while ((obj=objs.next()) != 0) { IfcRelAggregates * agg = ROSE_CAST(IfcRelAggregates,obj); // Only look at children of elem if (elem != agg-> RelatingObject()) continue; // recursively traverse the subcomponent SetOfIfcObjectDefinition * subs = agg-> RelatedObjects(); for (i=0, sz=subs->size(); i get(i), indent + 1); } }