MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / LinearUnitConverter

Method LinearUnitConverter

source/MaterialXCore/Unit.cpp:21–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19//
20
21LinearUnitConverter::LinearUnitConverter(UnitTypeDefPtr unitTypeDef)
22{
23 if (!unitTypeDef)
24 {
25 return;
26 }
27
28 // Populate the unit scale and offset maps for each UnitDef.
29 unsigned int enumerant = 0;
30 for (UnitDefPtr unitdef : unitTypeDef->getUnitDefs())
31 {
32 for (UnitPtr unit : unitdef->getUnits())
33 {
34 const string& name = unit->getName();
35 if (!name.empty())
36 {
37 const string& scaleString = unit->getAttribute(SCALE_ATTRIBUTE);
38 if (!scaleString.empty())
39 {
40 ValuePtr scaleValue = Value::createValueFromStrings(scaleString, getTypeString<float>());
41 _unitScale[name] = scaleValue->asA<float>();
42 }
43 else
44 {
45 _unitScale[name] = 1.0f;
46 }
47 _unitEnumeration[name] = enumerant++;
48 }
49 }
50 }
51
52 _unitType = unitTypeDef->getName();
53}
54
55LinearUnitConverterPtr LinearUnitConverter::create(UnitTypeDefPtr unitTypeDef)
56{

Callers

nothing calls this directly

Calls 4

createValueFromStringsFunction · 0.85
getUnitDefsMethod · 0.80
getNameMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected