mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Emit error messages on missing units
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user