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
- The DialogViz classes provided with Open
Inventor C++ from Mercury are not available because you will use
the standard Winforms package instead.
-
The GDI output available with HardCopy C++
is not currently available in the HardCopy package of Open Inventor .NET.
-
The SolidViz, ScaleViz/MultiPipe, TerrainViz, and FXViz extensions of Open
Inventor C++ from Mercury are not currently available with Open Inventor .NET.
- IvTune is not available.
C++ Features not Available in Open Inventor
.NET
The following is not possible with Open Inventor .NET:
- Creating new nodes without writing native C++ code.
- Calling OpenGL directly from a .NET application.
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
- The C++ methods SoBase::ref(), SoBase::unref(), and SoBase::unrefNoDelete() are not needed because reference counting is a feature of the .NET language.
- Class SoType is not needed because .NET Type is equivalent.
- Class SbString is not needed because .NET String is equivalent.
- Class SbBool is not needed because .NET bool is equivalent.
- The C++ methods SoDB::init(), SoInteraction::init(),
and SoNodeKit::init() are not needed because
these classes are automatically initialized when loading the first Open Inventor.NET class.
Likewise for SoHardCopy::init(), SoVolumeRendering::init(),
and PoMeshviz::init().