Inventor provides runtime type-checking through the SoType class. Use the getTypeId() method on an instance to obtain the SoType for that instance. Runtime type-checking is available for most Inventor classes, including nodes, engines, actions, details, and events.
The SoType class has methods that enable you to find the parent class of a type (getParent()), to create an instance of a particular type (createInstance()), and to obtain an SbName for the class type (getName()). For example, the following code returns a name, such as
Material or Group, which you could then use to print some information about the node:
C++ :
The following two statements both return the SoType for an SoMaterial node (the first is more efficient):
C++ :
To determine whether an instance is of a particular type, use the == operator, as follows:
C++ :
To determine whether an instance is of the same type or derived from a particular class, use the isOfType() method or the SoType::derivedFrom() method (the two methods have the same effects):
C++ :
Also see the description in Applying Actions of the SoSearchAction, which allows you to search the scene graph for nodes of a particular type, or derived from a type.