From 0f73c436380dce7c477984f49e2b3958f0111344 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 22 Sep 2021 20:04:40 +1000 Subject: [PATCH] Fixes from code review. --- src/ifcgeom/IfcGeomIteratorImplementation.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomIteratorImplementation.h b/src/ifcgeom/IfcGeomIteratorImplementation.h index 38af8930d2..676db8f5de 100644 --- a/src/ifcgeom/IfcGeomIteratorImplementation.h +++ b/src/ifcgeom/IfcGeomIteratorImplementation.h @@ -497,11 +497,25 @@ namespace IfcGeom { void addRepresentationsFromContextIds() { for (auto context_id : settings.context_ids()) { IfcSchema::IfcGeometricRepresentationContext* context = ifc_file->instance_by_id(context_id)->as(); + + if (!context) { + Logger::Error("Failed to process context ID " + std::to_string(context_id)); + continue; + } + representations->push(context->RepresentationsInContext()); try { - if (context->Precision() && *context->Precision() < lowest_precision_encountered) { - lowest_precision_encountered = *context->Precision(); + double precision; + + if (context->as()) { + precision = *context->as()->ParentContext()->Precision(); + } else { + precision = *context->Precision(); + } + + if (precision && precision < lowest_precision_encountered) { + lowest_precision_encountered = precision; any_precision_encountered = true; } } catch (const std::exception& e) {