MaterialX 1.39.1
Loading...
Searching...
No Matches
LinearUnitConverter Class Reference

A converter class for linear units that require only a scalar multiplication. More...

#include <Unit.h>

Inheritance diagram for LinearUnitConverter:
UnitConverter

Public Member Functions

const string & getUnitType () const
 Return the unit type string.
 
void write (DocumentPtr doc) const override
 Create unit definitions in a document based on the converter. More...
 
Conversion
const std::unordered_map< string, float > & getUnitScale () const
 Return the mappings from unit names to the scale value defined by a linear converter.
 
float conversionRatio (const string &inputUnit, const string &outputUnit) const
 Ratio between the given unit to a desired unit. More...
 
float convert (float input, const string &inputUnit, const string &outputUnit) const override
 Convert a given value in a given unit to a desired unit. More...
 
Vector2 convert (const Vector2 &input, const string &inputUnit, const string &outputUnit) const override
 Convert a given value in a given unit to a desired unit. More...
 
Vector3 convert (const Vector3 &input, const string &inputUnit, const string &outputUnit) const override
 Convert a given value in a given unit to a desired unit. More...
 
Vector4 convert (const Vector4 &input, const string &inputUnit, const string &outputUnit) const override
 Convert a given value in a given unit to a desired unit. More...
 
Shader Mapping
int getUnitAsInteger (const string &unitName) const override
 Given a unit name return a value that it can map to as an integer. More...
 
virtual string getUnitFromInteger (int index) const override
 Given an integer index return the unit name in the map used by the converter. More...
 
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...
 

Static Public Member Functions

static LinearUnitConverterPtr create (UnitTypeDefPtr UnitDef)
 Creator.
 

Detailed Description

A converter class for linear units that require only a scalar multiplication.

Member Function Documentation

◆ conversionRatio()

float conversionRatio ( const string &  inputUnit,
const string &  outputUnit 
) const

Ratio between the given unit to a desired unit.

Parameters
inputUnitUnit of input value
outputUnitUnit for output value

◆ convert() [1/4]

Vector2 convert ( const Vector2 input,
const string &  inputUnit,
const string &  outputUnit 
) const
overridevirtual

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

Implements UnitConverter.

◆ convert() [2/4]

Vector3 convert ( const Vector3 input,
const string &  inputUnit,
const string &  outputUnit 
) const
overridevirtual

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

Implements UnitConverter.

◆ convert() [3/4]

Vector4 convert ( const Vector4 input,
const string &  inputUnit,
const string &  outputUnit 
) const
overridevirtual

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

Implements UnitConverter.

◆ convert() [4/4]

float convert ( float  input,
const string &  inputUnit,
const string &  outputUnit 
) const
overridevirtual

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

Implements UnitConverter.

◆ getUnitAsInteger()

int getUnitAsInteger ( const string &  unitName) const
overridevirtual

Given a unit name return a value that it can map to as an integer.

Returns -1 value if not found

Reimplemented from UnitConverter.

◆ getUnitFromInteger()

virtual string getUnitFromInteger ( int  index) const
overridevirtual

Given an integer index return the unit name in the map used by the converter.

Returns Empty string if not found

Reimplemented from UnitConverter.

◆ write()

void write ( DocumentPtr  doc) const
overridevirtual

Create unit definitions in a document based on the converter.

Implements UnitConverter.


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