6.6.2. Loading XML

After this XML file has been generated, the easy way to rebuild your scene is to import the information provided by the XML file using the loadFromXML(“fileName”) method. Your code can be as short as the following:

Example 6.5. A simple example using an XML description file

main(int argc, char **argv)
// Initialize Inventor. This returns a main window to use.
// If unsuccessful, exit.
Widget mainWindow = SoXt::init(argv[0]);    // pass the app name
  if (mainWindow == NULL) exit(1);

// Initialize TerrainViz

  SoXtExaminerViewer *mainViewer = new SoXtExaminerViewer(mainWindow);
  SoSeparator *mainRoot = new SoSeparator;


  SoTVizRender *dtmRender = new SoTVizRender();



  dtmRender->maxRenderedTriangles = 10000;

// Display main window
  mainViewer->show(); mainViewer->viewAll(); SoXt::show(mainWindow);
  SoXt::mainLoop();  // Main Inventor event loop 
return 0;