You are here: Start » AVL.NET » AVL.NET - AVL Relation

# AVL.NET - AVL Relation

### Overview

AVL.NET is an AVL wrapper which means that when we call AVL.NET functions, we actually call native AVL functions. That requires the AVL.dll library to be present in the same location as the AvlNet.dll assembly when running the application that references AvlNet.dll assembly.

### Functions

In .NET a function must be a member of some type (which makes it a method rather than a function). Therefore while in AVL functions may be accessed through the namespace only (e.g. avl::AddImages(...)), in AVL.NET all the library functions are static methods of the AVL class:

using AvlNet;



### Types

Most of the native AVL types have their counterpart in the AvlNet.dll assembly, which are native AVL type wrappers. Internally, a managed type contains a native pointer to the AVL type and because of those native pointers (unmanaged resources), objects of those types need to be disposed properly when not used any more to avoid memory leaks. This is guaranteed thanks to the System.IDisposable interface but it is the user's responsibility to call it's Dispose method to release resources immediately instead of leaving it to the next Garbage Collection. This may increase the application performance. More about managing AvlNet types can be found here.

### Optionals and Conditionals

The AVL's atl::Optional and atl::Conditional types are both mapped by the AvlNet.NullableRef<T> or AvlNet.SafeNullableRef<T> types for reference types and System.Nullable<T> for value types.

The table below lists how different types are handled in AVL.NET:

AVL TypeAVL.NET Type
Plain Types (e.g float, int, double, long)
float
float
atl::Optional<float>
System.Nullable<float>
atl::Conditional<float>
atl::Array<float>
System.Collections.Generic.List<float>
Structures (e.g. Point2D, Point3D, Circle2D)
atl::Optional<atl::Point2D>
System.Nullable<AvlNet.Point2D>
atl::Conditional<atl::Point2D>
atl::Array<atl::Point2D>
System.Collections.Generic.IList<AvlNet.Point2D>
Classes (e.g. Region, Image, Path)
avl::Region
AvlNet.Region
atl::Optional<avl::Region>
AvlNet.NullableRef<Region>
or
AvlNet.SafeNullableRef<Region>
atl::Conditional<avl::Region>
atl::Array<avl::Region>
AvlNet.SafeList<Region>
or
System.Collections.Generic.List<Region>

### Settings

There are such options that may control the functions behavior as diagnostic mode, SSE acceleration, parallel computing, etc. Most of them can also be modified in AVL.NET with Settings class.

AVLAVL.NET
void avl::EnableSSEAcceleration(bool enable)
AvlNet.Settings.IsSSEEnabled setter
bool avl::GetSSEAccelerationEnabled()
AvlNet.Settings.IsSSEEnabled getter
void avl::SetParallelComputing(bool enabled, int num_threads)
AvlNet.Settings.IsParallelComputingEnabled setter

AvlNet.Settings.ParallelComputingThreadCount setter
int avl::GetParallelComputingThreadsCount()
AvlNet.Settings.ParallelComputingThreadCount getter
void avl::EnableAvlDiagnosticOutputs(bool enable)
AvlNet.Settings.IsDiagnosticModeEnabled setter
bool avl::GetAvlDiagnosticOutputsEnabled()
AvlNet.Settings.IsDiagnosticModeEnabled getter

Following snippet presents example Settings class usage. This is a part of the bigger example.

//...
private void diagnosticModeButton_CheckedChanged(object sender, EventArgs e)
{
AvlNet.Settings.IsDiagnosticModeEnabled = (sender as ToolStripButton).Checked;

UpdateImages();
}
//...


In many functions in AVL optional inputs (e.g. inRoi in AddChannels) may be provided with atl::NIL value which makes the function execute with default ROI. In AVL.NET such methods have appropriate overloads with those optional values skipped.
The same refers to optional outputs. In AVL it is common to provide atl::NIL for such outputs when one does not want the function to calculate value for it. It is impossible in .NET to disable output calculation that way though. Instead, appropriate overloads may be used to skip the output calculation e.g. PathToLineDistance in one of its overloads skips the outConnectingSegment output.