basic/geometry/vrml_reader/VrmlCoordinate3.cpp

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "VrmlCoordinate3.h"
00003 #include "VrmlStack.h"
00004 #include "Utility.h"
00005 
00006 //=============================================================================
00007 // constructor
00008 //
00009 // Description: constructor
00010 //=============================================================================
00011 VrmlCoordinate3::VrmlCoordinate3()
00012 {
00013 }
00014 
00015 //=============================================================================
00016 // copy constructor
00017 //
00018 // Description: copy constructor
00019 //=============================================================================
00020 VrmlCoordinate3::VrmlCoordinate3( const VrmlCoordinate3& right )
00021 {
00022         assert( false );
00023 }
00024 
00025 //=============================================================================
00026 // Destructor
00027 //
00028 // Description: Destructor
00029 //=============================================================================
00030 VrmlCoordinate3::~VrmlCoordinate3()
00031 {
00032         this->points.clear();
00033 }
00034 
00035 //=============================================================================
00036 // GetCoordinate
00037 //
00038 // Description: gets the XYZ coordinates for this index
00039 //=============================================================================
00040 const Vector4& VrmlCoordinate3::GetCoordinate( const int i ) const
00041 {
00042 #ifdef _DEBUG
00043         int size = points.size();
00044         assert( size > i );                             //this assertion fires if there aren't enough
00045                                                                         //vertexes in the list
00046 #endif
00047         assert( points[ i ].Magnitude() < 1000.0 );
00048         return this->points[ i ];
00049 }
00050 
00051 //=============================================================================
00052 // Parse
00053 //
00054 // Description: parses this node from a buffer
00055 //=============================================================================
00056 void VrmlCoordinate3::Parse( char*& buffer )
00057 {
00058         EatWhite( buffer );
00059         char pointIndicator[ 80 ] = "";
00060         sscanf( buffer, "%s", pointIndicator );
00061         assert( strcmp( pointIndicator, "point" ) == 0 );
00062         buffer += strlen( pointIndicator );
00063         EatWhite( buffer );
00064         assert( *buffer == '[' );
00065         buffer++;
00066         
00067         while( *buffer != ']' )
00068         {
00069                 float x;
00070                 float y;
00071                 float z;
00072                 sscanf( buffer, "%e%e%e", &x, &y, &z );
00073 
00074                 //add the xyz we just read in to the list
00075                 Vector4 vector( x, y, z );
00076                 assert( vector.Magnitude() < 1000.0 );
00077                 this->points.push_back( vector );
00078 
00079                 int size = points.size();
00080 
00081                 int position = strcspn( buffer, ",]" );
00082                 buffer += position;
00083                 if( *buffer == ',' )
00084                 {
00085                         buffer++;
00086                 }
00087                 EatWhite( buffer );             
00088         }
00089         buffer++;
00090         EatWhite( buffer );
00091         buffer++;
00092 }
00093 
00094 //=============================================================================
00095 // Render
00096 //
00097 // Description: renders this VrmlObject via the VRML renderer
00098 //=============================================================================
00099 void VrmlCoordinate3::Render( VrmlStack& stack ) const
00100 {
00101         int size = points.size();
00102         stack.vrmlCoordinate3 = this;
00103 }

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