sdaiCloseModel

This function closes the model. After this call no instance handles will be available including all handles referencing the geometry of this specific file, 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
//
void            sdaiCloseModel(
                        SdaiModel               model
                    );


//
//   Weak typing definition
//
void    __declspec(dllexport) __stdcall   sdaiCloseModel(
                                                                        int_t                   model
                                                                    );
    

Property model

Size: 32 bit / 4 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 sdaiCloseModel can be used.

#include    "./include/ifcengine.h"
#include    <iostream>

void    OpenModel__optionI(
                const char  * fileName
            )
{
    //
    //  The advised manner of opening an IFC (or ifcXML) file is by using embedded schema's that can be recognized automatically
    //

    SdaiModel   model = sdaiOpenModelBN(0, fileName, "");

    if (model) {
        SdaiInteger entityCount = engiGetEntityCount(model), instanceCount = 0;

        for (SdaiInteger i = 0; i < entityCount; i++) {
            SdaiEntity  entity = engiGetEntityElement(model, i);

            SdaiAggr    ifcInstances   = sdaiGetEntityExtent(model, entity);
            SdaiInteger noIfcInstances = sdaiGetMemberCount(ifcInstances);
                
            instanceCount += noIfcInstances;
        }

        std::cout << "entity count (schema): " << entityCount << "\n";
        std::cout << "instance count (ifc file): " << instanceCount << "\n";

        sdaiCloseModel(model);
    }
}

void    OpenModel__optionII(
                const char  * fileName
            )
{
    //
    //  It is possible to overrule the automatic selection of an embedded schema
    //  The following options are available for embedded schemas:
    //      IFC2X3 (version 2.3.0.1, i.e. IFC2x3 TC1 'ISO/PAS 16739:2005')
    //      IFC4   (version 4.0.2.1, i.e. IFC4 ADD2 TC1 'ISO 16739-1:2018')
    //      IFC4X1 (version 4.1.0.0, i.e. IFC4.1)
    //      IFC4X2 (version 4.2.0.0, i.e. IFC4.2)
    //      IFC4X3 (version 4.3.2.0, i.e. IFC4.3 ADD2)
    //      IFC4X4 (in development,  i.e. IFC4.4)
    //      AP203  (ISO 10303-203:2011 edition 2)    if STEP Engine code part is embedded in the compiled library
    //      AP214  (ISO 10303-214:2010 edition 3)    if STEP Engine code part is embedded in the compiled library
    //      AP242  (ISO 10303-242:2022 edition 3)    if STEP Engine code part is embedded in the compiled library
    //      CIS/2                                    if CIS/2 Engine code part is embedded in the compiled library
    //

    SdaiModel   model = sdaiOpenModelBN(0, fileName, "IFC4");

    if (model) {
        SdaiInteger entityCount = engiGetEntityCount(model), instanceCount = 0;

        for (SdaiInteger i = 0; i < entityCount; i++) {
            SdaiEntity  entity = engiGetEntityElement(model, i);

            SdaiAggr    ifcInstances = sdaiGetEntityExtent(model, entity);
            SdaiInteger noIfcInstances = sdaiGetMemberCount(ifcInstances);

            instanceCount += noIfcInstances;
        }

        std::cout << "entity count (schema): " << entityCount << "\n";
        std::cout << "instance count (ifc file): " << instanceCount << "\n";

        sdaiCloseModel(model);
    }
}

void    OpenModel__optionIII(
                const char  * fileName,
                const char  * schemaName
            )
{
    //
    //  It is also possible to load a schema file (.exp)
    //  This schema can be one of the supported schemas, however it is
    //  also possible to use an adjusted or fully self developed schema
    // 
    //  Adjusted schemas will still support geometrical concepts (depending on the adjustments)
    //

    SdaiModel   model = sdaiOpenModelBN(0, fileName, schemaName);

    if (model) {
        SdaiInteger entityCount = engiGetEntityCount(model), instanceCount = 0;

        for (SdaiInteger i = 0; i < entityCount; i++) {
            SdaiEntity  entity = engiGetEntityElement(model, i);

            SdaiAggr    ifcInstances = sdaiGetEntityExtent(model, entity);
            SdaiInteger noIfcInstances = sdaiGetMemberCount(ifcInstances);

            instanceCount += noIfcInstances;
        }

        std::cout << "entity count (schema): " << entityCount << "\n";
        std::cout << "instance count (ifc file): " << instanceCount << "\n";

        sdaiCloseModel(model);
    }
}

void    OpenModel__optionIV(
                const char  * fileName
            )
{
    //
    //  It is also possible to load a file without schema,
    //  in this case only the header is loaded, this is a fast option to read headers.
    //

    SdaiModel   model = sdaiOpenModelBN(0, fileName, 0);

    if (model) {
        SdaiInteger entityCount = engiGetEntityCount(model), instanceCount = 0;

        for (SdaiInteger i = 0; i < entityCount; i++) {
            SdaiEntity  entity = engiGetEntityElement(model, i);

            SdaiAggr    ifcInstances = sdaiGetEntityExtent(model, entity);
            SdaiInteger noIfcInstances = sdaiGetMemberCount(ifcInstances);

            instanceCount += noIfcInstances;
        }

        //  In this specific case both entityCount and instanceCount are expected to be zero
        std::cout << "entity count (schema): " << entityCount << "\n";
        std::cout << "instance count (ifc file): " << instanceCount << "\n";

        sdaiCloseModel(model);
    }
}