Information technology — Computer graphics, image processing and
environmental data representation —
Extensible 3D (X3D) language bindings —
Part 3: 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
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() |
The data type is implemented as the primitive built-in bool
type.
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.
The data type is implemented as a reference to an instance of the Browser data type.
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.
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
.
The data type is implemented as an enumeration. Create the list of values for the SAIEncoding enumeration type.
The data type is represented by the X3DExecutionContext.
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.
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
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.
The name of the field is implemented as a char array type.
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.
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.
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.
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.
The data type is implemented as the Matrix data type.
The data type is implemented as the built-in numeric float
type.
A null value is defined as the value 0.0f
.
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;
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
data type.
See 7.8.1 ProfileInfo for a
detailed definition of this data type.
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"
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
.
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.
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.
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.
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.
Null is implemented as the standard type NULL
.
All exceptions (errors) defined in this specification shall be derived from X3DException
.
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.
InvalidImportException.
.
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.
InvalidBrowserException
.
InvalidDocumentException.
InvalidExecutionContextException.
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.
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
.
URLUnavailableException
.
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 |