Open Inventor C++ vs Open Inventor .NET

The .NET framework implies differences between the C++ and the .NET API. This section may be skipped by .NET-only developers. However, it may be helpful if you are already familiar with the Open Inventor C++ API.

Classes and Extensions not Available in Open Inventor .NET

C++ Features not Available in Open Inventor .NET

The following is not possible with Open Inventor .NET:

C++ Features Available in .NET But With a Different Interface

The following features cannot be implemented in the same way as they are implemented in C++.

Callback mechanism

The callback mechanism is used very often by Open inventor C++. Callback functions are defined as follows:

typedef <return_type> functionCB(void * userData, type1 arg1,..., typen argn); 
static <return_type> myFunctionCB(void * userData, type1 arg1,..., typen argn) { 
... 
}

The callback is registered by calling an addCallback method:

addCallback((functionCB*) myFunctionCB, this);

The .NET implementation is based on delegates and each type of callback is implemented by a specific delegate.

The following example shows how to set a callback on a selection point event.

bool SelectionPointCB(SoAction action, SoPrimitiveVertex v){
SoDetail detail = v.GetDetail(); int coordIndex = ((SoPointDetail) detail).GetCoordinateIndex(); ... return false; // continue examining next primitives
}

The delegate is registered as follows:

SoSelection selection = new SoExtSelection();
selection.SetPointFilterCallback(new SoExtSelection.PointCB(SelectionPointCB));

Pointers, values

All objects are handled through references -- not pointers or values, but only references.

C++

SoCone *cone = new SoCone;
cone->height.setValue( 3 );

C#

SoCone cone = new SoCone();
cone.height.SetValue( 3 ); // note also difference in capitalization of method name

Another minor difference between C++ and C# involves the new operator. The example below shows setting coordinate values into the vertex field of an SoVertexProperty node.

C++

Node->vertex.set1Value (0, SbVec3f(x,y,z));

C#

Node.vertex.Set1Value (0, new SbVec3f(x,y,z)); // "new" is required 

C++ Features That Are Not Necessary in .NET