diff --git a/src/ifcgeom/IfcGeomTree.h b/src/ifcgeom/IfcGeomTree.h index 7d8c175c2e..027cd3d903 100644 --- a/src/ifcgeom/IfcGeomTree.h +++ b/src/ifcgeom/IfcGeomTree.h @@ -305,13 +305,19 @@ namespace IfcGeom { void add_file(IfcGeom::Iterator& it) { if (it.initialize()) { do { - IfcGeom::BRepElement* elem = (IfcGeom::BRepElement*)it.get(); - auto compound = elem->geometry().as_compound(); - compound.Move(elem->transformation().data()); - add((IfcUtil::IfcBaseEntity*)it.file()->instance_by_id(elem->id()), compound); + add_element(dynamic_cast*>(it.get())); } while (it.next()); } } + + void add_element(IfcGeom::BRepElement* elem) { + if (!elem) { + return; + } + auto compound = elem->geometry().as_compound(); + compound.Move(elem->transformation().data()); + add(elem->product(), compound); + } }; }