basic/geometry/vrml_reader/VrmlChildren.cpp

Go to the documentation of this file.
00001 #include "stddef.h"
00002 #include "utility.h"
00003 #include "VrmlChildren.h"
00004 #include "VrmlStack.h"
00005 #include <geometry/igs/igs_group.h>
00006 
00007 //=============================================================================
00008 // destructor
00009 //
00010 // Description: reads the vrml node out of a file
00011 //=============================================================================
00012 VrmlChildren::~VrmlChildren()
00013 {
00014         int i;
00015         int size = nodes.size();
00016         for( i = 0; i < size; i++ )
00017         {
00018                 VrmlNode* node = nodes[ i ];
00019                 node->Release();
00020         }
00021 }
00022 
00023 //=============================================================================
00024 // Parse
00025 //
00026 // Description: reads the vrml node out of a file
00027 //=============================================================================
00028 void VrmlChildren::Parse( char*& buffer )
00029 {
00030         EatWhite( buffer );
00031 
00032         while( buffer[ 0 ] != ']' )
00033         {
00034                 Keyword keyword = VrmlNode::GetKeyword( buffer );
00035 
00036                 //we must process define keywords differently
00037                 EatWhite( buffer );
00038                 if( keyword != VRML_Define )
00039                 {
00040                         buffer++;
00041                 }
00042 
00043                 //parse the node
00044                 VrmlNode* node = VrmlNode::ParseNode( keyword, buffer );
00045 
00046                 if( node != NULL )
00047                 {
00048                         node->AddRef();
00049                         nodes.push_back( node );
00050                 }
00051                 else
00052                 {
00053                         assert( node != NULL );
00054                 }
00055                 EatWhite( buffer );
00056 
00057                 //advance past a comma
00058                 while( buffer[ 0 ] == ',' )
00059                 {
00060                         buffer++;
00061                         EatWhite( buffer );
00062                 }
00063         }
00064 
00065         //advance past the ']'
00066         EatWhite( buffer );
00067         buffer++;
00068 }
00069 
00070 //=============================================================================
00071 // Render
00072 //
00073 // Description: renders the VrmlNode to the stack
00074 //=============================================================================
00075 void VrmlChildren::Render( VrmlStack& stack ) const
00076 {
00077         int i;
00078         int size = this->nodes.size();
00079         for( i = 0; i < size; i++ )
00080         {
00081                 VrmlNode* node = nodes[ i ];
00082                 assert( node != NULL );
00083                 node->Render( stack );
00084         }
00085 }
00086 
00087 //=============================================================================
00088 // RenderOpenGl
00089 //
00090 // Description: renders this VRML object to OpenGL
00091 //=============================================================================
00092 void VrmlChildren::RenderOpenGl( VrmlStack& stack ) const
00093 {
00094         int i;
00095         int size = this->nodes.size();
00096         for( i = 0; i < size; i++ )
00097         {
00098                 VrmlNode* node = nodes[ i ];
00099                 assert( node != NULL );
00100                 VrmlStack substack = stack;
00101                 node->RenderOpenGl( substack );
00102         }
00103 }
00104 
00105 //=============================================================================
00106 // RenderToIGS
00107 //
00108 // Description: renders this VRML object to the faster to process 
00109 //                              IanGraphicsSystem
00110 //=============================================================================
00111 IGS_Object* VrmlChildren::RenderToIGS( VrmlStack& stack ) const
00112 {
00113         IGS_Group* group = new IGS_Group;
00114 
00115         int i;
00116         int size = this->nodes.size();
00117         for( i = 0; i < size; i++ )
00118         {
00119                 VrmlNode* node = nodes[ i ];
00120                 assert( node != NULL );
00121                 VrmlStack substack = stack;
00122                 IGS_Object* object = node->RenderToIGS( substack );
00123                 if( object != NULL )
00124                 {
00125                         group->AddObject( object );
00126                 }
00127         }
00128         return group;
00129 }

Generated on Sat Apr 1 21:30:33 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO