MCPcopy Create free account
hub / github.com/assimp/assimp / ConvertUnit

Function ConvertUnit

code/AssetLib/IFC/IFCLoader.cpp:312–334  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

310
311// ------------------------------------------------------------------------------------------------
312void ConvertUnit(const Schema_2x3::IfcNamedUnit &unit, ConversionData &conv) {
313 if (const Schema_2x3::IfcSIUnit *const si = unit.ToPtr<Schema_2x3::IfcSIUnit>()) {
314 if (si->UnitType == "LENGTHUNIT") {
315 conv.len_scale = si->Prefix ? ConvertSIPrefix(si->Prefix) : 1.f;
316 IFCImporter::LogDebug("got units used for lengths");
317 }
318 if (si->UnitType == "PLANEANGLEUNIT") {
319 if (si->Name != "RADIAN") {
320 IFCImporter::LogWarn("expected base unit for angles to be radian");
321 }
322 }
323 } else if (const Schema_2x3::IfcConversionBasedUnit *const convu = unit.ToPtr<Schema_2x3::IfcConversionBasedUnit>()) {
324 if (convu->UnitType == "PLANEANGLEUNIT") {
325 try {
326 conv.angle_scale = convu->ConversionFactor->ValueComponent->To<::Assimp::STEP::EXPRESS::REAL>();
327 ConvertUnit(*convu->ConversionFactor->UnitComponent, conv);
328 IFCImporter::LogDebug("got units used for angles");
329 } catch (std::bad_cast &) {
330 IFCImporter::LogError("skipping unknown IfcConversionBasedUnit.ValueComponent entry - expected REAL");
331 }
332 }
333 }
334}
335
336// ------------------------------------------------------------------------------------------------
337void ConvertUnit(const ::Assimp::STEP::EXPRESS::DataType &dt, ConversionData &conv) {

Callers 1

SetUnitsFunction · 0.85

Calls 1

ConvertSIPrefixFunction · 0.85

Tested by

no test coverage detected