Information technology — Computer graphics, image processing and
environmental data representation —
Extensible 3D (X3D) language bindings —
Part 5: C#
6 Type definitions
The X3D Scene Authoring Interface defines a set of fundamental abstract data types. This clause gives the mapping from those data types to the data types defined in this binding. All implementation-dependent data types are defined after all implementation-independent data types in each category.
See Table 6.1 for the topics for this clause.
Table 6.1 — Topics in this clause
The action type is dependent on the method used. Table 6.2 defines the mapping between each service, the valid action types for that service and the C# implementations of that action. Actions are mapped as method names describing the action rather than strict primitive types.
Table 6.2 — SAIAction to C# implementation mapping
| Abstract SAI service | Action type | C# implementation |
|---|---|---|
| dynamicRouteHandling | AddRoute | X3DExecutionContext.addRoute() |
| DeleteRoute | X3DExecutionContext.deleteRoute() | |
| updateControl | BeginUpdate | ExternalBrowser.beginUpdate() |
| EndUpdate | ExternalBrowser.endUpdate() | |
| registerBrowserInterest | AddBrowserInterest | Browser.addBrowserListener() |
| RemoveBrowserInterest | Browser.removeBrowserListener() | |
| Change Viewpoint | Next | Browser.nextViewpoint() |
| Previous | Browser.previousViewpoint() | |
| First | Browser.firstViewpoint() | |
| Last | Browser.lastViewpoint() | |
| getNode | DEFNode | X3DExecutionContext.getNamedNode() |
| IMPORTNode | X3DExecutionContext.getImportNode() | |
| EXPORTNode | X3DScene.getExportNode() | |
| namedNodeHandling | AddDEFNode/UpdateDEFNode | X3DScene.updateNamedNode() |
| RemoveDEFNode | X3DScene.removeNamedNode() | |
| AddIMPORTNode/UpdateIMPORTNode | X3DScene.updateImportedNode() | |
| RemoveIMPORTNode | X3DScene.removeImportedNode() | |
| AddExportNode/UpdateEXPORTNode | X3DScene.updateExportedNode() | |
| RemoveEXPORTNode | X3DScene.removeExportedNode() | |
| protoDeclarationHandling | AddProto/UpdateProto | X3DScene.updateProtoNode() |
| RemoveProto | X3DScene.removeProtoNode() | |
| externprotoDeclarationHandling | AddExternProto/UpdateExternProto | X3DScene.updateExternProtoNode() |
| RemoveExternProto | X3DScene.removeExternProtoNode() | |
| dynamicRouteHandling | AddRoute | X3DExecutionContext.addRoute() |
| DeleteRoute | X3DExecutionContext.deleteRoute() | |
| rootNodeHandling | AddRootNode | X3DScene.addRouteNode() |
| RemoveRootNode | X3DScene.removeRouteNode() | |
| registerFieldInterest | AddInterest | X3DField.addFieldEventListener() |
| RemoveInterest | X3DField.removeFieldEventListener() |
The data type is implemented as the primitive built-in bool type.
The data type is implemented as the class X3DComponent.
The capability to obtain an SAIBrowserRef is implemented in the getBrowser() method which returns an instance of the ExternalBrowser class.
char.
The data type is implemented as a reference to an instance of the Browser class.
char. The reference may take the value NULL.
The data type is implemented as a constant reference to an instance
of the ComponentInfo class. This presents a read-only view of a
component and its information.
The data type is implemented as a structure with two members.
The first member represents the name of the component and is defined as a reference to
a null terminated array of the primitive built-in type char. The
second member represents the support level and is defined using the primitive built-in
type unsigned int.
The data type is represented by the X3DExecutionContext class.
The field identifier is represented as an instance of the class that is
appropriate to the field type. For each specific X3D field type, there shall
be a derived class that represents the field type, and includes strong type
checking for the values. An implementation is not required to return the
same class instance for every query, but shall ensure that equivalence
checking is correct through the implementation of the equals() function.
Field access is driven by the state of the field object. It shall have two
read-only boolean properties to determine if it is readable
(readable) and writable (writable). These
properties shall be true if the field is readable or writable
respectively at the current point in time. Note that for a given field the
value of the properties for a particular SAIField may change over time
dependent on the node's current state in the life cycle as specified in
4.4.3.5 Object life cycle of part 1 of
ISO/IEC 19775.
The data type is represented by the X3DFieldDefinition class.
This class has a number of read-only properties defined. The definition of
the properties available are described in 7.6.2 Field definition.
The field type may be represented in two alternative fashions.
The first alternative is provided through getType() function
provided in the X3DField class. This returns a numeric value which has one
of the values defined by the defined in Table 6.3.
Table 6.3 — Mapping of X3D field type to C# definitions
| X3D Field type | C# representation | Value |
|---|---|---|
| SFBool | static int SFBOOL | 1 |
| MFBool | static int MFBOOL | 2 |
| SFColor | static int SFCOLOR | 26 |
| MFColor | static int MFCOLOR | 25 |
| SFColorRGBA | static int SFCOLORRGBA | 28 |
| MFColorRGBA | static int MFCOLORRGBA | 27 |
| SFDouble | static int SFDOUBLE | 9 |
| MFDouble | static int MFDOUBLE | 10 |
| SFFloat | static int SFFLOAT | 7 |
| MFFloat | static int MFFLOAT | 8 |
| SFImage | static int SFIMAGE | 29 |
| MFImage | static int MFIMAGE | 30 |
| SFInt32 | static int SFINT32 | 4 |
| MFInt32 | static int MFINT32 | 3 |
| SFMatrix3d | static int SFMATRIX3D | 37 |
| MFMatrix3d | static int MFMATRIX3D | 38 |
| SFMatrix3f | static int SFMATRIX3F | 39 |
| MFMatrix3f | static int MFMATRIX3F | 40 |
| SFMatrix4d | static int SFMATRIX4D | 41 |
| MFMatrix4d | static int MFMATRIX4D | 42 |
| SFMatrix4f | static int SFMATRIX4F | 43 |
| MFMatrix4f | static int MFMATRIX4F | 44 |
| SFNode | static int SFNODE | 13 |
| MFNode | static int MFNODE | 14 |
| SFRotation | static int SFROTATION | 24 |
| MFRotation | static int MFROTATION | 23 |
| SFString | static int SFTRING | 31 |
| MFString | static int MFSTRING | 32 |
| SFTime | static int SFTIME | 11 |
| MFTime | static int MFTIME | 12 |
| SFVec2d | static int SFVEC2D | 17 |
| MFVec2d | static int MFVEC2D | 17 |
| SFVec2f | static int SFVEC2F | 15 |
| MFVec2f | static int MFVEC2F | 16 |
| SFVec3d | static int SFVEC3D | 21 |
| MFVec3d | static int MFVEC3D | 22 |
| SFVec3f | static int SFVEC3F | 19 |
| MFVec3f | static int MFVEC3F | 20 |
| SFVec4d | static int SFVEC4D | 35 |
| MFVec4d | static int MFVEC4D | 36 |
| SFVec4f | static int SFVEC4F | 33 |
| MFVec4f | static int MFVEC4F | 34 |
The second alternative is provided by the classes themselves. Field classes are derived to provide implementations of the exact field type. A list of all the objects for each field type and access type is provided in 7.5.4 Field Services.
The field value is defined on a per class and per field type instance. See the definitions of the individual field type objects for the exact definition of each type. As a general rule, the X3D data type maps the the equivalent C# primitive types using the mapping in Table 6.4.
Table 6.4 — Mapping of X3D field value types to C# data types
| X3D field type | C# data type |
|---|---|
| SFBool | bool |
| MFBool | bool[] |
| SFColor | float[3] |
| MFColor | float[3][] |
| SFColorRGBA | float[4] |
| MFColorRGBA | float[4][] |
| SFFloat | float |
| MFFloat | float[] |
| SFDouble | double |
| MFDouble | double[] |
| SFImage | struct Image {int; int; int; unsigned int [];} |
| MFImage | struct Image[] |
| SFInt32 | int |
| MFInt32 | int[] |
| SFMatrix3f | float[9] |
| MFMatrix3f | float[9][] |
| SFMatrix3d | double[9] |
| MFMatrix3d | double[9][] |
| SFMatrix4f | float[16] |
| MFMatrix4f | float[16][] |
| SFMatrix4d | double[16] |
| MFMatrix4d | double[16][] |
| SFNode | X3DNode |
| MFNode | X3DNode[] |
| SFRotation | float[4] |
| MFRotation | float[4][] |
| SFString | char[] or std::string |
| MFString | char[][] or std::string[] |
| SFTime | double |
| MFTime | double[] |
| SFVec2f | float[2] |
| MFVec2f | float[2][] |
| SFVec2d | double[2] |
| MFVec2d | double[2][] |
| SFVec3f | float[3] |
| MFVec3f | float[3][] |
| SFVec3d | double[3] |
| MFVec3d | double[3][] |
| SFVec4f | float[4] |
| MFVec4f | float[4][] |
| SFVec4d | double[4] |
| MFVec4d | double[4][] |
The data type is implemented as the built-in numeric type float.
A null value is defined as the value 0.0f.
The data type is implemented as the built-in int type.
Table 6.5 — Load state type value definitions
| State | C# enum | Value |
|---|---|---|
| NOT_STARTED | LOAD_NOT_STARTED | 1 |
| IN_PROGRESS | LOAD_IN_PROGRESS | 2 |
| COMPLETE | LOAD_COMPLETE | 3 |
| FAILED | LOAD_FAILED | 4 |
It is strongly recommended thar the end user does not use the integer values. They should be using the defined enumerations names.
The data type is implemented as the Matrix class.
The data type is implemented as the built-in numeric float type.
A null value is defined as the value 0.0f.
SFNode class. This object is used for the dual purpose of representing an individual
node as well as the single-value node field type. The identifier of a node field
may be accessed directly as a property of the parent node. In the following
example, the value of the appearance field of the Shape node is assigned a new
value.
myShape.appearance = someNewAppearanceNode;
X3DConstants. The host object contains a collection of read-only
numeric propeties named for each abstract node type defined in ISO/IEC 19775-1. The naming convention
shall be to use the exact naming specified in ISO/IEC 19775-1, maintaining
case.
EXAMPLE The following two constants define the X3DGroupingNode and X3DUrlObject abstract node types:
X3DConstants.X3DGroupingNode X3DConstants.X3DUrlObject
The profile declaration is represented by the ProfileInfo class.
See 7.8.1 ProfileInfo for a
detailed definition of this class.
String standard
object types. Key/Value pairs are declared in a single string in the
following format with the '=' character as the separator. Whitespace
surrounding the key and value are ignored although whitespace inside the
key and value are legal.
The following are considered valid values (as well as permutations of the given examples):
"key=value" "key = value" "key= value" "a key = some value" "a key =some value"
The component declaration is represented by two separate classes for PROTO
and EXTERNPROTO. For PROTO, the class is X3DProtoDeclaration.
For EXTERNPROTO, the class is X3DExternProtoDeclaration.
The requester is represented as an instance of one of two classes depending on what information is being requested.
The requester is an instance of the class representing the interface BrowserListener when the service request is registerBrowserInterest as specified in 6.3.20
registerBrowserInterest of ISO/IEC 19775-2.
The requester is an instance of the class representing the interface X3DEventListener when the service request is registerFieldInterest as specified in 6.7.7
registerFieldInterest of ISO/IEC 19775-2.
Routes are represented by the class X3DRoute. This allows
fetching of all the route information, but it may not be changed. Browsers
shall not expose to the end user extended versions of this class that allow
direct modification of the route.
The scene is represented by the class X3DScene. The scene interface holds all the functions that represent the Scene Services. A full definition of the interface and all its functions is in 7.4 Scene Services.
The unit declaration is represented by the UnitInfo class. This
class presents a read-only view of a unit declaration and its information.
Null is implemented as the standard type NULL.
The error types are implemented as the exception class X3DException.
All exceptions (errors) defined in this specification shall be derived from X3DException.
NoSuchBrowserException.
ConnectionException.
InvalidBrowserException is used to indicate
that an SAIBrowserRef has been disposed.
InvalidExecutionContextException is used to
indicate that an SAIExecutionContext has been disposed.
InvalidNodeException is used to indicate
that an SAINode has been disposed.
InvalidRouteException is used to indicate
that an SAIRoute has been disposed.
InvalidProtoException is used to indicate
that an SAIProtoDeclaration has been
disposed.
InvalidImportException.
InsufficientCapabilityException.
InvalidFieldException.
InvalidWritableFieldException is used to
indicate the named field is not accessible as a writable field when
attempting to create a route with the X3DExecutionContext.addRoute() method.
InvalidReadableFieldException is used to
indicate the named field is not accessible as a readable field when
attempting to create a route with the X3DExecutionContext.addRoute() method.
InvalidBrowserException.
InvalidDocumentException.
InvalidExecutionContextException.
InvalidFieldException. Note that there are two derived classes
from this class (InvalidWritableFieldException and InvalidReadableFieldException) that may be used at times where
this error may be generated.
X3DExecutionContext.getNamedNode(), X3DScene.getExportedNode() and X3DExecutionContext.getImportedNode() functions use the InvalidNodeException. When accessing fields of a node, the
error is expressed as an InvalidFieldException.
InvalidNodeException.
InvalidOperationTimingException.
InvalidURLException.
InvalidX3DException.
NodeInUseException.
NodeUnavailableException.
BrowserNotSharedException.
NotSupportedException.
Browser event types are distinguished by an enumeration. The values for each type are defined in Table 6.6.
Table 6.6 — Mapping of Abstract SAI event types to C# constants
| Type | C# constant | Value |
|---|---|---|
| SAI_BROWSER_Connection_Error | SAI_BROWSER_Connection_Error | 1 |
| SAI_BROWSER_Event | SAI_BROWSER_Event | 2 |
| SAI_BROWSER_Initialized | SAI_BROWSER_Initialized | 3 |
| SAI_BROWSER_Shutdown | SAI_BROWSER_Shutdown | 4 |
![]()