Emit error messages on missing units

This commit is contained in:
Thomas Krijnen
2018-09-07 14:25:46 +02:00
parent 7e7da9cb1a
commit 09c5759a9f
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -1580,6 +1580,8 @@ std::pair<std::string, double> 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<std::string, double> 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<std::string, double> 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<std::string, double>(unit_name, unit_magnitude);
}
+2
View File
@@ -145,6 +145,8 @@ namespace IfcGeom {
std::pair<std::string, double> 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<std::string>(projects->size()) + "); unable to read unit information.");
}
}