sdaiOpenModelBNUnicode

This function opens the model on location fileName.
Attribute repository will be ignored, they are their because of backward compatibility.
A handle to the model will be returned, or 0 in case something went wrong.

Syntax

//
//   Strong typing definition
//
SdaiModel       sdaiOpenModelBNUnicode(
                        SdaiRep                 repository,
                        const wchar_t           * fileName,
                        const wchar_t           * schemaName
                    );

static  inline  SdaiModel   sdaiOpenModelBNUnicode(
                                    SdaiRep                 repository,
                                    wchar_t                 * fileName,
                                    wchar_t                 * schemaName
                                )
{
    return  sdaiOpenModelBNUnicode(
                    repository,
                    (const wchar_t*) fileName,
                    (const wchar_t*) schemaName
                );
}


//
//   Weak typing definition
//
int_t   __declspec(dllexport) __stdcall sdaiOpenModelBNUnicode(
                                                int_t                   repository,
                                                const wchar_t           * fileName,
                                                const wchar_t           * schemaName
                                            );

static  inline  int_t   sdaiOpenModelBNUnicode(
                                int_t                   repository,
                                wchar_t                 * fileName,
                                wchar_t                 * schemaName
                            )
{
    return  sdaiOpenModelBNUnicode(
                    repository,
                    (const wchar_t*) fileName,
                    (const wchar_t*) schemaName
                );
}
    

Property repository

Size: 32 bit / 4 byte (value)
Ignore this attribute, the value will be ignored in the current implementation, present for backwards compatibility.

Property fileName

Size: 32 bit / 4 byte (reference)
The file name of the file as available in the file system in Unicode (wchar_t *). The given wchar_t array will not be adjusted. The size of each wchar_t element is depending on the OS, both 16 bit / 2 bytes wchar_t elements as well as 32 bit / 4 byte wchar_t elements are recognized and supported.

Property schemaName

Size: 32 bit / 4 byte (reference)
The file name of the file as available in the file system in Unicode (wchar_t *). The given wchar_t array will not be adjusted. The size of each wchar_t element is depending on the OS, both 16 bit / 2 bytes wchar_t elements as well as 32 bit / 4 byte wchar_t elements are recognized and supported.

Example (based on pure API calls)

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

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

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

    SdaiModel   model = sdaiOpenModelBNUnicode(0, fileName, L"");

    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 wchar_t   * 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 = sdaiOpenModelBNUnicode(0, fileName, L"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 wchar_t   * fileName,
                const wchar_t   * 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 = sdaiOpenModelBNUnicode(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 wchar_t   * 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 = sdaiOpenModelBNUnicode(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);
    }
}