GetArea
For perfomance reasons it is benefitial to call it with vertex and index array when
the arrays are calculated anyway or Volume and Area are needed.
There are two ways to call GetVolume:
vertices and indices are both zero: in this case the instance will be
recalculated when needed. It is expected the client does not
need the arrays itself or there is no performance issue.
vertices and indices are both given: the call is placed directly after
updateBuffer calls and no structural change to depending instances have
been done in between. The transformationMatrix array is not needed,
even if it is being used due to not giving any performance gain to this
operation.
Note: internally the call does not store its results, any optimization based on known
dependancies between instances need to be implemented on the client.
Note: in case precision is important and vertex array is 32 bit it is advised to
set vertices and indices to 0 even if arrays are existing.
Syntax
public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetArea")] public static extern double GetArea(Int64 owlInstance, ref float vertices, ref Int32 indices); [DllImport(EngineDLL, EntryPoint = "GetArea")] public static extern double GetArea(Int64 owlInstance, ref float vertices, ref Int64 indices); [DllImport(EngineDLL, EntryPoint = "GetArea")] public static extern double GetArea(Int64 owlInstance, ref double vertices, ref Int32 indices); [DllImport(EngineDLL, EntryPoint = "GetArea")] public static extern double GetArea(Int64 owlInstance, ref double vertices, ref Int64 indices); [DllImport(EngineDLL, EntryPoint = "GetArea")] public static extern double GetArea(Int64 owlInstance, IntPtr vertices, IntPtr indices);
Property owlInstance
Size: 64 bit / 8 byte (value)Property vertices
Size: 64 bit / 8 byte (reference)Property indices
Size: 64 bit / 8 byte (reference)
Example
Here you can find code snippits that show how the API call GetArea 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); // // Simple use of the derived information functions // double volume = Engine.x86_64.GetVolume(instanceBox, (IntPtr) 0, (IntPtr) 0), area = Engine.x86_64.GetArea(instanceBox, (IntPtr) 0, (IntPtr) 0), perimeter = Engine.x86_64.GetPerimeter(instanceBox); 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]); // // Reuse knowledge to improve performance (in case of single precision, with less accuracy) // volume = Engine.x86_64.GetVolume(instanceBox, ref vertexBuffer[0], ref indexBuffer[0]); area = Engine.x86_64.GetArea(instanceBox, ref vertexBuffer[0], ref indexBuffer[0]); } // // The resulting model can be viewed in 3D-Editor.exe // Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin"); Engine.x86_64.CloseModel(model); } }