int
main(int, char **)
{
// Initialize Inventor
SoDB::init();
#ifdef WIN32
SoOutput conOut;
conOut.setFilePointer(__AllocConsole());
#endif
// Open and read input scene graph
SoInput sceneInput;
if (! sceneInput.openFile("../data/bird.iv"))
return 1;
SoSeparator *root = SoDB::readAll(&sceneInput);
if (root == NULL)
return 1;
root->ref();
//////////////////////////////////////////////////////////////
// CODE FOR The Inventor Mentor STARTS HERE
SoSearchAction mySearchAction;
// Look for first existing light derived from class SoLight
mySearchAction.setType(SoLight::getClassTypeId());
mySearchAction.setInterest(SoSearchAction::FIRST);
mySearchAction.apply(root);
if (mySearchAction.getPath() == NULL) { // No lights found
// Add a default directional light to the scene
SoDirectionalLight *myLight = new SoDirectionalLight;
root->insertChild(myLight, 0);
}
// CODE FOR The Inventor Mentor ENDS HERE
//////////////////////////////////////////////////////////////
#ifdef WIN32
SoWriteAction myWriteAction(&conOut);
#else
SoWriteAction myWriteAction;
#endif
myWriteAction.apply(root);
// #ifdef WIN32
// conOut.flushFile();
// #endif
root->unref();
// The usual exit(0) has been replaced with exit(1) to enable the console
// window showing the output to stay on the screen until the user deletes it
exit(1);
return 0;
}