neuray API Programmer's Manual

itype.h File Reference

Description

Types of the MDL type system.

Code Example

itype.h

‎/***************************************************************************************************
 * Copyright 2024 NVIDIA Corporation. All rights reserved.
 **************************************************************************************************/

#ifndef MI_NEURAYLIB_ITYPE_H
#define MI_NEURAYLIB_ITYPE_H

#include <mi/base/interface_declare.h>

namespace mi {

class IString;

namespace neuraylib {

class IAnnotation_block;

class IStruct_category : public
    mi::base::Interface_declare<0xdc79e614,0xad7e,0x4e4d,0xa9,0xc1,0x25,0x91,0xba,0x84,0x44,0x2d>
{
public:
    enum Predefined_id {
        CID_USER              = -1,         
        CID_MATERIAL_CATEGORY =  0,         
        CID_FORCE_32_BIT      =  0x7fffffff //   Undocumented, for alignment only.
    };

    virtual const char* get_symbol() const = 0;

    virtual Predefined_id 
               get_predefined_id() const = 0;

    virtual const IAnnotation_block* get_annotations() const = 0;
};

mi_static_assert( sizeof( IStruct_category::Predefined_id) == sizeof( Sint32));

class IStruct_category_list : public
    mi::base::Interface_declare<0x509417fe,0xaf4d,0x439e,0xa5,0xa2,0x09,0x56,0x2a,0x6c,0x04,0x2a>
{
public:
    virtual Size 
               get_size() const = 0;

    virtual Size 
               get_index( const char* name) const = 0;

    virtual const char* get_name( Size index) const = 0;

    virtual const IStruct_category* get_struct_category( Size index) const = 0;

    template <class T>
    const T* get_struct_category( Size index) const
    {
        const IStruct_category* ptr_struct_category = get_struct_category( index);
        if( !ptr_struct_category)
            return 0;
        const T* ptr_T = static_cast<const T*>(
            ptr_struct_category->get_interface( typename T::IID()));
        ptr_struct_category->release();
        return ptr_T;
    }

    virtual const IStruct_category* get_struct_category( const char* name) const = 0;

    template <class T>
    const T* get_struct_category( const char* name) const
    {
        const IStruct_category* ptr_struct_category = get_struct_category( name);
        if( !ptr_struct_category)
            return 0;
        const T* ptr_T = static_cast<const T*>(
            ptr_struct_category->get_interface( typename T::IID()));
        ptr_struct_category->release();
        return ptr_T;
    }

    virtual Sint32 
               set_struct_category( Size index, const IStruct_category* struct_category) = 0;

    virtual Sint32 
               set_struct_category(
        const char* name, const IStruct_category* struct_category) = 0;

    virtual Sint32 
               add_struct_category(
        const char* name, const IStruct_category* struct_category) = 0;
};

class IType : public
    mi::base::Interface_declare<0x242af675,0xeaa2,0x48b7,0x81,0x63,0xba,0x06,0xa5,0xfb,0x68,0xf0>
{
public:
    enum Kind {
        TK_ALIAS,
        TK_BOOL,
        TK_INT,
        TK_ENUM,
        TK_FLOAT,
        TK_DOUBLE,
        TK_STRING,
        TK_VECTOR,
        TK_MATRIX,
        TK_COLOR,
        TK_ARRAY,
        TK_STRUCT,
        TK_TEXTURE,
        TK_LIGHT_PROFILE,
        TK_BSDF_MEASUREMENT,
        TK_BSDF,
        TK_HAIR_BSDF,
        TK_EDF,
        TK_VDF,
        //  Undocumented, for alignment only.
        TK_FORCE_32_BIT = 0xffffffffU
    };

    enum Modifier {
        MK_NONE        = 0,  
        MK_UNIFORM     = 2,  
        MK_VARYING     = 4,  
        MK_FORCE_32_BIT      //   Undocumented, for alignment only.
    };

    virtual Kind 
               get_kind() const = 0;

    virtual Uint32 
               get_all_type_modifiers() const = 0;

    virtual const IType* skip_all_type_aliases() const = 0;

    virtual bool is_declarative() const = 0;
};

mi_static_assert( sizeof( IType::Kind) == sizeof( Uint32));
mi_static_assert( sizeof( IType::Modifier) == sizeof( Uint32));

class IType_alias : public
    mi::base::Interface_declare<0x69d8c70a,0xdfda,0x4e8e,0xaa,0x09,0x12,0x1f,0xa9,0x78,0xc6,0x6a,
                                neuraylib::IType>
{
public:
    static const Kind 
               s_kind = TK_ALIAS;

    virtual const IType* get_aliased_type() const = 0;

    virtual Uint32 
               get_type_modifiers() const = 0;

    virtual const char* get_symbol() const = 0;
};

class IType_atomic : public
    mi::base::Interface_declare<0x9d5f9116,0x3896,0x45c8,0xb4,0x5a,0x8b,0x03,0x84,0x49,0x0a,0x77,
                                neuraylib::IType>
{
};

class IType_bool : public
    mi::base::Interface_declare<0x831d8a38,0x26d3,0x4fd2,0xa7,0xf7,0x15,0xc2,0xa5,0x20,0x76,0x6c,
                                neuraylib::IType_atomic>
{
public:
    static const Kind 
               s_kind = TK_BOOL;
};

class IType_int : public
    mi::base::Interface_declare<0xbbad021c,0xbfe5,0x45de,0xaf,0x66,0xfd,0xe8,0x45,0xbe,0x48,0x49,
                                neuraylib::IType_atomic>
{
public:
    static const Kind 
               s_kind = TK_INT;
};

class IType_enum : public
    mi::base::Interface_declare<0x0e5b167c,0x9c3e,0x48bf,0xb5,0xfd,0x37,0x96,0xaa,0x47,0xaf,0xd1,
                                neuraylib::IType_atomic>
{
public:
    enum Predefined_id {
        EID_USER           = -1,             
        EID_TEX_GAMMA_MODE =  0,             
        EID_INTENSITY_MODE =  1,             
        EID_FORCE_32_BIT   =  0x7fffffff     //   Undocumented, for alignment only.
    };

    static const Kind 
               s_kind = TK_ENUM;

    virtual const char* get_symbol() const = 0;

    virtual Size 
               get_size() const = 0;

    virtual const char* get_value_name( Size index) const = 0;

    virtual Sint32 
               get_value_code( Size index, Sint32* errors = 0) const = 0;

    virtual Size 
               find_value( const char* name) const = 0;

    virtual Size 
               find_value( Sint32 code) const = 0;

    virtual Predefined_id 
               get_predefined_id() const = 0;

    virtual const IAnnotation_block* get_annotations() const = 0;

    virtual const IAnnotation_block* get_value_annotations( Size index) const = 0;
};

mi_static_assert( sizeof( IType_enum::Predefined_id) == sizeof( Sint32));

class IType_float : public
    mi::base::Interface_declare<0x613711b3,0x41f2,0x44a9,0xbb,0x78,0x43,0xe2,0x41,0x64,0xb3,0xda,
                                neuraylib::IType_atomic>
{
public:
    static const Kind 
               s_kind = TK_FLOAT;
};

class IType_double : public
    mi::base::Interface_declare<0xc381508b,0x7945,0x4c70,0x8a,0x20,0x57,0xd5,0x2b,0x36,0x35,0x40,
                                neuraylib::IType_atomic>
{
public:
    static const Kind 
               s_kind = TK_DOUBLE;
};

class IType_string : public
    mi::base::Interface_declare<0x4b4629bc,0xa2ce,0x4008,0xba,0x76,0xf6,0x4d,0x60,0x76,0x0a,0x85,
                                neuraylib::IType_atomic>
{
public:
    static const Kind 
               s_kind = TK_STRING;
};

class IType_compound : public
    mi::base::Interface_declare<0xc9ca497f,0xc38b,0x411f,0xa8,0x16,0xa7,0xd8,0x23,0x28,0xa5,0x40,
                                neuraylib::IType>
{
public:
    virtual const IType* get_component_type( Size index) const = 0;

    virtual Size 
               get_size() const = 0;
};

class IType_vector : public
    mi::base::Interface_declare<0x412a8a91,0x9062,0x46fd,0xaa,0xcf,0x46,0xbd,0xb3,0xde,0x5b,0x9c,
                                neuraylib::IType_compound>
{
public:
    static const Kind 
               s_kind = TK_VECTOR;

    virtual const IType_atomic* get_element_type() const = 0;
};

class IType_matrix : public
    mi::base::Interface_declare<0x6b76570e,0x51b2,0x4e9b,0x9f,0xe7,0xda,0x03,0x1c,0x37,0xbc,0x75,
                                neuraylib::IType_compound>
{
public:
    static const Kind 
               s_kind = TK_MATRIX;

    virtual const IType_vector* get_element_type() const = 0;
};

class IType_color : public
    mi::base::Interface_declare<0xedb16770,0xdf70,0x4def,0x83,0xa5,0xc4,0x4f,0xcd,0x09,0x47,0x0f,
                                neuraylib::IType_compound>
{
public:
    static const Kind 
               s_kind = TK_COLOR;
};

class IType_array : public
    mi::base::Interface_declare<0x21ab6abe,0x0e26,0x40da,0xa1,0x98,0x42,0xc0,0x89,0x71,0x5d,0x2a,
                                neuraylib::IType_compound>
{
public:
    static const Kind 
               s_kind = TK_ARRAY;

    virtual const IType* get_element_type() const = 0;

    virtual bool is_immediate_sized() const = 0;

    virtual Size 
               get_size() const = 0;

    virtual const char* get_deferred_size() const = 0;
};

class IType_struct : public
    mi::base::Interface_declare<0x19566cb2,0x0b5d,0x41ca,0xa0,0x31,0x96,0xe2,0x9a,0xd4,0xc3,0x1a,
                                neuraylib::IType_compound>
{
public:
    enum Predefined_id {
        SID_USER               = -1,             
        SID_MATERIAL_EMISSION  =  0,             
        SID_MATERIAL_SURFACE   =  1,             
        SID_MATERIAL_VOLUME    =  2,             
        SID_MATERIAL_GEOMETRY  =  3,             
        SID_MATERIAL           =  4,             
        SID_FORCE_32_BIT       =  0x7fffffff     //   Undocumented, for alignment only.
    };

    static const Kind 
               s_kind = TK_STRUCT;

    virtual const char* get_symbol() const = 0;

    virtual const IType* get_field_type( Size index) const = 0;

    virtual const char* get_field_name( Size index) const = 0;

    virtual Size 
               find_field( const char* name) const = 0;

    virtual Predefined_id 
               get_predefined_id() const = 0;

    virtual const IAnnotation_block* get_annotations() const = 0;

    virtual const IAnnotation_block* get_field_annotations( Size index) const = 0;

    virtual const IStruct_category* get_struct_category() const = 0;
};

mi_static_assert( sizeof( IType_struct::Predefined_id) == sizeof( Sint32));

class IType_reference : public
    mi::base::Interface_declare<0x3e12cdec,0xdaba,0x460c,0x9e,0x8a,0x21,0x4c,0x43,0x9a,0x1a,0x90,
                                neuraylib::IType>
{
};

class IType_resource : public
    mi::base::Interface_declare<0x142f5bea,0x139e,0x42e4,0xb1,0x1c,0xb3,0x4d,0xd8,0xe3,0xd9,0x8d,
                                neuraylib::IType_reference>
{
};

class IType_texture : public
    mi::base::Interface_declare<0x2f11253f,0xb8ac,0x4b7d,0x8d,0xd6,0x43,0x66,0xf5,0x97,0xd0,0x93,
                                neuraylib::IType_resource>
{
public:
    static const Kind 
               s_kind = TK_TEXTURE;

    enum Shape {
        TS_2D           = 0,            
        TS_3D           = 1,            
        TS_CUBE         = 2,            
        TS_PTEX         = 3,            
        TS_BSDF_DATA    = 4,            

        TS_FORCE_32_BIT = 0xffffffffU   //   Undocumented, for alignment only.
    };

    virtual Shape 
               get_shape() const = 0;
};

mi_static_assert( sizeof( IType_texture::Shape) == sizeof( Uint32));

class IType_light_profile : public
    mi::base::Interface_declare<0x11b80cd8,0x14aa,0x4dfa,0x8b,0xf6,0x0e,0x56,0x0f,0x10,0x9c,0x37,
                                neuraylib::IType_resource>
{
public:
    static const Kind 
               s_kind = TK_LIGHT_PROFILE;
};

class IType_bsdf_measurement : public
    mi::base::Interface_declare<0xf061d204,0xc649,0x4a6b,0xb6,0x2d,0x67,0xe6,0x47,0x53,0xa9,0xda,
                                neuraylib::IType_resource>
{
public:
    static const Kind 
               s_kind = TK_BSDF_MEASUREMENT;
};

class IType_df : public
    mi::base::Interface_declare<0xf4bcba08,0x7777,0x4662,0x8e,0x29,0x67,0xe1,0x52,0xac,0x05,0x3e,
                                neuraylib::IType_reference>
{
};

class IType_bsdf : public
    mi::base::Interface_declare<0x6542a02c,0xe1d2,0x485d,0x9a,0x51,0x7b,0xed,0xff,0x7f,0x24,0x7b,
                                neuraylib::IType_df>
{
public:
    static const Kind 
               s_kind = TK_BSDF;
};

class IType_hair_bsdf : public
    mi::base::Interface_declare<0x8eac6c90,0x2b8f,0x4650,0x8b,0x93,0x88,0xe0,0x42,0xff,0x19,0x9c,
                                neuraylib::IType_df>
{
public:
    static const Kind 
               s_kind = TK_HAIR_BSDF;
};

class IType_edf : public
    mi::base::Interface_declare<0x3e3ce697,0xa2a7,0x43ef,0xa2,0xec,0x52,0x5a,0x4c,0x27,0x8f,0xeb,
                                neuraylib::IType_df>
{
public:
    static const Kind 
               s_kind = TK_EDF;
};

class IType_vdf : public
    mi::base::Interface_declare<0x44782b21,0x9e60,0x40b2,0xba,0xae,0x41,0x74,0xc9,0x98,0xe1,0x86,
                                neuraylib::IType_df>
{
public:
    static const Kind 
               s_kind = TK_VDF;
};

class IType_list : public
    mi::base::Interface_declare<0x68a97390,0x22ea,0x4f03,0xa5,0xb5,0x5c,0x18,0x32,0x38,0x28,0x91>
{
public:
    virtual Size 
               get_size() const = 0;

    virtual Size 
               get_index( const char* name) const = 0;

    virtual const char* get_name( Size index) const = 0;

    virtual const IType* get_type( Size index) const = 0;

    template <class T>
    const T* get_type( Size index) const
    {
        const IType* ptr_type = get_type( index);
        if( !ptr_type)
            return 0;
        const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
        ptr_type->release();
        return ptr_T;
    }

    virtual const IType* get_type( const char* name) const = 0;

    template <class T>
    const T* get_type( const char* name) const
    {
        const IType* ptr_type = get_type( name);
        if( !ptr_type)
            return 0;
        const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
        ptr_type->release();
        return ptr_T;
    }

    virtual Sint32 
               set_type( Size index, const IType* type) = 0;

    virtual Sint32 
               set_type( const char* name, const IType* type) = 0;

    virtual Sint32 
               add_type( const char* name, const IType* type) = 0;
};

class IType_factory : public
    mi::base::Interface_declare<0x353803c0,0x74a6,0x48ac,0xab,0xa1,0xe4,0x25,0x42,0x1d,0xa1,0xbc>
{
public:


    virtual const IStruct_category* create_struct_category( const char* symbol) const = 0;

    virtual IStruct_category_list* create_struct_category_list() const = 0;

    virtual const IStruct_category* get_predefined_struct_category(
        IStruct_category::Predefined_id id) const = 0;

    virtual IStruct_category_list* clone(
        const IStruct_category_list* struct_category_list) const = 0;

    virtual Sint32 
               compare( const IStruct_category* lhs, const IStruct_category* rhs) const = 0;

    virtual Sint32 
               compare(
        const IStruct_category_list* lhs, const IStruct_category_list* rhs) const = 0;

    virtual const IString* dump( const IStruct_category* struct_category, Size depth = 0) const = 0;

    virtual const IString* dump( const IStruct_category_list* list, Size depth = 0) const = 0;




    virtual const IType_alias* create_alias(
        const IType* type, Uint32 modifiers, const char* symbol) const = 0;

    virtual const IType_bool* create_bool() const = 0;

    virtual const IType_int* create_int() const = 0;

    virtual const IType_enum* create_enum( const char* symbol) const = 0;

    virtual const IType_float* create_float() const = 0;

    virtual const IType_double* create_double() const = 0;

    virtual const IType_string* create_string() const = 0;

    virtual const IType_vector* create_vector(
        const IType_atomic* element_type, Size size) const = 0;

    virtual const IType_matrix* create_matrix(
        const IType_vector* column_type, Size columns) const = 0;

    virtual const IType_color* create_color() const = 0;

    virtual const IType_array* create_immediate_sized_array(
        const IType* element_type, Size size) const = 0;

    virtual const IType_array* create_deferred_sized_array(
        const IType* element_type, const char* size) const = 0;

    virtual const IType_struct* create_struct( const char* symbol) const = 0;

    virtual const IType_texture* create_texture( IType_texture::Shape shape) const = 0;

    virtual const IType_light_profile* create_light_profile() const = 0;

    virtual const IType_bsdf_measurement* create_bsdf_measurement() const = 0;

    virtual const IType_bsdf* create_bsdf() const = 0;

    virtual const IType_hair_bsdf* create_hair_bsdf() const = 0;

    virtual const IType_edf* create_edf() const = 0;

    virtual const IType_vdf* create_vdf() const = 0;

    virtual IType_list* create_type_list() const = 0;

    virtual const IType_enum* get_predefined_enum( IType_enum::Predefined_id id) const = 0;

    virtual const IType_struct* get_predefined_struct( IType_struct::Predefined_id id) const = 0;

    virtual const IType* create_from_mdl_type_name( const char* name) const = 0;

    template <class T>
    const T* create_from_mdl_type_name( const char* name) const
    {
        const IType* ptr_type = create_from_mdl_type_name( name);
        if( !ptr_type)
            return 0;
        const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
        ptr_type->release();
        return ptr_T;
    }




    virtual IType_list* clone( const IType_list* type_list) const = 0;




    virtual Sint32 
               compare( const IType* lhs, const IType* rhs) const = 0;

    virtual Sint32 
               compare( const IType_list* lhs, const IType_list* rhs) const = 0;

    virtual Sint32 
               is_compatible( const IType* lhs, const IType* rhs) const = 0;

    virtual Sint32 
               from_same_struct_category( const IType* lhs, const IType* rhs) const = 0;





    virtual const IString* dump( const IType* type, Size depth = 0) const = 0;

    virtual const IString* dump( const IType_list* list, Size depth = 0) const = 0;




    virtual const IString* get_mdl_module_name( const IType* type) const = 0;

    virtual const IString* get_mdl_type_name( const IType* type) const = 0;

};
 // end group mi_neuray_mdl_types

} // namespace neuraylib

} // namespace mi

#endif // MI_NEURAYLIB_ITYPE_H

Namespaces

namespace 
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
namespace 
Namespace for the neuray API. More...

Classes

class 
Represents the optional struct category for struct types. More...
class 
An ordered collection of struct categories identified by name or index. 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...