Information technology — Computer graphics, image processing and environmental data representation — Extensible 3D (X3D) language bindings —
Part 3:  C

6 Type definitions

--- X3D separator bar ---

cube 6.1 Introduction and topics

6.1.1 Introduction

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.

6.1.2 Topics

See Table 6.1 for the topics for this clause.

Table 6.1 — Topics in this clause

6.2 Data type definitions

6.2.1 SAIAction

The action type is dependent on the function 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 function names describing the action rather than strict primitive types.

Table 6.2 — SAIAction to C implementation mapping

Service Action Type C Implementation
dynamicRouteHandling AddRoute X3DExecutionContext.addRoute()
DeleteRoute X3DExecutionContext.deleteRoute()
updateControl BeginUpdate ExternalBrowser.beginUpdate()
EndUpdate ExternalBrowser.endUpdate()
shareWorld share ExternalBrowser.shareBrowser()
unshare ExternalBrowser.unshareBrowser()
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()
rootNodeHandling AddRootNode X3DScene.addRootNode()
RemoveRootNode X3DScene.removeRootNode()
changeViewpoint Next Browser.nextViewpoint()
Previous Browser.previousViewpoint()
First Browser.firstViewpoint()
Last Browser.lastViewpoint()

6.2.2 SAIBoolean

The data type is implemented as the primitive built-in bool type.

6.2.3 SAIBrowserApp

The data type is implemented as the interface X3DComponent data type. The capability to obtain a SAIBrowserRef is implemented in the getBrowser() function which returns an instance of the ExternalBrowser data type.

6.2.4 SAIBrowserName

The data type is implemented as a reference to a null terminated array of the primitive built-in type char.

6.2.5 SAIBrowserRef

The data type is implemented as a reference to an instance of the Browser data type.

6.2.6 SAIBrowserVersion

The data type is implemented as a reference to a null terminated array of the primitive built-in type char. The reference may take the value NULL.

6.2.7 SAIComponent

The data type is implemented as a constant reference to an instance of the ComponentInfo. This presents a read-only view of a component and its information.

6.2.8 SAIComponentDeclaration

The data type is implemented as a data type 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.

6.2.9 SAIEncoding

The data type is implemented as an enumeration. Create the list of values for the SAIEncoding enumeration type.

6.2.10 SAIExecutionContext

The data type is represented by the X3DExecutionContext.

6.2.11 SAIField

The field identifier is represented as an instance of the data type that is appropriate to the field type. For each specific X3D field type, there shall be a data type that represents the field type, and includes strong type checking for the values. An implementation is not required to return the same data type instance for every query, but shall ensure that equivalence checking is correct through the implementation of the equals() function.

6.2.12 SAIFieldAccess

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.

6.2.13 SAIFieldDeclaration

The data type is represented by the X3DFieldDefinition data type. This data type has a number of read-only properties defined. The definition of the properties available are described in 7.6.2 Field definition.

6.2.14 SAIFieldName

The name of the field is implemented as a char array type.

6.2.15 SAIFieldType

The field type may be represented in two alternative fashions.

The first alternative is provided through getType() function provided in the X3DField data type. 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 representations

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 18
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 data types themselves. Field data types 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.

6.2.16 SAIFieldValue

The field value is defined on a per data type 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 data types to C data types

X3D field type C 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* (see text below)
MFNode X3DNode** (see text below)
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][]

In C for SFNode the data type is a reference (or pointer) to the X3DNode data type. Similarly for MFNode the data type is an array of references (or pointers) to the X3DNode data type.

6.2.17 SAIFrameRate

The data type is implemented as the built-in numeric type float. A null value is defined as the value 0.0f.

6.2.18 SAILayerID

The data type is implemented as the built-in int type.

6.2.19 SAILoadState

The load state is implemented as an enumeration. The values for each state are defined in Table 6.5.

Table 6.5 — Load state type value definitions

State Java Constant 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.

6.2.20 SAIMatrix

The data type is implemented as the Matrix data type.

6.2.21 SAINavSpeed

The data type is implemented as the built-in numeric float type. A null value is defined as the value 0.0f.

6.2.22 SAINode

The node identifier is represented as an instance of the SFNode data type. 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;

6.2.23 SAINodeType

The node type is represented as a numeric constant value in the host object 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

6.2.24 SAIParameterList

The createBrowser and getBrowser services are not implemented by this language binding. Therefore, there is no requirement to define valid values for this abstract type.

6.2.25 SAIProfileDeclaration

The profile declaration is represented by the ProfileInfo data type. See 7.8.1 ProfileInfo for a detailed definition of this data type.

6.3.26 SAIPropertyList

The data type is implemented as an array of char types. Key/Value pairs are declared in a single char array 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"

6.2.27 SAIProtoDeclaration

The component declaration is represented by two separate data types for PROTO and EXTERNPROTO. For PROTO, the data type is X3DProtoDeclaration. For EXTERNPROTO, the data type is X3DExternProtoDeclaration.

6.2.28 SAIRequester

The requester is represented as an instance of one of two data types depending on what information is being requested.

The requester is an instance of the data type 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 data type representing the interface X3DEventListener when the service request is registerFieldInterest as specified in 6.7.7 registerFieldInterest of ISO/IEC 19775-2.

6.2.29 SAIRoute

Routes are represented by the data type 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 data type that allow direct modification of the route.

6.2.30 SAIScene

The scene is represented by the X3DScene data type. 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.

6.2.31 SAIStream

The stream is implemented as the Stream standard object type char array data type.

6.2.32 SAIString

The string is implemented as a char array data type.

6.2.33 SAIUnitDeclaration

The unit declaration is represented by the UnitInfo data type. This data type presents a read-only view of a unit declaration and its information.

6.2.34 null

Null is implemented as the standard type NULL.

6.3 Error types

6.3.1 SAIError

C implementations of the errors rely on derived oclasses functions based on the SAIError type.

All exceptions (errors) defined in this specification shall be derived from X3DException.

6.3.2 SAI_BROWSER_UNAVAILABLE

The error type is implemented as the exception data type.

6.3.3 SAI_CONNECTION_ERROR

The error type is implemented as the exception data type.

6.3.4 SAI_DISPOSED

The error type is implemented as five different exception classes error functions, depending on their context.

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.

6.3.5 SAI_IMPORTED_NODE

The error type is implemented as the exception data type InvalidImportException.

6.3.6 SAI_INSUFFICIENT_CAPABILITIES

The error type is implemented as the exception data type.

6.3.7 SAI_INVALID_ACCESS_TYPE

The error type is implemented as two separate exceptions based on the implementation of SAINode and the rules defined in Table 6.2.

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() function.

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() function.

6.3.8 SAI_INVALID_BROWSER

The error type is implemented as the exception data type InvalidBrowserException.

6.3.9 SAI_INVALID_DOCUMENT

The error type is implemented as the exception data type InvalidDocumentException.

6.3.10 SAI_INVALID_EXECUTION_CONTEXT

The error type is implemented as the exception data type InvalidExecutionContextException.

6.3.11 SAI_INVALID_FIELD

The error type is implemented as the exception data type InvalidFieldException. Note that there are two derived data types from this data type (InvalidWritableFieldException and InvalidReadableFieldException) that may be used at times where this error may be generated.

6.3.12 SAI_INVALID_NAME

The error type is expressed as different exceptions dependent on the situation. The X3DExecutionContext.getNamedNode(), X3DScene.getExportedNode() and X3DExecutionContext.getImportedNode() functions use the InvalidNodeException. When accessing fields of a node, the error is expressed as an InvalidFieldException.

6.3.13 SAI_INVALID_NODE

The error type is implemented as the exception data type InvalidNodeException.

6.3.14 SAI_INVALID_OPERATION_TIMING

The error type is implemented as the exception data type InvalidOperationTimingException.

6.3.15 SAI_INVALID_URL

The error type is implemented as the exception data type InvalidURLException.

6.3.16 SAI_INVALID_X3D

The error type is implemented as the exception data type InvalidX3DException.

6.3.17 SAI_NODE_IN_USE

The error type is implemented as the exception data type NodeInUseException.

6.3.18 SAI_NODE_NOT_AVAILABLE

The error type is implemented as the exception data type NodeUnavailableException.

6.3.19 SAI_NOT_SHARED

The error type is implemented as the exception data type BrowserNotSharedException.

6.3.20 SAI_NOT_SUPPORTED

The error type is implemented as the exception data type NotSupportedException.

6.3.21 SAI_URL_UNAVAILABLE

The error type is implemented as the exception data type URLUnavailableException.

6.4 Event types

6.4.1 Overview

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
SAI_BROWSER_URL_Error SAI_BROWSER_URL_Error 5

6.4.2 SAI_Browser_Connection_Error

TODO

6.4.3 SAI_Browser_Event

The SAI_Browser_Event is implemented as an enumeration. The values for each type are defined in Table 6.6.

6.4.4 SAI_Browser_Initialized

TODO

6.4.5 SAI_Browser_Shutdown

TODO

6.4.6 SAI_Browser_URL_Error

TODO

6.4.7 SAIFieldEvent

The event type is implemented as a set of parameters passed to the user defined callback function. The user function shall have parameters that are the pointer to the field, the timestamp of when the event happened and the user data that may have been registered with the field.

--- X3D separator bar ---