GetConceptualFaceArea

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

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetConceptualFaceArea")]
public static extern double GetConceptualFaceArea(Int64 conceptualFace, ref float vertices, ref Int32 indices);

[DllImport(EngineDLL, EntryPoint = "GetConceptualFaceArea")]
public static extern double GetConceptualFaceArea(Int64 conceptualFace, ref float vertices, ref Int64 indices);

[DllImport(EngineDLL, EntryPoint = "GetConceptualFaceArea")]
public static extern double GetConceptualFaceArea(Int64 conceptualFace, ref double vertices, ref Int32 indices);

[DllImport(EngineDLL, EntryPoint = "GetConceptualFaceArea")]
public static extern double GetConceptualFaceArea(Int64 conceptualFace, ref double vertices, ref Int64 indices);

[DllImport(EngineDLL, EntryPoint = "GetConceptualFaceArea")]
public static extern double GetConceptualFaceArea(Int64 conceptualFace, IntPtr vertices, IntPtr indices);    

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 vertices

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 vertices array.

Property indices

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

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

using Engine;

...

static void Main(string[] args)
{
    Int64   model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64 classBox = Engine.x86_64.GetClassByName(model, "Box");

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByName(model, "length"),
                propertyWidth = Engine.x86_64.GetPropertyByName(model, "width"),
                propertyHeight = Engine.x86_64.GetPropertyByName(model, "height");

        //
        //  Instances (creating)
        //
        Int64   instanceBox = Engine.x86_64.CreateInstance(classBox, (string) null);

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

        Engine.x86_64.SetDatatypeProperty(instanceBox, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceBox, propertyWidth, ref width, 1);
        Engine.x86_64.SetDatatypeProperty(instanceBox, propertyHeight, ref height, 1);

        Int64   vertexBufferSize = 0,
                indexBufferSize = 0;
        Engine.x86_64.CalculateInstance(instanceBox, out vertexBufferSize, out indexBufferSize, (IntPtr) 0);
        if (vertexBufferSize != 0 && indexBufferSize != 0)
        {
            float[] vertexBuffer = new float[6 * vertexBufferSize];
            Engine.x86_64.UpdateInstanceVertexBuffer(instanceBox, ref vertexBuffer[0]);

            Int32[] indexBuffer = new Int32[indexBufferSize];
            Engine.x86_64.UpdateInstanceIndexBuffer(instanceBox, ref indexBuffer[0]);

            Int64   conceptualFaceCnt = Engine.x86_64.GetConceptualFaceCnt(instanceBox);
            for (Int64 index = 0; index < conceptualFaceCnt; index++) {
                Int64   startIndexTriangles = 0,
                        noIndicesTriangles = 0,
                        conceptualFace =
                    Engine.x86_64.GetConceptualFaceEx(
                            instanceBox, index,
                            out startIndexTriangles, out noIndicesTriangles,
                            (IntPtr) 0, (IntPtr) 0,
                            (IntPtr) 0, (IntPtr) 0,
                            (IntPtr) 0, (IntPtr) 0,
                            (IntPtr) 0, (IntPtr) 0
                        );

                double  conceptualFaceArea =
                            Engine.x86_64.GetConceptualFaceArea(
                                    conceptualFace,
                                    ref vertexBuffer[0],
                                    ref indexBuffer[0]
                                ),
                        conceptualFacePerimeter =
                            Engine.x86_64.GetConceptualFacePerimeter(
                                    conceptualFace
                                );
            }
        }

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