GetConceptualFaceArea

This function returns the area of a given Conceptual Face. The attributes vertex buffer and index buffer are optional but will improve performance if defined.

Syntax

//
//   Strong typing definition
//
double          GetConceptualFaceArea(
                        ConceptualFace          conceptualFace,
                        const void              * vertexBuffer,
                        const void              * indexBuffer
                    );

static  inline  double  GetConceptualFaceArea(
                                ConceptualFace          conceptualFace
                            )
{
    const void * vertexBuffer = nullptr,
                * indexBuffer = nullptr;
    return  GetConceptualFaceArea(
                    conceptualFace,
                    vertexBuffer,
                    indexBuffer
                );
}


//
//   Weak typing definition
//
double  __declspec(dllexport) __stdcall GetConceptualFaceArea(
                                                int64_t                 conceptualFace,
                                                const void              * vertexBuffer,
                                                const void              * indexBuffer
                                            );

static  inline  double  GetConceptualFaceArea(
                                int64_t                 conceptualFace
                            )
{
    const void * vertexBuffer = nullptr,
                * indexBuffer = nullptr;
    return  GetConceptualFaceArea(
                    conceptualFace,
                    vertexBuffer,
                    indexBuffer
                );
}
    

Property conceptualFace

Size: 64 bit / 8 byte (value)
A conceptual face is a face that does not have to be placed within one plane. For example a Cylinder has typically 3 conceptual faces where a Box typically has 6 conceptual faces. In case of a Box the 'normal' face count is equal to the conceptual face count, in case of a Cylinder the 'normal' face count depends on the segmentation, for example in case of 36 segments, it will have 38 faces but still 3 conceptual faces.

Property vertexBuffer

Size: 64 bit / 8 byte (reference)
The array of vertices, this array is allocated by the host application. Depending on SetFormat() the array exists of 32 bit (4 byte) single precision floats or 64 bit (8 byte) double precision floats. Each vertex elements exists of several elemens, i.e. X, Y, Z values, but optionally also nX, nY, nZ, texture coordinates, bitangent / binormal coordinates, colors etc. What is contained is defined by SetFormat() and can be retrieved via GetFormat(). The host application has to make sure enough memory is allocated for the vertexBuffer array.

Property indexBuffer

Size: 64 bit / 8 byte (reference)
The array of indices, this array is allocated by the host application. Depending on SetFormat() the array exists of 32 bit (4 byte) integers or 64 bit (8 byte) integeres.

Example (based on pure API calls)

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

#include    "./include/engine.h"

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

    if (model) {
        //
        //  Classes
        //
        int64_t classBox = GetClassByName(model, "Box");

        //
        //  Datatype Properties (attributes)
        //
        int64_t propertyLength = GetPropertyByName(model, "length"),
                propertyWidth = GetPropertyByName(model, "width"),
                propertyHeight = GetPropertyByName(model, "height");

        //
        //  Instances (creating)
        //
        int64_t instanceBox = CreateInstance(classBox, nullptr);

        double  length = 2.8,
                width = 1.3,
                height = 1.4;

        SetDatatypeProperty(instanceBox, propertyLength, &length, 1);
        SetDatatypeProperty(instanceBox, propertyWidth, &width, 1);
        SetDatatypeProperty(instanceBox, propertyHeight, &height, 1);

        int64_t vertexBufferSize = 0,
                indexBufferSize = 0;
        CalculateInstance(instanceBox, &vertexBufferSize, &indexBufferSize, 0);
        if (vertexBufferSize && indexBufferSize) {
            float   * vertexBuffer = new float[6 * vertexBufferSize];
            UpdateInstanceVertexBuffer(instanceBox, vertexBuffer);

            int32_t * indexBuffer = new int32_t[indexBufferSize];
            UpdateInstanceIndexBuffer(instanceBox, indexBuffer);

            int64_t conceptualFaceCnt = GetConceptualFaceCnt(instanceBox);
            for (int64_t index = 0; index < conceptualFaceCnt; index++) {
                int64_t startIndexTriangles = 0,
                        noIndicesTriangles = 0,
                        conceptualFace =
                    GetConceptualFace(
                            instanceBox, index,
                            &startIndexTriangles, &noIndicesTriangles,
                            nullptr, nullptr,
                            nullptr, nullptr,
                            nullptr, nullptr,
                            nullptr, nullptr
                        );

                double  conceptualFaceArea =
                            GetConceptualFaceArea(
                                    conceptualFace,
                                    vertexBuffer,
                                    indexBuffer
                                ),
                        conceptualFacePerimeter =
                            GetConceptualFacePerimeter(
                                    conceptualFace
                                );
            }
        }

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        SaveModel(model, "c:\\created\\myFile.bin");
        CloseModel(model);
    }
}