CloseModel

This function closes the model. After this call none of the instances and classes within the model can be used anymore, also garbage collection is not allowed anymore, in default compilation the model itself will be known in the kernel, however known to be disabled. Calls containing the model reference will be protected from crashing when called.

Syntax

//
//   Strong typing definition
//
int64_t         CloseModel(
                        OwlModel                model
                    );


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall CloseModel(
                                                int64_t                 model
                                            );
    

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.

Example (based on pure API calls)

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

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

void    CreateContent()
{
    int64_t model = CreateModel();

    if (model) {
        //
        //  Classes
        //
        int64_t classBooleanOperation = GetClassByName(model, "BooleanOperation"),
                classCube = GetClassByName(model, "Cube"),
                classCylinder = GetClassByName(model, "Cylinder"),
                classMatrix = GetClassByName(model, "Matrix"),
                classTransformation = GetClassByName(model, "Transformation");

        //
        //  Object Properties (relations)
        //
        int64_t propertyFirstObject = GetPropertyByName(model, "firstObject"),
                propertyMatrix = GetPropertyByName(model, "matrix"),
                propertyObject = GetPropertyByName(model, "object"),
                propertySecondObject = GetPropertyByName(model, "secondObject");

        //
        //  Datatype Properties (attributes)
        //
        int64_t property_41 = GetPropertyByName(model, "_41"),
                propertyLength = GetPropertyByName(model, "length"),
                propertyRadius = GetPropertyByName(model, "radius"),
                propertySegmentationParts = GetPropertyByName(model, "segmentationParts"),
                propertyType = GetPropertyByName(model, "type");

        //
        //  Instances
        //
        int64_t instanceBooleanOperation = CreateInstance(classBooleanOperation, nullptr),
                instanceCube = CreateInstance(classCube, nullptr),
                instanceCylinder = CreateInstance(classCylinder, nullptr),
                instanceMatrix = CreateInstance(classMatrix, nullptr),
                instanceTransformation = CreateInstance(classTransformation, nullptr);

        SetObjectProperty(instanceTransformation, propertyObject, &instanceCylinder, 1);
        SetObjectProperty(instanceTransformation, propertyMatrix, &instanceMatrix, 1);

        double  length = 1.8,
                radius = 1.3,
                offsetX = 4.2;
        int64_t segmentationParts = 36;
        
        SetDatatypeProperty(instanceCylinder, propertyLength, &length, 1);
        SetDatatypeProperty(instanceCylinder, propertyRadius, &radius, 1);
        SetDatatypeProperty(instanceCylinder, propertyFirstObject, &segmentationParts, 1);
        SetDatatypeProperty(instanceMatrix, property_41, &offsetX, 1);

        //
        //  Saves only the Transformation and (indirectly) related instances
        //
        SaveInstanceTreeW(instanceTransformation, L"c:\\created\\TranformedCylinder.bin");

        SetObjectProperty(instanceBooleanOperation, propertyFirstObject, &instanceCube, 1);
        SetObjectProperty(instanceBooleanOperation, propertySecondObject, &instanceCylinder, 1);

        length = 2.1;
        int64_t type = 1;

        SetDatatypeProperty(instanceCube, propertyLength, &length, 1);
        SetDatatypeProperty(instanceBooleanOperation, propertyType, &type, 1);

        //
        //  Saves all instances
        //
        SaveModelW(model, L"c:\\created\\TranformedCylinderAndCubeWithSubtractedCylinder.bin");

        //
        //  Saves only the Boolean Operation and (indirectly) related instances
        //
        SaveInstanceTreeW(instanceBooleanOperation, L"c:\\created\\CubeWithSubtractedCylinder.bin");

        CloseModel(model);
    }
}