home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / audio / drive / so.c++ < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.7 KB  |  68 lines

  1. /*
  2.  * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. //
  18. // so.c++ - read in an inventor file and return the root node
  19. //
  20.  
  21. #include <gl/gl.h>
  22. #include <Inventor/So.h>
  23.  
  24. ////////////////////////////////////////////////////////////////////////
  25. //
  26. // Description:
  27. //    Read the passed datafile and return the root node.
  28. //
  29.  
  30. SoGroup *
  31. readSceneGraph(const char *filename)
  32. {
  33.     SoInput        in;
  34.     SoNode        *node;
  35.     SoGroup        *root = NULL;
  36.     SbBool        ok;
  37.  
  38.     if (in.openFile(filename))
  39.     {
  40.         root = new SoGroup;
  41.         root->ref();
  42.         
  43.         while ((ok = SoDB::read(&in, node)) != FALSE && node != NULL)
  44.             root->addChild(node);
  45.     
  46.         if (! ok)
  47.         {
  48.             fprintf(stderr, "Error reading Inventor datafile %s",filename);
  49.             exit(0);
  50.         }
  51.         
  52.         if ((root == NULL) || (root->getNumChildren() == 0))
  53.         {
  54.             fprintf(stderr, "No data read from Inventor datafile %s",filename);
  55.             exit(0);
  56.         }
  57.  
  58.         in.closeFile();
  59.         
  60.         return root;
  61.     }
  62.     else
  63.     {
  64.         fprintf(stderr, "Could not open Inventor datafile %s",filename);
  65.         exit(0);
  66.     }
  67. }
  68.