From 09c5759a9fe15a1ff6517113f8a56d2b4080835b Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 7 Sep 2018 14:25:46 +0200 Subject: [PATCH] Emit error messages on missing units --- src/ifcgeom/IfcGeomFunctions.cpp | 12 ++++++++++++ src/ifcgeom/IfcGeomIterator.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 7ed8ddc228..feb851b803 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1580,6 +1580,8 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn std::string unit_name = "METER"; double unit_magnitude = 1.; + bool length_unit_encountered = false, angle_unit_encountered = false; + try { IfcEntityList::ptr units = unit_assignment->Units(); if (!units || !units->size()) { @@ -1609,8 +1611,10 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn unit_name = current_unit_name; unit_magnitude = current_unit_magnitude; setValue(IfcGeom::Kernel::GV_LENGTH_UNIT, current_unit_magnitude); + length_unit_encountered = true; } else { setValue(IfcGeom::Kernel::GV_PLANEANGLE_UNIT, current_unit_magnitude); + angle_unit_encountered = true; } } } @@ -1623,6 +1627,14 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn Logger::Message(Logger::LOG_ERROR, ss.str()); } + if (!length_unit_encountered) { + Logger::Error("No length unit encountered"); + } + + if (!angle_unit_encountered) { + Logger::Error("No plane angle unit encountered"); + } + return std::pair(unit_name, unit_magnitude); } diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index e6898df684..499f042c48 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -145,6 +145,8 @@ namespace IfcGeom { std::pair length_unit = kernel.initializeUnits(project->UnitsInContext()); unit_name = length_unit.first; unit_magnitude = length_unit.second; + } else { + Logger::Error("A single IfcProject is expected (encountered " + boost::lexical_cast(projects->size()) + "); unable to read unit information."); } }