basic/geometry/vrml_reader/VrmlSeparator.cpp

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include <geometry/igs/IGS_Group.h>
00003 #include "utility.h"
00004 #include "VrmlSeparator.h"
00005 
00006 //=============================================================================
00007 // Destructor
00008 //
00009 // Description: deletes all the subnodes
00010 //=============================================================================
00011 VrmlSeparator::~VrmlSeparator()
00012 {
00013         int i;
00014         for( i = 0; i < this->nodes.size(); i++ )
00015         {
00016                 VrmlNode*& node = nodes[ i ];
00017                 delete node;
00018                 node = NULL;
00019         }
00020 }
00021 
00022 //=============================================================================
00023 // Parse
00024 //
00025 // Description: Parses this node from a buffer
00026 //=============================================================================
00027 void VrmlSeparator::Parse( char*& buffer )
00028 {
00029         EatWhite( buffer );
00030 
00031         while( *buffer != '}' )
00032         {
00033                 Keyword keyword = VrmlNode::GetKeyword( buffer );
00034                 EatWhite( buffer );
00035 
00036                 if( keyword != VRML_RenderCulling )
00037                 {
00038                         buffer++;
00039                 }
00040                 VrmlNode* node = VrmlNode::ParseNode( keyword, buffer );
00041                 if( node != NULL )
00042                 {
00043                         this->nodes.push_back( node );
00044                 }
00045                 else
00046                 {
00047                         assert( node != NULL );
00048                 }
00049                 EatWhite( buffer );
00050         }
00051 
00052         //advance past trailing '}'
00053         buffer++;
00054 }
00055 
00056 //=============================================================================
00057 // Render
00058 //
00059 // Description: Renders this node to the stack
00060 //=============================================================================
00061 void VrmlSeparator::Render( VrmlStack& stack ) const
00062 {
00063         //do nothing on purpose - does not need to be recursive
00064 }
00065 //=============================================================================
00066 // RenderOpenGl
00067 //
00068 // Description: Renders this node to the OpenGL context
00069 //=============================================================================
00070 void VrmlSeparator::RenderOpenGl( VrmlStack& stack ) const
00071 {
00072         int i;
00073         int size = this->nodes.size();
00074         for( i = 0; i < size; i++ )
00075         {
00076                 VrmlNode* node = this->nodes[ i ];
00077                 node->RenderOpenGl( stack );
00078         }
00079 }
00080 
00081 //=============================================================================
00082 // RenderToIGS
00083 //
00084 // Description: Renders this node using the stack to produce IGS objects
00085 //=============================================================================
00086 IGS_Object* VrmlSeparator::RenderToIGS( VrmlStack& stack ) const
00087 {
00088         IGS_Group* group = new IGS_Group;
00089 
00090         int i;
00091         int size = this->nodes.size();
00092         for( i = 0; i < size; i++ )
00093         {
00094                 VrmlNode* node = this->nodes[ i ];
00095                 IGS_Object* object = node->RenderToIGS( stack );
00096                 if( object != NULL )
00097                 {
00098                         group->AddObject( object );
00099                 }
00100                 else
00101                 {
00102                         //some VRML nodes don't produce valid IGS objects. They're "helper" nodes
00103                 }
00104         }
00105         return group;
00106 }

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