MaterialX 1.39.1
Loading...
Searching...
No Matches
UnitConverter Class Referenceabstract

An abstract base class for unit converters. More...

#include <Unit.h>

Inheritance diagram for UnitConverter:
LinearUnitConverter

Public Member Functions

virtual float convert (float input, const string &inputUnit, const string &outputUnit) const =0
 Convert a given value in a given unit to a desired unit. More...
 
virtual int getUnitAsInteger (const string &) const
 Given a unit name return a value that it can map to as an integer Returns -1 value if not found. More...
 
virtual string getUnitFromInteger (int) const
 Given an integer index return the unit name in the map used by the converter Returns Empty string if not found. More...
 
virtual Vector2 convert (const Vector2 &input, const string &inputUnit, const string &outputUnit) const =0
 Convert a given value in a given unit to a desired unit. More...
 
virtual Vector3 convert (const Vector3 &input, const string &inputUnit, const string &outputUnit) const =0
 Convert a given value in a given unit to a desired unit. More...
 
virtual Vector4 convert (const Vector4 &input, const string &inputUnit, const string &outputUnit) const =0
 Convert a given value in a given unit to a desired unit. More...
 
virtual void write (DocumentPtr doc) const =0
 Create unit definitions in a document based on the converter. More...
 

Detailed Description

An abstract base class for unit converters.

Each unit converter instance is responsible for a single unit type.

Member Function Documentation

◆ convert() [1/4]

virtual Vector2 convert ( const Vector2 input,
const string &  inputUnit,
const string &  outputUnit 
) const
pure virtual

Convert a given value in a given unit to a desired unit.

Parameters
inputInput value to convert
inputUnitUnit of input value
outputUnitUnit for output value

Implemented in LinearUnitConverter.

◆ convert() [2/4]

virtual Vector3 convert ( const Vector3 input,
const string &  inputUnit,
const string &  outputUnit 
) const
pure virtual

Convert a given value in a given unit to a desired unit.

Parameters
inputInput value to convert
inputUnitUnit of input value
outputUnitUnit for output value

Implemented in LinearUnitConverter.

◆ convert() [3/4]

virtual Vector4 convert ( const Vector4 input,
const string &  inputUnit,
const string &  outputUnit 
) const
pure virtual

Convert a given value in a given unit to a desired unit.

Parameters
inputInput value to convert
inputUnitUnit of input value
outputUnitUnit for output value

Implemented in LinearUnitConverter.

◆ convert() [4/4]

virtual float convert ( float  input,
const string &  inputUnit,
const string &  outputUnit 
) const
pure virtual

Convert a given value in a given unit to a desired unit.

Parameters
inputInput value to convert
inputUnitUnit of input value
outputUnitUnit for output value

Implemented in LinearUnitConverter.

◆ getUnitAsInteger()

virtual int getUnitAsInteger ( const string &  ) const
inlinevirtual

Given a unit name return a value that it can map to as an integer Returns -1 value if not found.

Reimplemented in LinearUnitConverter.

◆ getUnitFromInteger()

virtual string getUnitFromInteger ( int  ) const
inlinevirtual

Given an integer index return the unit name in the map used by the converter Returns Empty string if not found.

Reimplemented in LinearUnitConverter.

◆ write()

virtual void write ( DocumentPtr  doc) const
pure virtual

Create unit definitions in a document based on the converter.

Implemented in LinearUnitConverter.


The documentation for this class was generated from the following file: