From b00acd3f677c027308dd8f4933ce8529226d51b6 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 4 Aug 2017 16:31:34 +0200 Subject: [PATCH] only convert length unit if units are present in both files --- src/ifcparse/IfcParse.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 260f362104..792f07db36 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1510,8 +1510,14 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) { entity->getArgumentEntity(i) == IfcSchema::Type::IfcPositiveLengthMeasure) { if (boost::math::isnan(conversion_factor)) { - conversion_factor = other_file->getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT).second / - getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT).second; + const std::pair this_file_unit = getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT); + const std::pair other_file_unit = other_file->getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT); + std::cerr << other_file_unit.second << " " << this_file_unit.second << std::endl; + if (this_file_unit.first && other_file_unit.first) { + conversion_factor = other_file_unit.second / this_file_unit.second; + } else { + conversion_factor = 1.; + } } if (attr_type == IfcUtil::Argument_DOUBLE) { double v = *attr;