neuray API Programmer's Manual

MDL type system

[Neuray API]

Description

The MDL type system mainly consists of four sets of interfaces:Types are represented by mi::neuraylib::IType and are constructed via mi::neuraylib::IType_factory,Values are represented by mi::neuraylib::IValue and are constructed via mi::neuraylib::IValue_factory,Expressions are represented by mi::neuraylib::IExpression and are constructed via mi::neuraylib::IExpression_factory, andAnnotations are represented by mi::neuraylib::IAnnotation and are constructed via mi::neuraylib::IExpression_factory. The three factories mentioned above can be obtained from mi::neuraylib::IMdl_factory.

In addition, the free functions mi::neuraylib::get_value() and mi::neuraylib::set_value() are useful to read and write instances of mi::neuraylib::IValue.

See MDL-related elements and Miscellaneous MDL-related Interfaces for interfaces that make use of this type system.

Classes

class 
An annotation is similar to a direct call expression, but without return type. More...
class 
An annotation block is an array of annotations. More...
class 
An annotation definition. More...
class 
An ordered collection of annotation blocks identified by name or index. More...
class 
The interface to MDL expressions. More...
class 
An indirect call expression. More...
class 
A constant expression. More...
class 
A direct call expression. More...
class 
The interface for creating expressions. More...
class 
An ordered collection of expressions identified by name or index. More...
class 
A parameter reference expression. More...
class 
A temporary reference expression. More...
class 
The interface to MDL types. More...
class 
The type of kind alias. More...
class 
The type of kind array. More...
class 
An atomic type. More...
class 
The type of kind bool. More...
class 
The type of kind bsdf. More...
class 
The type of kind bsdf_measurement. More...
class 
The type of kind color. More...
class 
A compound type. More...
class 
The type of distribution functions. More...
class 
The type of kind double. More...
class 
The type of kind edf. More...
class 
A type of kind enum. More...
class 
The interface for creating types. More...
class 
The type of kind float. More...
class 
The type of kind bsdf. More...
class 
The type of kind int. More...
class 
The type of kind light_profile. More...
class 
An ordered collection of types identified by name or index. More...
class 
The type of kind matrix. More...
class 
The reference types. More...
class 
A string valued resource type. More...
class 
The type of kind string. More...
class 
The type of kind struct. More...
class 
The type of kind texture. More...
class 
The type of kind vdf. More...
class 
The type of kind vector. More...
class 
The interface to MDL values. More...
class 
A value of type array. More...
class 
An atomic value. More...
class 
A value of type boolean. More...
class 
A BSDF measurement value. More...
class 
A value of type color. More...
class 
A compound value. More...
class 
A value of type double. More...
class 
A value of type enum. More...
class 
The interface for creating values. More...
class 
A value of type float. More...
class 
A value of type integer. More...
class 
An invalid distribution function value. More...
class 
A light profile value. More...
class 
An ordered collection of values identified by name or index. More...
class 
A value of type matrix. More...
class 
Base class for resource values. More...
class 
A value of type string. More...
class 
A value of type string which can be used to obtain the original, non-localized value of a localized string. More...
class 
A value of type struct. More...
class 
A texture value. More...
class 
A value of type vector. More...

Enumerations

enum mi::neuraylib::Mdl_version{ MDL_VERSION_1_0, MDL_VERSION_1_1, MDL_VERSION_1_2, MDL_VERSION_1_3, MDL_VERSION_1_4, MDL_VERSION_1_5, MDL_VERSION_1_6, MDL_VERSION_1_7, MDL_VERSION_1_8, MDL_VERSION_EXP, MDL_VERSION_LATEST = MDL_VERSION_1_8, MDL_VERSION_INVALID = 0xffffffffU, MDL_VERSION_FORCE_32_BIT = 0xffffffffU}
The MDL version.

Functions

template< class T>mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, T& v)
Simplifies reading the value of mi::neuraylib::IValue into the corresponding classes from the base and math API. More...
mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, bool& v)
This specialization handles mi::neuraylib::IValue_bool. More...
mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​Float32& v)
This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. More...
mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​Float64& v)
This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. More...
mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, const char*& v)
This specialization handles mi::neuraylib::IValue_enum, mi::neuraylib::IValue_string and mi::neuraylib::IValue_resource. More...
template< class T, Size>mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Vector < T , DIM >& v)
This specialization handles mi::neuraylib::IValue_vector. More...
template< class T, Size, Size>mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Matrix < T , ROW , COL >& v)
This specialization handles mi::neuraylib::IValue_matrix. More...
mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Color& v)
This specialization handles mi::neuraylib::IValue_color. More...
mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Spectrum& v)
This specialization handles mi::neuraylib::IValue_color. More...
template< class T>mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​Size index, T& v)
This variant handles elements of compounds identified via an additional index. More...
template< class T>mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, const char* name, T& v)
This variant handles fields of structs identified via an additional field name. More...
template< class T>mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, T* v, mi::​Size n)
This variant handles entire arrays. More...
template< class T>mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const T& v)
Simplifies setting the value of mi::neuraylib::IValue from the corresponding classes from the base and math API. More...
mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const bool& v)
This specialization handles mi::neuraylib::IValue_bool. More...
mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​Float32& v)
This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. More...
mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​Float64& v)
This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. More...
mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const char* v)
This specialization handles mi::neuraylib::IValue_enum, mi::neuraylib::IValue_string and mi::neuraylib::IValue_resource. More...
template< class T, Size>mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Vector < T , DIM >& v)
This specialization handles mi::neuraylib::IValue_vector. More...
template< class T, Size, Size>mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Matrix < T , ROW , COL >& v)
This specialization handles mi::neuraylib::IValue_matrix. More...
mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Color& v)
This specialization handles mi::neuraylib::IValue_color. More...
mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Spectrum& v)
This specialization handles mi::neuraylib::IValue_color. More...
template< class T>mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, mi::​Size index, const T& v)
This variant handles elements of compounds identified via an additional index. More...
template< class T>mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const char* name, const T& v)
This variant handles fields of structs identified via an additional field name. More...
template< class T>mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const T* v, mi::​Size n)
This variant handles entire arrays. More...

Enums

enum mi::neuraylib::Mdl_version

The MDL version.

Enumerator:

MDL_VERSION_1_0
MDL version 1.0.
MDL_VERSION_1_1
MDL version 1.1.
MDL_VERSION_1_2
MDL version 1.2.
MDL_VERSION_1_3
MDL version 1.3.
MDL_VERSION_1_4
MDL version 1.4.
MDL_VERSION_1_5
MDL version 1.5.
MDL_VERSION_1_6
MDL version 1.6.
MDL_VERSION_1_7
MDL version 1.7.
MDL_VERSION_1_8
MDL version 1.8.
MDL_VERSION_EXP
MDL experimental features.
MDL_VERSION_LATEST = MDL_VERSION_1_8
Latest MDL version.
MDL_VERSION_INVALID = 0xffffffffU
Invalid MDL version.
MDL_VERSION_FORCE_32_BIT = 0xffffffffU

Functions

template< class T>

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, T& v) [inline]

Simplifies reading the value of mi::neuraylib::IValue into the corresponding classes from the base and math API. The various overloads of this method support all atomic MDL types with the corresponding C-type as type of v (and int for mi::neuraylib::IValue_enum). Vectors and matrices are supported if v is of type mi::math::Vector and mi::math::Matrix, respectively. For arrays, see get_value( const mi::neuraylib::IValue*, T*, Size). For components of compounds, see get_value( const mi::neuraylib::IValue*, Size, T&) and get_value( const mi::neuraylib::IValue*, const char*, T&).

It is not possible to read entire structs with a single call (in general there is no corresponding C++ class, and absence of introspection machinery). Struct fields need to be read one by one.

There is no support for inner-most components of multi-dimensional compounds (arrays of compounds or structs of compounds) -- this would require additional overloads accepting two or more component indices and/or field names.

This general template handles mi::neuraylib::IValue_int and mi::neuraylib::IValue_enum and expects mi::Uint32 as second argument. Since it is a template it will handle other types as second argument if they are accepted in place of parameters of type mi::Uint32, e.g., mi::Sint32.

Parameters

value
The instance of mi::neuraylib::IValue to read.
v
The new value will be stored here.

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, bool& v) [inline]

This specialization handles mi::neuraylib::IValue_bool. It expects a bool as second argument. See mi::neuraylib::get_value() for details.

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​Float32& v) [inline]

This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. It expects an mi::Float32 as second argument. See mi::neuraylib::get_value() for details.

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​Float64& v) [inline]

This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. It expects an mi::Float64 as second argument. See mi::neuraylib::get_value() for details.

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, const char*& v) [inline]

This specialization handles mi::neuraylib::IValue_enum, mi::neuraylib::IValue_string and mi::neuraylib::IValue_resource. It expects a const char* as second argument. See mi::neuraylib::get_value() for details.

template< class T, Size>

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Vector < T , DIM >& v) [inline]

This specialization handles mi::neuraylib::IValue_vector. It expects an mi::math::Vector of matching dimension and element type as second argument. See mi::neuraylib::get_value() for details.

template< class T, Size, Size>

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Matrix < T , ROW , COL >& v) [inline]

This specialization handles mi::neuraylib::IValue_matrix. It expects an mi::math::Matrix of matching dimensions and element type as second argument. See mi::neuraylib::get_value() for details.

Note:

The conversion between mi::neuraylib::IValue_matrix and mi::math::Matrix is supposed to preserve the memory layout. Since mi::neuraylib::IValue_matrix uses a column-major layout and mi::math::Matrix uses a row-major layout, the conversion process effectively transposes the matrix.

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Color& v) [inline]

This specialization handles mi::neuraylib::IValue_color. It expects an mi::math::Color as second argument. See mi::neuraylib::get_value() for details.

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​math::​Spectrum& v) [inline]

This specialization handles mi::neuraylib::IValue_color. It expects an mi::math::Spectrum as second argument. See mi::neuraylib::get_value() for details.

template< class T>

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, mi::​Size index, T& v) [inline]

This variant handles elements of compounds identified via an additional index. See also mi::neuraylib::get_value() for more details about overloads.

Parameters

value
The instance of mi::neuraylib::IValue to read.
index
The index of the affected compound element.
v
The new value will be stored here.

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -3: The index is not valid.

template< class T>

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, const char* name, T& v) [inline]

This variant handles fields of structs identified via an additional field name. See also mi::neuraylib::get_value() for more details about overloads.

Parameters

value
The instance of mi::neuraylib::IValue to read.
name
The name of the affected struct field.
v
The new value will be stored here.

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -3: The field name is not valid.

template< class T>

mi::​Sint32 mi::neuraylib::get_value( const mi::​neuraylib::​IValue* value, T* v, mi::​Size n) [inline]

This variant handles entire arrays. See also mi::neuraylib::get_value() for more details about overloads.

Parameters

value
The instance of mi::neuraylib::IValue to read.
v
The new value will be stored here (as pointer to a C array).
n
The size of the C array (needs to match the size of value).

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -4: The array sizes do not match.

template< class T>

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const T& v) [inline]

Simplifies setting the value of mi::neuraylib::IValue from the corresponding classes from the base and math API. The various overloads of this method support all atomic MDL types with the corresponding C-type as type of v (and int for mi::neuraylib::IValue_enum). Vectors and matrices are supported if v is of type mi::math::Vector and mi::math::Matrix, respectively. For arrays, see set_value( mi::neuraylib::IValue*, const T*, Size). For components of compounds, see set_value( mi::neuraylib::IValue*, Size, const T&) and set_value( mi::neuraylib::IValue*, const char*, const T&).

It is not possible to set entire structs with a single call (in general there is no corresponding C++ class, and absence of introspection machinery). Struct fields need to be set one by one.

There is no support for inner-most components of multi-dimensional compounds (arrays of compounds or structs of compounds) -- this would require additional overloads accepting two or more component indices and/or field names.

This general template handles mi::neuraylib::IValue_int and mi::neuraylib::IValue_enum and expects mi::Uint32 as second argument. Since it is a template it will handle other types as second argument if they are accepted in place of parameters of type mi::Uint32, e.g., mi::Sint32.

Parameters

value
The instance of mi::neuraylib::IValue to modify.
v
The new value to be set.

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -2: The value of v is not valid.

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const bool& v) [inline]

This specialization handles mi::neuraylib::IValue_bool. It expects a bool as second argument. See mi::neuraylib::set_value() for details.

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​Float32& v) [inline]

This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. It expects an mi::Float32 as second argument. See mi::neuraylib::set_value() for details.

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​Float64& v) [inline]

This specialization handles mi::neuraylib::IValue_float and mi::neuraylib::IValue_double. It expects an mi::Float64 as second argument. See mi::neuraylib::set_value() for details.

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const char* v) [inline]

This specialization handles mi::neuraylib::IValue_enum, mi::neuraylib::IValue_string and mi::neuraylib::IValue_resource. It expects a const char* as second argument. See mi::neuraylib::set_value() for details.

template< class T, Size>

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Vector < T , DIM >& v) [inline]

This specialization handles mi::neuraylib::IValue_vector. It expects an mi::math::Vector of matching dimension and element type as second argument. See mi::neuraylib::set_value() for details.

template< class T, Size, Size>

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Matrix < T , ROW , COL >& v) [inline]

This specialization handles mi::neuraylib::IValue_matrix. It expects an mi::math::Matrix of matching dimensions and element type as second argument. See mi::neuraylib::set_value() for details.

Note:

The conversion between mi::neuraylib::IValue_matrix and mi::math::Matrix is supposed to preserve the memory layout. Since mi::neuraylib::IValue_matrix uses a column-major layout and mi::math::Matrix uses a row-major layout, the conversion process effectively transposes the matrix.

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Color& v) [inline]

This specialization handles mi::neuraylib::IValue_color. It expects an mi::math::Color as second argument. See mi::neuraylib::set_value() for details.

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const mi::​math::​Spectrum& v) [inline]

This specialization handles mi::neuraylib::IValue_color. It expects an mi::math::Spectrum as second argument. See mi::neuraylib::set_value() for details.

template< class T>

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, mi::​Size index, const T& v) [inline]

This variant handles elements of compounds identified via an additional index. See also mi::neuraylib::set_value() for more details about overloads.

Parameters

value
The instance of mi::neuraylib::IValue to modify.
index
The index of the affected compound element.
v
The new value to be set.

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -3: The index is not valid.

template< class T>

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const char* name, const T& v) [inline]

This variant handles fields of structs identified via an additional field name. See also mi::neuraylib::set_value() for more details about overloads.

Parameters

value
The instance of mi::neuraylib::IValue to modify.
name
The name of the affected struct field.
v
The new value to be set.

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -3: The field name is not valid.

template< class T>

mi::​Sint32 mi::neuraylib::set_value( mi::​neuraylib::​IValue* value, const T* v, mi::​Size n) [inline]

This variant handles entire arrays. See also mi::neuraylib::set_value() for more details about overloads.

Parameters

value
The instance of mi::neuraylib::IValue to modify.
v
The new value to be set (as pointer to a C array).
n
The size of the C array (needs to match the size of value).

Returns

  • 0: Success.
  • -1: The dynamic type of value does not match the static type of v.
  • -4: The array sizes do not match.