Take unit information into account when applying precision. Thanks Stefan

This commit is contained in:
Thomas Krijnen
2014-11-26 13:08:47 +00:00
parent 7f8d84a1af
commit eb815120dc
+10 -4
View File
@@ -606,6 +606,9 @@ double UnitPrefixToValue( IfcSchema::IfcSIPrefix::IfcSIPrefix v ) {
else return 1.0f;
}
static std::string unit_name = "METER";
static float unit_magnitude = 1.0f;
void IfcGeomObjects::InitPrecision() {
IfcGeom::SetValue(IfcGeom::GV_PRECISION, 0.00001);
@@ -631,7 +634,13 @@ void IfcGeomObjects::InitPrecision() {
}
}
if (any_precision_encountered) {
IfcGeom::SetValue(IfcGeom::GV_PRECISION, lowest_precision_encountered);
lowest_precision_encountered *= unit_magnitude;
if (lowest_precision_encountered < 1.e-8) {
Logger::Message(Logger::LOG_WARNING, "Precision lower than 0.00000001 meter not enforced");
IfcGeom::SetValue(IfcGeom::GV_PRECISION, 1.e-8);
} else {
IfcGeom::SetValue(IfcGeom::GV_PRECISION, lowest_precision_encountered);
}
}
} catch (const IfcParse::IfcException& ex) {
std::stringstream ss;
@@ -640,9 +649,6 @@ void IfcGeomObjects::InitPrecision() {
}
}
static std::string unit_name = "METER";
static float unit_magnitude = 1.0f;
void IfcGeomObjects::InitUnits() {
// Set default units, set length to meters, angles to undefined
IfcGeom::SetValue(IfcGeom::GV_LENGTH_UNIT,1.0);