2.5. LEARNING OPENINVENTOR/COIN3D 15
2.5.2 Important classes in OpenInventor/Coin3D
SoPath, SoNode, SoEngine
are three main categories of Object in Coin3D. Classes are organised into modules, see http:
//developer90.openinventor.com/APIS/RefManCpp/main.html
Description from this online documentation is extracted for key classes. See the brief description for classes: http://coin3d.
bitbucket.org/Coin/annotated.html;
** Basic objects **
•
SbXXX: Basic types like SbVec3f, SbMatrix, SbColor, SbString, SbTime; Containers like SbDict, SbList; geometrical
representation of basic shape like SbSphere; SbTypeInfo
• SoBase: ancester for most Coin3D ojbects, similar with QObject, FreeCAD’s Base::BaseClass
Top-level superclass for a number of class-hierarchies. SoBase provides the basic interfaces and methods for doing
reference counting, type identification and import/export. All classes in Coin3D which uses these mechanisms are
descendent from this class
ref() unref() getName()
virtual SoType getTypeId (void) const =0
notify (SoNotList *nl) //observer pattern, notify Auditor
addAuditor (void *const auditor, const SoNotRec::Type type)
Qobject is the base object for all derived Qt objects, offering event, containner, property, type support.
Example of inheritance chains:
Coin3D:
SoBase->SoFieldContainer->SoNode->SoGroup->SoShape
FreeCAD:
BaseClass->App::PropertyContainer->App::DocumentObject->Part::Feature
•
SoType: Inventor provides runtime type-checking through the
SoType
class.
node->getTypeId().getName();
like
Base::TypeClass in FreeCAD
Basis for the run-time type system in Coin3D. Many of the classes in the Coin3D library must have their type
information registered before any instances are created (including, but not limited to: engines, nodes, fields, actions,
nodekits and manipulators). The use of
SoType
to store this information provides lots of various functionality for
working with class hierarchies, comparing class types, instantiating objects from classnames, etc etc
• SoField: Top-level abstract base class for fields serializable, similar with App::Property in FreeCAD
Fields is the mechanism used throughout Coin for encapsulating basic data types to detect changes made to
them, and to provide conversion, import and export facilities. SoSFXXX: Single Field with Base type wrapped
(App::Property); SoMFXXX: Multiple Field (array of field). E.g. SoSFBool class is a container for an SbBool
value.
• SoFieldContainer: serializaton(App::PropertyContainer in FreeCAD) function is built into SoNode
• SoBaseList Container for pointers to SoBase derived objects.
The additional capability of the SoBaseList class over its parent class, SbPList, is to automatically handle
referencing and dereferencing of items as they are added or removed from the lists
** Scene organisation **
•
SoDB: This class collects various methods for initializing, setting and accessing common global data from the Coin
library
Similar with
App::Document
in FreeCAD import and export into file. Directed Acyclic Graph is used for better
performance, SoNodes are organised into database, serialization into text file *.iv .
“The foundation concept in Open Inventor is the”scene database" which defines the objects to be used in an
application. When using Open Inventor, a programmer creates, edits, and composes these objects into hierarchical
3D scene graphs (i.e., database). " Quoted from Open Inventor reference.
• SoNode: similar with App::DocumentObject in FreeCAD, has flags like ignore, override
Base class for nodes used in scene graphs. Coin is a retained mode 3D visualization library (built on top of the
immediate mode OpenGL library). “Retained mode” means that instead of passing commands to draw graphics
primitives directly to the renderer, you build up data structures which are rendered by the library on demand
• SoGroup: similar with App::DocumentObjectGroup in FreeCAD