XdkWrl: Overview of organisation

Home | Hierarchy | Members | Alphabetical | Related Pages

# Overview of organisation

The library is organized in 5 modules

- the Field Types whose header files are in `xdkwrl/fieldtypes`
- the Base Types whose header files are in `xdkwrl`
- the Standard Node Types whose header files are in `xdkwrl/nodes`
- the Parser Classes whose header files are in `xdkwrl/parser`
- the Tools whose header files are in `xdkwrl/tools`

The field types represent all the possible types of value that are encountered in a VRML files. Some of them are direct equivalent to C++ type such as SFBool for example. Some other types are more complex such as SFVec3 and offer very basic functionnalities. There is no algebraic functions such as adding to SFVec3 for example. Remember than the goal of the library is just to allow you to access the info stored in the VRML file within your program.

The base types are the generic ones that you manipulate or from which other types are derived. The most important ones are the Node class that is detailed below in Section The Node class and the Scene class that is described below in Section The Scene class. You will also find in the category the class for the specific nodes ProtoDeclaration, ProtoInterface and Script. See the special pages for The Proto Classes and The Script Class.

The standard nodes are the classes for each of the standard nodes defined in the VRML standard. One of the nice thing of this classes is that they are generated automatically from the spec of the VRML standard. Therefore you (and I!) can be pretty confident that there are no mistakes in these classes. See page The Generator of standard nodes classes. for more info on this and how you can use it to extend the library.

The parser classes are the one used to "load" a VRML file. They are generated using ANTLR which allows to define simply and efficiently the gramamr directly from the VRML standard, which once again lets you be pretty confident in the robustness of the library. You will usually not use these classes directly but will use the wrl::Scene class API instead. However if you want to extend the library you can derive new classes from these classes without having to learn the details of ANTLR. The library itself uses this functionnality to offer two parsers, a slow and secure version and a fast version that should be equivalent but might still contains some bugs due to optimizations. See Section The Scene class for details on these two parsers implementations.

The tools classes contains a few classes that I think might be useful when using the library. There is for example a pretty printer of VRML2 scene graph, some class to follow a transform hierarchy in such a scene graph. There is also a copy of my argstream library for parsing the command line. These tools are also included so you can compile the examples.

## The Scene class

This is your main interface to parse a file. It is just a raw encapsulation of the parser. Here is the simplest example (it also uses a prettyprinter to display the file).

    #include <xdkwrl/scene.h>
    #include <xdkwrl/tools/prettyprinter.h>
    #include <stdexcept>

    using namespace std;

    int
    main(int argc,char** argv)
    {
      try
      {
        wrl::Scene scene;
        scene.load(argv[1],true);
        wrl::PrettyPrinter p(cout);
        p<<scene;
      }
      catch (runtime_error e)
      {
        cerr <<e.what()<<endl;
      }
    }

See the wrl::Scene class documentation for more details.

## The Node class

It is the core of the API for you, the class you will manipulate the most. It is the base class for all nodes. It offers some functionnalities that are implemented by derived types. The important concept is the one of field handle. It is implemented as a subclass wrl::Node::FieldHandle. See wrl::Node for details. One interesting feature of this library is that I embedded in the doxygen documentation (this documentation you are reading) the VRML2 documentation for each node.

The node class is also derived in another abstract class, the wrl::DeclaredNode. This class is the base class for the Proto and Script related classes. This nodes have indeed the particularity that the fields are not specified statically in the VRML standard but can be declared to be anything in the VRML file itself. The wrl::DeclaredNode encapsulates the mechanism to declare such fields and to retrieve them through field handles.

Generated on 5 Jan 2007 with version 1.5.1. |