|
|
virtual const IImport_result * | import_elements (ITransaction *transaction, const char *uri, const IMap *importer_options=nullptr, const IImpexp_state *parent_state=nullptr) const =0 |
| Imports scene elements. More...
|
|
virtual const IImport_result * | import_elements_from_string (ITransaction *transaction, const char *data, const char *file_extension, const IMap *importer_options=nullptr, const IImpexp_state *parent_state=nullptr) const =0 |
| Imports scene data from a string into the database. More...
|
|
virtual ICanvas * | import_canvas (const char *uri) const =0 |
| Imports a canvas from a file on disk. More...
|
|
virtual Sint32 | import_bsdf_data (const char *uri, IBsdf_isotropic_data **reflection, IBsdf_isotropic_data **transmission) const =0 |
| Imports BSDF data from a file on disk. More...
|
|
|
virtual Size | get_importer_length () const =0 |
| Returns the number of registered importers. More...
|
|
virtual const IImporter * | get_importer (Size index) const =0 |
| Returns a registered importer. More...
|
|
virtual const IImporter * | select_importer_by_uri (const char *uri) const =0 |
| Returns the importer that would be used for a particular resource. More...
|
|
virtual IReader * | get_reader (const char *uri) const =0 |
| Returns a random-access reader that can be used to import the given resource. More...
|
|
virtual IReader * | create_reader (const IBuffer *buffer) const =0 |
| Creates a random-access reader for a given buffer. More...
|
|
|
virtual const IString * | get_absolute_path (ITransaction *transaction, const char *path) const =0 |
| Returns the absolute path corresponding to the given path. More...
|
|
virtual const IString * | create_importer_directory (ITransaction *transaction) const =0 |
| Creates a unique directory that can be used by importers for temporary files. More...
|
|
virtual const IString * | convert_filename_to_uri (const char *filename) const =0 |
| Converts a filename into a URI. More...
|
|
virtual const IString * | convert_uri_to_filename (const char *uri) const =0 |
| Converts a URI into a filename. More...
|
|
virtual Uint32 | retain () const =0 |
| Increments the reference count. More...
|
|
virtual Uint32 | release () const =0 |
| Decrements the reference count. More...
|
|
virtual const IInterface * | get_interface (const Uuid &interface_id) const =0 |
| Acquires a const interface from another. More...
|
|
template<class T> |
const T * | get_interface () const |
| Acquires a const interface from another. More...
|
|
virtual IInterface * | get_interface (const Uuid &interface_id)=0 |
| Acquires a mutable interface from another. More...
|
|
template<class T> |
T * | get_interface () |
| Acquires a mutable interface from another. More...
|
|
virtual Uuid | get_iid () const =0 |
| Returns the interface ID of the most derived interface. More...
|
|
|
using | Self = Interface_declare< id1, ... > |
| Own type. More...
|
|
using | IID = Uuid_t< id1, ... > |
| Declares the interface ID (IID) of this interface. More...
|
|
using | IID = Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> |
| Declares the interface ID (IID) of this interface. More...
|
|
static bool | compare_iid (const Uuid &iid) |
| Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
|
|
static bool | compare_iid (const Uuid &iid) |
| Compares the interface ID iid against the interface ID of this interface. More...
|
|
This interface is used to import files.
virtual const IString * mi::neuraylib::IImport_api::convert_filename_to_uri |
( |
const char * |
filename | ) |
const |
|
pure virtual |
Converts a filename into a URI.
Returns nullptr
if filename
is nullptr
. Otherwise returns a URI without URI scheme and URI authority. The URI path is constructed from the filename according to the following rules.
On Linux and MacOS X, the URI path equals the filename. On Windows, backslashes in relative filenames are converted to slashes to obtain the URI path. Absolute filenames are mapped to URI paths according to the following table.
Filename | URI path | Comment |
C:\dir1\dir2\file | /C:/dir1/dir2/file | - |
\dir1\dir2\file | /dir1/dir2/file | - |
\\share\dir1\dir2\file | //share/dir1/dir2/file | Note that an empty URI authority (// ) is prepended since otherwise the the share name is interpreted as URI authority. |
- Note
- There are no checks whether
filename
identifies an existing file, or whether that file is readable. The filename is simply converted to a URI according to some fixed rules.
-
This method does not support filenames with hashes or question marks.
-
This method does not understand the special variable
"${shader}"
.
- See also
- Importer and Exporter for general information about URIs.
virtual const IString * mi::neuraylib::IImport_api::convert_uri_to_filename |
( |
const char * |
uri | ) |
const |
|
pure virtual |
Converts a URI into a filename.
Returns nullptr
if
uri
is nullptr
,
- the URI scheme is non-empty and different from
"file"
,
- the URI authority is non-empty, or
- the URI path is empty.
In all other cases the URI path is converted into a filename according to the following rules.
On Linux and MacOS X, the filename equals the URI path. On Windows, slashes in relative URI paths are replaced by backslashes to obtain the filename. Absolute URI paths are mapped to file system paths according to the following table.
URI path | Filename | Comment |
/C:/dir1/dir2/file | C:\dir1\dir2\file | - |
/C/dir1/dir2/file | C:\dir1\dir2\file | This mapping is supported in addition to the first one since a colon is a reserved character in URIs. |
/dir1/dir2/file | \dir1\dir2\file | This mapping is only supported for top-level directory names not consisting of a single letter. |
//share/dir1/dir2/file | \\share\dir1\dir2\file | This mapping requires an (otherwise optional) empty URI authority (// ) since otherwise the share name is interpreted as URI authority. |
- Note
- There are no checks whether
uri
identifies an existing file, or whether that file is readable. The URI is simply converted to a filename according to some fixed rules.
-
This method does not support filenames with hashes or question marks.
-
This method does not understand the special variable
"${shader}"
.
- See also
- Importer and Exporter for general information about URIs.
virtual const IImport_result * mi::neuraylib::IImport_api::import_elements |
( |
ITransaction * |
transaction, |
|
|
const char * |
uri, |
|
|
const IMap * |
importer_options = nullptr , |
|
|
const IImpexp_state * |
parent_state = nullptr |
|
) |
| const |
|
pure virtual |
Imports scene elements.
This method reads the named file from uri
and parses it with an importer. Importer selection is based on testing a file prefix (if available) or the uri
filename extension. Elements will be put into the database as if they had been stored with mi::neuraylib::ITransaction::store().
In addition to importer-specific options, every importer supports the following standard options:
The method stores a non-zero status code in the returned instance of mi::neuraylib::IImport_result if an error occurred. The database and mi::neuraylib::IImport_result contain all elements read up to that point. The element that caused the error might be incomplete or inconsistent. If the "list_elements"
options is selected, every changed or added element, even if it caused an error, is reported in the elements array of mi::neuraylib::IImport_result. In case of an error, the database can be returned to a safe state that does not contain incompletely defined elements by calling the mi::neuraylib::ITransaction::abort() method, which will return the database to the state it was in when the current transaction started. (This is not specific to scene importing, any operation that modifies the database can be reversed in this way.)
- Parameters
-
transaction | The transaction to be used. |
uri | The URI of the file to import from. See Importer and Exporter for the supported URI naming conventions. |
importer_options | The importer options (see above). |
parent_state | An optional state that can be passed by a parent importer, or nullptr . Such a state is used to resolve relative URIs w.r.t. to the URI of the parent state. In addition, the parent state can be used by the importer for better diagnostics in case of errors. |
- Returns
- The import result uses the following error codes.
- 0: The import operation was successful.
- 1: The passed URI is invalid (malformed).
- 2: The Iray SDK failed to create an instance of mi::neuraylib::IReader for the given URI, most probably because it was unable to open the specified file, e.g., because the file does not exist, or the user has insufficient permissions.
- 3: There is no appropriate importer for this file format (and file content).
- 4: The importer failed to create the instance of mi::neuraylib::IImpexp_state.
- 5: The importer did not return a valid instance of mi::neuraylib::IImport_result.
- 6: The option '...' has an invalid type.
- 7: The option '...' has an invalid value.
- 4000-5999: Reserved for importer-specific error codes.
The severity of all listed errors (excluding the importer-specific error codes) is mi::base::details::MESSAGE_SEVERITY_ERROR. There might be other undocumented error codes.
virtual const IImport_result * mi::neuraylib::IImport_api::import_elements_from_string |
( |
ITransaction * |
transaction, |
|
|
const char * |
data, |
|
|
const char * |
file_extension, |
|
|
const IMap * |
importer_options = nullptr , |
|
|
const IImpexp_state * |
parent_state = nullptr |
|
) |
| const |
|
pure virtual |
Imports scene data from a string into the database.
In all other respects it behaves like the import_elements() method. However, this function can only handle non-binary data, since the data is passed in as a zero-terminated string.
This method supports following options:
- Parameters
-
transaction | The transaction to be used. |
data | The string that holds the scene elements to import. |
file_extension | The file extension. Since there is no file name/URI in this variant, this string is used to select the importer, e.g., ".mdl" . |
importer_options | The importer options (see above). |
parent_state | An optional state that can be passed by a parent importer, or nullptr . Such a state is used to resolve relative URIs w.r.t. to the URI of the parent state. In addition, the parent state can be used by the importer for better diagnostics in case of errors. |
- Returns
- The import result uses the following error codes.
- 0: The import operation was successful.
- 1: The data was invalid (
data
is nullptr
or the empty string).
- 2: The data format is invalid (
file_extension
is nullptr
or the empty string).
- 3: There is no appropriate importer for this file extension (and data).
- 4: The importer failed to create the instance of mi::neuraylib::IImpexp_state.
- 5: The importer did not return a valid instance of mi::neuraylib::IImport_result.
- 6: The option '...' has an invalid type.
- 7: The option '...' has an invalid value.
- 4000-5999: Reserved for importer-specific error codes.
The severity of all listed errors (excluding the importer-specific error codes) is mi::base::details::MESSAGE_SEVERITY_ERROR. There might be other undocumented error codes.
When used to import MDL modules, the following options are also supported:
"module_name"
of type mi::IString: The MDL name of the module that is represented by data
. Note that there must be no file-based MDL module of that name in the configured search path, otherwise the method will fail. That is, this method can not be used to shadow file-based MDL modules. It is also not possible to use this method to change already imported MDL modules. This option is mandatory if file_extension
is ".mdl"
.
When used to import MDL modules, the following error codes are possible:
- 8: The option 'module_name' is mandatory for MDL modules.