From 101ef69ae9b888959c79f713a38f3431d6132c7d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 20 Jun 2017 18:55:52 +0200 Subject: [PATCH] Fail serialize() if one of the faces cannot be mapped to IFC (2x3) --- src/ifcgeom/IfcGeomSerialisation.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ifcgeom/IfcGeomSerialisation.cpp b/src/ifcgeom/IfcGeomSerialisation.cpp index 1cbdcd097c..7b41c2fa8f 100644 --- a/src/ifcgeom/IfcGeomSerialisation.cpp +++ b/src/ifcgeom/IfcGeomSerialisation.cpp @@ -473,11 +473,22 @@ template int convert_to_ifc(const TopoDS_Shape& s, U*& item, bool advanced) { IfcSchema::IfcFace::list::ptr faces(new IfcSchema::IfcFace::list); IfcSchema::IfcFace* f; + for (TopExp_Explorer exp(s, TopAbs_FACE); exp.More(); exp.Next()) { if (convert_to_ifc(TopoDS::Face(exp.Current()), f, advanced)) { faces->push(f); + } else { + /// Cleanup: + for (auto it = faces->begin(); it != faces->end(); ++it) { + IfcEntityList::ptr data = IfcParse::traverse(*it)->unique(); + for (auto jt = data->begin(); jt != data->end(); ++jt) { + delete *jt; + } + } + return 0; } } + item = new U(faces); return faces->size(); }