GetVolume
There are two ways to call GetVolume:
vertexBuffer and indexBuffer 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.
vertexBuffer and indexBuffer 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
dependencies between instances need to be implemented on the client.
Note: in case precision is important and vertex buffer is 32 bit it is advised to
set vertexBuffer and indexBuffer to 0 even if arrays are existing.
Syntax
public const string enginedll = @"engine.dll"; [DllImport(enginedll, EntryPoint = "GetVolume")] public static extern double GetVolume(Int64 owlInstance, ref float vertexBuffer, ref Int32 indexBuffer); [DllImport(enginedll, EntryPoint = "GetVolume")] public static extern double GetVolume(Int64 owlInstance, ref float vertexBuffer, ref Int64 indexBuffer); [DllImport(enginedll, EntryPoint = "GetVolume")] public static extern double GetVolume(Int64 owlInstance, ref double vertexBuffer, ref Int32 indexBuffer); [DllImport(enginedll, EntryPoint = "GetVolume")] public static extern double GetVolume(Int64 owlInstance, ref double vertexBuffer, ref Int64 indexBuffer); [DllImport(enginedll, EntryPoint = "GetVolume")] public static extern double GetVolume(Int64 owlInstance, IntPtr vertexBuffer, IntPtr indexBuffer); public static double GetVolume(Int64 owlInstance) { return GetVolume(owlInstance, IntPtr.Zero, IntPtr.Zero); }
Property owlInstance
Size: 64 bit / 8 byte (value)Property vertexBuffer
Size: 32 bit / 4 byte (reference)Property indexBuffer
Size: 32 bit / 4 byte (reference)
Example (based on pure API calls)
Here you can find code snippits that show how the API call GetVolume can be used.
using RDF; // include at least engine.cs within your solution ... static void Main(string[] args) { Int64 model = RDF.engine.CreateModel(); if (model != 0) { // // Classes // Int64 classBox = RDF.engine.GetClassByName(model, "Box"); // // Datatype Properties (attributes) // Int64 propertyLength = RDF.engine.GetPropertyByName(model, "length"), propertyWidth = RDF.engine.GetPropertyByName(model, "width"), propertyHeight = RDF.engine.GetPropertyByName(model, "height"); // // Instances (creating) // Int64 instanceBox = RDF.engine.CreateInstance(classBox, (string) null); double length = 2.8, width = 1.3, height = 1.4; RDF.engine.SetDatatypeProperty(instanceBox, propertyLength, ref length, 1); RDF.engine.SetDatatypeProperty(instanceBox, propertyWidth, ref width, 1); RDF.engine.SetDatatypeProperty(instanceBox, propertyHeight, ref height, 1); // // Simple use of the derived information functions // double volume = RDF.engine.GetVolume(instanceBox, (IntPtr) 0, (IntPtr) 0), area = RDF.engine.GetArea(instanceBox, (IntPtr) 0, (IntPtr) 0), perimeter = RDF.engine.GetPerimeter(instanceBox); Int64 vertexBufferSize = 0, indexBufferSize = 0; RDF.engine.CalculateInstance(instanceBox, out vertexBufferSize, out indexBufferSize, (IntPtr) 0); if (vertexBufferSize != 0 && indexBufferSize != 0) { float[] vertexBuffer = new float[6 * vertexBufferSize]; RDF.engine.UpdateInstanceVertexBuffer(instanceBox, ref vertexBuffer[0]); Int32[] indexBuffer = new Int32[indexBufferSize]; RDF.engine.UpdateInstanceIndexBuffer(instanceBox, ref indexBuffer[0]); // // Reuse knowledge to improve performance (in case of single precision, with less accuracy) // volume = RDF.engine.GetVolume(instanceBox, ref vertexBuffer[0], ref indexBuffer[0]); area = RDF.engine.GetArea(instanceBox, ref vertexBuffer[0], ref indexBuffer[0]); } // // The resulting model can be viewed in 3D-Editor.exe // RDF.engine.SaveModel(model, "c:\\created\\myFile.bin"); RDF.engine.CloseModel(model); } }