ImportModelA

This function imports a design tree via an array.
The design tree will be added to the given existing model.
The return value contains the first instance not referenced by any other instance or zero if it does not exist. In case the imported model is created with SaveInstanceTree() this instance is unique and equal to the instance used within the call SaveInstanceTree().

Syntax

//
//   Strong typing definition
//
OwlInstance     ImportModelA(
                        OwlModel                model,
                        const unsigned char     * content,
                        int64_t                 size
                    );

static  inline  OwlInstance ImportModelA(
                                    OwlModel                model,
                                    const unsigned char     * content
                                )
{
    return  ImportModelA(
                    model,
                    content,
                    strlen((const char*) content)   //    size
                );
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall ImportModelA(
                                                int64_t                 model,
                                                const unsigned char     * content,
                                                int64_t                 size
                                            );

static  inline  int64_t ImportModelA(
                                int64_t                 model,
                                const unsigned char     * content
                            )
{
    return  ImportModelA(
                    model,
                    content,
                    strlen((const char*) content)   //    size
                );
}
    

Property model

Size: 64 bit / 8 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

Property content

Size: 64 bit / 8 byte (reference)
The content of this IO call, the size of the content is defined by attribute size.

Property size

Size: 64 bit / 8 byte (value)
The size of the content as defined in number of bytes.

Example (based on pure API calls)

Here you can find code snippits that show how the API call ImportModelA can be used.

#include    "./include/engine.h"
#include    <assert.h>

void    ImportModelByArray(int64_t model, wchar_t * importFileName)
{
    FILE    * myFileRead = nullptr;

    _wfopen_s(&myFileRead, importFileName, L"rb");
    if (model && &myFileRead) {
        fseek(myFileRead, 0L, SEEK_END);
        int_t   size = ftell(myFileRead);
        rewind(myFileRead);

        if (size) {
            unsigned char   * content = new unsigned char[size];
            size = fread(content, 1, size, myFileRead);

            ImportModelA(model, content, (int64_t) size);
            delete[] content;
        }
        else {
            assert(false);
        }

        fclose(myFileRead);
    }
    else {
        assert(false);
    }
}