MDL SDK API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::neuraylib::IMdl_factory Class Referenceabstract

Factory for various MDL interfaces and functions. More...

Inheritance diagram for mi::neuraylib::IMdl_factory:
mi::base::Interface_declare< 0xba936279, 0x4b71, 0x42a4, 0x95, 0x37, 0x98, 0x69, 0x97, 0xb3, 0x47, 0x72 > mi::base::IInterface

Public Member Functions

virtual IType_factorycreate_type_factory (ITransaction *transaction)=0
 Returns an MDL type factory for the given transaction. More...
 
virtual IValue_factorycreate_value_factory (ITransaction *transaction)=0
 Returns an MDL value factory for the given transaction. More...
 
virtual IExpression_factorycreate_expression_factory (ITransaction *transaction)=0
 Returns an MDL expression factory for the given transaction. More...
 
virtual IMdl_execution_contextcreate_execution_context ()=0
 Creates an execution context. More...
 
virtual IValue_texturecreate_texture (ITransaction *transaction, const char *file_path, IType_texture::Shape shape, Float32 gamma, bool shared, Sint32 *errors=0)=0
 Creates a value referencing a texture identified by an MDL file path. More...
 
virtual IValue_light_profilecreate_light_profile (ITransaction *transaction, const char *file_path, bool shared, Sint32 *errors=0)=0
 Creates a value referencing a light profile identified by an MDL file path. More...
 
virtual IValue_bsdf_measurementcreate_bsdf_measurement (ITransaction *transaction, const char *file_path, bool shared, Sint32 *errors=0)=0
 Creates a value referencing a BSDF measurement identified by an MDL file path. More...
 
virtual IMdl_module_buildercreate_module_builder (ITransaction *transaction, const char *module_name, Mdl_version min_module_version, Mdl_version max_module_version, IMdl_execution_context *context)=0
 Creates a module builder for a given module. More...
 
virtual IMdl_module_transformercreate_module_transformer (ITransaction *transaction, const char *module_name, IMdl_execution_context *context)=0
 Creates a module transformer for a given module. More...
 
virtual const IStringget_db_module_name (const char *mdl_name)=0
 Returns the DB name for the MDL name of a module (or file path for MDLE modules). More...
 
virtual const IStringget_db_definition_name (const char *mdl_name)=0
 Returns the DB name for the MDL name of an material or function definition. More...
 
virtual void analyze_uniform (ITransaction *transaction, const char *root_name, bool root_uniform, const IExpression *query_expr, bool &query_result, IString *error_path, IMdl_execution_context *context) const =0
 Analyzes whether an expression graph violates the uniform constraints. More...
 
virtual const IStringdecode_name (const char *name)=0
 Decodes a DB or MDL name. More...
 
virtual const IStringencode_module_name (const char *name)=0
 Encodes a DB or MDL module name. More...
 
virtual const IStringencode_function_definition_name (const char *name, const IArray *parameter_types) const =0
 Encodes a DB or MDL function or material definition name. More...
 
virtual const IStringencode_type_name (const char *name) const =0
 Encodes an MDL type name. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0xba936279, 0x4b71, 0x42a4, 0x95, 0x37, 0x98, 0x69, 0x97, 0xb3, 0x47, 0x72 >
typedef Interface_declare< id1,
id2, id3, id4, id5, id6, id7,
id8, id9, id10, id11,
IInterface
Self
 Own type. More...
 
typedef Uuid_t< id1, id2, id3,
id4, id5, id6, id7, id8, id9,
id10, id11 > 
IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0xba936279, 0x4b71, 0x42a4, 0x95, 0x37, 0x98, 0x69, 0x97, 0xb3, 0x47, 0x72 >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 

Detailed Description

Factory for various MDL interfaces and functions.

This interface gives access to the type, value, and expressions factories. It also allows to create material and function variants.

Member Function Documentation

virtual void mi::neuraylib::IMdl_factory::analyze_uniform ( ITransaction transaction,
const char *  root_name,
bool  root_uniform,
const IExpression query_expr,
bool &  query_result,
IString error_path,
IMdl_execution_context context 
) const
pure virtual

Analyzes whether an expression graph violates the uniform constraints.

Note
This method can be used to check already created graphs, but it can also be used to check whether a hypothetical connection would observe the uniform constraints: First, invoke the method with the root of the existing graph, root_uniform set to false (at least for materials), and query_expr set to the graph node to be replaced. If the call returns with query_result set to false (and no errors in the context), then any (valid) subgraph can be connected. Otherwise, invoke the method again with the root of the to-be-connected subgraph, root_uniform set to true, and query_expr set to NULL. If there are no errors, then the subgraph can be connected.
Make sure that query_expr (if not NULL) can be reached from root_name, otherwise query_result is always false. In particular, arguments passed during call creation (or later for argument changes) are cloned, and the expression that is part of the graph is different from the one that was used to construct the graph (equal, but not identical).
Parameters
transactionThe transaction to be used.
root_nameDB name of the root node of the graph (material instance or function call).
root_uniformIndicates whether the root node should be uniform.
query_exprA node of the call graph for which the uniform property is to be queried. This expression is only used to identify the corresponding node in the graph, i.e., it even makes sense to pass constant expressions (which by themselves are always uniform) to determine whether a to-be-connected call expression has to be uniform. Can be NULL.
[out]query_resultIndicates whether query_expr needs to be uniform (or false if query_expr is NULL, or in case of errors).
[out]error_pathA path to a node of the graph that violates the uniform constraints, or the empty string if there is no such node (or in case of errors). Such violations are also reported via context. Can be NULL.
contextThe execution context can be used to pass options and to retrieve error and/or warning messages. Can be NULL.
virtual IValue_bsdf_measurement* mi::neuraylib::IMdl_factory::create_bsdf_measurement ( ITransaction transaction,
const char *  file_path,
bool  shared,
Sint32 errors = 0 
)
pure virtual

Creates a value referencing a BSDF measurement identified by an MDL file path.

Parameters
transactionThe transaction to be used.
file_pathThe absolute MDL file path that identifies the BSDF measurement. The MDL search paths are used to resolve the file path. See section 2.2 in [MDLLS] for details.
sharedIndicates whether you want to re-use the DB element for that BSDF measurement if it has already been loaded, or if you want to create a new DB element in all cases. Note that sharing is based on the location where the BSDF measurement is finally located and includes sharing with instances that have not explicitly been loaded via this method, e.g., BSDF measurements in defaults.
errorsAn optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: The file path is not an absolute MDL file path.
  • -3: Failed to resolve the given file path.
Returns
The value referencing the BSDF measurement, or NULL in case of failure.
virtual IMdl_execution_context* mi::neuraylib::IMdl_factory::create_execution_context ( )
pure virtual

Creates an execution context.

virtual IExpression_factory* mi::neuraylib::IMdl_factory::create_expression_factory ( ITransaction transaction)
pure virtual

Returns an MDL expression factory for the given transaction.

virtual IValue_light_profile* mi::neuraylib::IMdl_factory::create_light_profile ( ITransaction transaction,
const char *  file_path,
bool  shared,
Sint32 errors = 0 
)
pure virtual

Creates a value referencing a light profile identified by an MDL file path.

Parameters
transactionThe transaction to be used.
file_pathThe absolute MDL file path that identifies the light profile. The MDL search paths are used to resolve the file path. See section 2.2 in [MDLLS] for details.
sharedIndicates whether you want to re-use the DB element for that light profile if it has already been loaded, or if you want to create a new DB element in all cases. Note that sharing is based on the location where the light profile is finally located and includes sharing with instances that have not explicitly been loaded via this method, e.g., light profiles in defaults.
errorsAn optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: The file path is not an absolute MDL file path.
  • -3: Failed to resolve the given file path.
Returns
The value referencing the light profile, or NULL in case of failure.
virtual IMdl_module_builder* mi::neuraylib::IMdl_factory::create_module_builder ( ITransaction transaction,
const char *  module_name,
Mdl_version  min_module_version,
Mdl_version  max_module_version,
IMdl_execution_context context 
)
pure virtual

Creates a module builder for a given module.

Parameters
transactionThe transaction to be used.
module_nameThe DB name of the MDL module to build. If there is no such module, then an empty module with this name and min_module_version is created. Otherwise, the existing module is edited. Builtin modules or MDLE modules cannot be built or edited.
min_module_versionThe initial MDL version of the new module. Ignored if the module exists already.
max_module_versionThe maximal desired MDL version of the module. If higher than the current MDL version of the module, then the module builder will upgrade the MDL version as necessary to handle requests requiring newer features.
contextAn execution context which can be queried for detailed error messages after the operation has finished. Can be NULL.
Returns
The module builder for the given module, or NULL in case of errors.
virtual IMdl_module_transformer* mi::neuraylib::IMdl_factory::create_module_transformer ( ITransaction transaction,
const char *  module_name,
IMdl_execution_context context 
)
pure virtual

Creates a module transformer for a given module.

Parameters
transactionThe transaction to be used.
module_nameThe DB name of the MDL module to transform. Builtin modules cannot be transformed.
contextAn execution context which can be queried for detailed error messages after the operation has finished. Can be NULL.
Returns
The module transformer for the given module, or NULL in case of errors.
virtual IValue_texture* mi::neuraylib::IMdl_factory::create_texture ( ITransaction transaction,
const char *  file_path,
IType_texture::Shape  shape,
Float32  gamma,
bool  shared,
Sint32 errors = 0 
)
pure virtual

Creates a value referencing a texture identified by an MDL file path.

Parameters
transactionThe transaction to be used.
file_pathThe absolute MDL file path that identifies the texture. The MDL search paths are used to resolve the file path. See section 2.2 in [MDLLS] for details.
shapeThe value that is returned by mi::neuraylib::IType_texture::get_shape() on the type corresponding to the return value.
gammaThe value that is returned by mi::neuraylib::ITexture::get_gamma() on the DB element referenced by the return value.
sharedIndicates whether you want to re-use the DB elements for that texture if it has already been loaded, or if you want to create new DB elements in all cases. Note that sharing is based on the location where the texture is finally located and includes sharing with instances that have not explicitly been loaded via this method, e.g., textures in defaults.
errorsAn optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: The file path is not an absolute MDL file path.
  • -3: Failed to resolve the given file path, or no suitable image plugin available.
Returns
The value referencing the texture, or NULL in case of failure.
virtual IType_factory* mi::neuraylib::IMdl_factory::create_type_factory ( ITransaction transaction)
pure virtual

Returns an MDL type factory for the given transaction.

virtual IValue_factory* mi::neuraylib::IMdl_factory::create_value_factory ( ITransaction transaction)
pure virtual

Returns an MDL value factory for the given transaction.

virtual const IString* mi::neuraylib::IMdl_factory::decode_name ( const char *  name)
pure virtual

Decodes a DB or MDL name.

Parameters
nameThe encoded DB or MDL name to be decoded.
Returns
The decoded DB or MDL name, or NULL if name is NULL. Returns the input string if encoded names are disabled.
Note
This method should only be used for display purposes. Do not use the returned name to identify functions or materials since this representation is ambiguous. For modules, it is possible to re-encode their name without loss of information, see encode_module_name(). This is not possible for names of function or material definitions.
This method does not require the corresponding module to be loaded. The method does not check whether the given name is valid, nor whether it is defined in the corresponding module.
virtual const IString* mi::neuraylib::IMdl_factory::encode_function_definition_name ( const char *  name,
const IArray parameter_types 
) const
pure virtual

Encodes a DB or MDL function or material definition name.

Parameters
nameThe decoded DB or MDL name of a function or material definition without signature.
parameter_typesA static or dynamic array with elements of type mi::IString representing decoded positional parameter type names. The value NULL can be used for functions or materials without parameters (treated like an empty array).
Returns
The encoded function or material definition name, or NULL if name or one of the array elements is NULL. If encoded names are disabled, then the individual components of the name are joined by parentheses and commas without further encoding.
Note
This method does not require the corresponding module to be loaded. The method does not check whether the given name is valid, nor whether it is defined in the corresponding module.
See Also
mi::neuraylib::IMdl_factory::encode_module_name(), mi::neuraylib::IMdl_factory::encode_type_name()
virtual const IString* mi::neuraylib::IMdl_factory::encode_module_name ( const char *  name)
pure virtual

Encodes a DB or MDL module name.

Parameters
nameThe decoded DB or MDL module name to be encoded.
Returns
The encoded DB or MDL module name, or NULL if name is NULL. Returns the input string if encoded names are disabled.
Note
This method does not require the corresponding module to be loaded. The method does not check whether the given name is valid.
See Also
mi::neuraylib::IMdl_factory::encode_function_definition_name(), mi::neuraylib::IMdl_factory::encode_type_name()
virtual const IString* mi::neuraylib::IMdl_factory::encode_type_name ( const char *  name) const
pure virtual

Encodes an MDL type name.

Parameters
nameThe decoded MDL name of a type.
Returns
The encoded MDL name of the type, or NULL if name is NULL. Returns the input string if encoded names are disabled
Note
This method does not require the corresponding module to be loaded. The method does not check whether the given name is valid, nor whether it is defined in the corresponding module.
See Also
mi::neuraylib::IMdl_factory::encode_function_definition_name(), mi::neuraylib::IMdl_factory::encode_module_name()
virtual const IString* mi::neuraylib::IMdl_factory::get_db_definition_name ( const char *  mdl_name)
pure virtual

Returns the DB name for the MDL name of an material or function definition.

For example, given "::state::normal()", the method returns "mdl::state::normal()".

Note
This method does not check for existence of the corresponding DB element, nor does it check that the input is a valid material or definition name.
Usage of this method is strongly recommended instead of manually prepending "mdl", since (a) the mapping is more complicated than that, e.g., for MDLE modules, and (b) the mapping might change in the future.
Parameters
mdl_nameThe MDL name of the material or function definition.
Returns
The DB name of that material or function definition, or NULL if mdl_name is invalid.
virtual const IString* mi::neuraylib::IMdl_factory::get_db_module_name ( const char *  mdl_name)
pure virtual

Returns the DB name for the MDL name of a module (or file path for MDLE modules).

For example, given "::state", the method returns "mdl::state".

Note
This method does not check for existence of the corresponding DB element, nor does it check that the input is a valid module name.
Usage of this method is strongly recommended instead of manually prepending "mdl", since (a) the mapping is more complicated than that, e.g., for MDLE modules, and (b) the mapping might change in the future.
Parameters
mdl_nameThe MDL name of the module (non-MDLE and MDLE module), or the file path of an MDLE module.
Returns
The DB name of that module, or NULL if mdl_name is invalid.