From 0087fa875bb3908d2080ce1aff0be4fc6bebe903 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 7 Aug 2021 13:01:52 +0200 Subject: [PATCH] separate tree::add_element(), dynamic_cast<> for invalid settings --- src/ifcgeom/IfcGeomTree.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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); + } }; }