6 #ifndef MATERIALX_UNIT_H_
7 #define MATERIALX_UNIT_H_
50 virtual float convert(
float input,
const string& inputUnit,
const string& outputUnit)
const = 0;
64 virtual Vector2 convert(
const Vector2& input,
const string& inputUnit,
const string& outputUnit)
const = 0;
70 virtual Vector3 convert(
const Vector3& input,
const string& inputUnit,
const string& outputUnit)
const = 0;
76 virtual Vector4 convert(
const Vector4& input,
const string& inputUnit,
const string& outputUnit)
const = 0;
114 float conversionRatio(
const string& inputUnit,
const string& outputUnit)
const;
120 float convert(
float input,
const string& inputUnit,
const string& outputUnit)
const override;
126 Vector2 convert(
const Vector2& input,
const string& inputUnit,
const string& outputUnit)
const override;
132 Vector3 convert(
const Vector3& input,
const string& inputUnit,
const string& outputUnit)
const override;
138 Vector4 convert(
const Vector4& input,
const string& inputUnit,
const string& outputUnit)
const override;
158 std::unordered_map<string, float> _unitScale;
159 std::unordered_map<string, int> _unitEnumeration;
189 void clearUnitConverters();
193 int getUnitAsInteger(
const string& unitName)
const;
200 bool convertToUnit(
DocumentPtr doc,
const string& unitType,
const string& targetUnit);
virtual void write(DocumentPtr doc) const =0
Create unit definitions in a document based on the converter.
std::unordered_map< string, UnitConverterPtr > UnitConverterPtrMap
Map of unit converters.
shared_ptr< UnitConverter > UnitConverterPtr
A shared pointer to a UnitConverter.
virtual string getUnitFromInteger(int) const
#define MATERIALX_NAMESPACE_BEGIN
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
Tto convert(const Tfrom &source)
shared_ptr< const LinearUnitConverter > ConstLinearUnitConverterPtr
A shared pointer to a const LinearUnitConverter.
shared_ptr< UnitTypeDef > UnitTypeDefPtr
A shared pointer to a UnitTypeDef.
const std::unordered_map< string, float > & getUnitScale() const
virtual ~UnitConverterRegistry()
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
const string & getUnitType() const
Return the unit type string.
shared_ptr< const UnitConverterRegistry > ConstUnitConverterRegistryPtr
A shared pointer to a const UnitConverterRegistry.
shared_ptr< UnitConverterRegistry > UnitConverterRegistryPtr
A shared pointer to a UnitConverterRegistry.
shared_ptr< const UnitConverter > ConstUnitConverterPtr
A shared pointer to a const UnitConverter.
virtual float convert(float input, const string &inputUnit, const string &outputUnit) const =0
LeafData & operator=(const LeafData &)=delete
virtual ~LinearUnitConverter()
shared_ptr< LinearUnitConverter > LinearUnitConverterPtr
A shared pointer to a LinearUnitConverter.
#define MATERIALX_NAMESPACE_END
virtual int getUnitAsInteger(const string &) const