initializeModellingInstance

The number of vertices and number of indices needed for storing the geometry of the given IFC instance is calculated by this function.

Syntax

public const string IFCEngineDLL = @"IFCEngine.dll";

[DllImport(IFCEngineDLL, EntryPoint = "initializeModellingInstance")]
public static extern Int64 initializeModellingInstance(Int64 model, ref Int64 noVertices, ref Int64 noIndices, double scale, Int64 instance);    

Property model

Size: 64 bit / 8 byte (value)
Handle of the model containing the IFC file, this handle is needed in many other calls and given when the model is created.

Property noVertices

Size: 64 bit / 8 byte (reference)
The number of vertices that are needed for this instance.

Property noIndices

Size: 64 bit / 8 byte (reference)
The number of indices that are needed for this instance.

Property scale

Size: 64 bit / 8 byte (value)
Ignore this argument use 1 as default value.

Property instance

Size: 64 bit / 8 byte (value)
Handle of an instance within an IFC file, for example #31313 = IFCWALLSTANDARDCASE(...)

Examples

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

void GenerateGeometry(Int64 model, Int64 ifcColumnInstance)
{
    Int64	setting = 0, mask = 0;
    mask += IfcEngine.x64.flagbit2;        //    PRECISION (32/64 bit)
    mask += IfcEngine.x64.flagbit3;        //    INDEX ARRAY (32/64 bit)
    mask += IfcEngine.x64.flagbit5;        //    NORMALS
    mask += IfcEngine.x64.flagbit8;        //    TRIANGLES
    mask += IfcEngine.x64.flagbit12;       //    WIREFRAME

    setting += 0;                          //    SINGLE PRECISION (float)
    setting += 0;                          //    32 BIT INDEX ARRAY (Int32)
    setting += IfcEngine.x64.flagbit5;     //    NORMALS ON
    setting += IfcEngine.x64.flagbit8;     //    TRIANGLES ON
    setting += 0;                          //    WIREFRAME OFF
    IfcEngine.x64.setFormat(model, setting, mask);
    //  The setFormat call is not called for each column instance we are generating geometry for.
    //  This is not needed when the setting/mask are not changed, the latest setting always applies.

    Int64 noVertices = 0, noIndices = 0;
    IfcEngine.x64.initializeModellingInstance(model, ref noVertices, ref noIndices, 0, ifcColumnInstance);

    if  (noVertices != 0  &&  noIndices != 0) {
        float[] vertexArray = new float[noVertices * 6];    //    
        Int32[] indexArray = new Int32[noIndices];
        IfcEngine.x64.finalizeModelling(model, vertexArray, indexArray, 0);

        Int64 mode = 0,
              startVertex = 0, startIndex = 0, primitiveCount = 0;
        IfcEngine.x64.getInstanceInModelling(model, ifcColumnInstance, mode, ref startVertex, ref startIndex, ref primitiveCount);

        //
        //  Array's vertexArray and indexArray are filled with data.
        //
        //  startIndex points to the first index in the indexArray of relevance
        //  In total 3 * primitiveCount elements on the indexArray represent all the triangles of the object.
        //
        //  startVertex is a derived value and given as some applications can get performance gain from this information.
        //

        ...
    }
}

void GetColumns(Int64 model)
{
    Int64 ifcColumnInstances = IfcEngine.x64.sdaiGetEntityExtentBN(model, "IFCCOLUMN"),
          noIfcColumnInstances = IfcEngine.x64.sdaiGetMemberCount(ifcColumnInstances);
    if (noIfcColumnInstances != 0)
    {
        for (Int64 i = 0; i < noIfcColumnInstances; i++)
        {
            Int64 ifcColumnInstance = 0;
            IfcEngine.x64.engiGetAggrElement(ifcColumnInstances, i, IfcEngine.x64.sdaiINSTANCE, out ifcColumnInstance);

            GenerateGeometry(model, ifcColumnInstance);
        }
    }
}