Removed incorrect special treatment of commas within VRML files
This commit is contained in:
parent
2dfd8064d4
commit
18bb852030
|
@ -45,7 +45,7 @@
|
|||
|
||||
#define PLUGIN_VRML_MAJOR 1
|
||||
#define PLUGIN_VRML_MINOR 3
|
||||
#define PLUGIN_VRML_PATCH 1
|
||||
#define PLUGIN_VRML_PATCH 2
|
||||
#define PLUGIN_VRML_REVNO 0
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/log.h>
|
||||
#include "wrlproc.h"
|
||||
|
@ -60,7 +61,15 @@ WRLPROC::WRLPROC( LINE_READER* aLineReader )
|
|||
|
||||
m_error.clear();
|
||||
m_file = aLineReader;
|
||||
m_filename = m_file->GetSource().ToUTF8();
|
||||
|
||||
wxString tname = m_file->GetSource();
|
||||
m_filename = tname.ToUTF8();
|
||||
wxFileName fn( tname );
|
||||
|
||||
if( fn.IsRelative() )
|
||||
fn.Normalize();
|
||||
|
||||
m_filedir = fn.GetPathWithSep().ToUTF8();
|
||||
|
||||
m_buf.clear();
|
||||
GETLINE;
|
||||
|
@ -218,7 +227,16 @@ WRLVERSION WRLPROC::GetVRMLType( void )
|
|||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadGlob( std::string& aGlob, bool* hasComma )
|
||||
const char* WRLPROC::GetParentDir( void )
|
||||
{
|
||||
if( m_filedir.empty() )
|
||||
return NULL;
|
||||
|
||||
return m_filedir.c_str();
|
||||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadGlob( std::string& aGlob )
|
||||
{
|
||||
aGlob.clear();
|
||||
|
||||
|
@ -228,9 +246,6 @@ bool WRLPROC::ReadGlob( std::string& aGlob, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
|
@ -250,11 +265,7 @@ bool WRLPROC::ReadGlob( std::string& aGlob, bool* hasComma )
|
|||
if( ',' == m_buf[m_bufpos] )
|
||||
{
|
||||
// the comma is a special instance of blank space
|
||||
if( NULL != hasComma )
|
||||
*hasComma = true;
|
||||
|
||||
++m_bufpos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -745,7 +756,7 @@ bool WRLPROC::ReadSFBool( bool& aSFBool )
|
|||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadSFColor( WRLVEC3F& aSFColor, bool* hasComma )
|
||||
bool WRLPROC::ReadSFColor( WRLVEC3F& aSFColor )
|
||||
{
|
||||
if( !m_file )
|
||||
{
|
||||
|
@ -756,12 +767,7 @@ bool WRLPROC::ReadSFColor( WRLVEC3F& aSFColor, bool* hasComma )
|
|||
size_t fileline = m_fileline;
|
||||
size_t linepos = m_bufpos;
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
bool lComma = false;
|
||||
|
||||
if( !ReadSFVec3f( aSFColor, &lComma ) )
|
||||
if( !ReadSFVec3f( aSFColor ) )
|
||||
return false;
|
||||
|
||||
if( aSFColor.x < 0.0 || aSFColor.x > 1.0 || aSFColor.y < 0.0 || aSFColor.y > 1.0
|
||||
|
@ -778,14 +784,11 @@ bool WRLPROC::ReadSFColor( WRLVEC3F& aSFColor, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = lComma;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadSFFloat( float& aSFFloat, bool* hasComma )
|
||||
bool WRLPROC::ReadSFFloat( float& aSFFloat )
|
||||
{
|
||||
if( !m_file )
|
||||
{
|
||||
|
@ -793,9 +796,6 @@ bool WRLPROC::ReadSFFloat( float& aSFFloat, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
aSFFloat = 0.0;
|
||||
|
||||
size_t fileline = m_fileline;
|
||||
|
@ -813,10 +813,9 @@ bool WRLPROC::ReadSFFloat( float& aSFFloat, bool* hasComma )
|
|||
break;
|
||||
}
|
||||
|
||||
bool lComma = false;
|
||||
std::string tmp;
|
||||
|
||||
if( !ReadGlob( tmp, &lComma ) )
|
||||
if( !ReadGlob( tmp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -849,14 +848,11 @@ bool WRLPROC::ReadSFFloat( float& aSFFloat, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = lComma;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadSFInt( int& aSFInt32, bool* hasComma )
|
||||
bool WRLPROC::ReadSFInt( int& aSFInt32 )
|
||||
{
|
||||
if( !m_file )
|
||||
{
|
||||
|
@ -864,11 +860,7 @@ bool WRLPROC::ReadSFInt( int& aSFInt32, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
aSFInt32 = 0;
|
||||
|
||||
size_t fileline = m_fileline;
|
||||
size_t linepos = m_bufpos;
|
||||
|
||||
|
@ -884,10 +876,9 @@ bool WRLPROC::ReadSFInt( int& aSFInt32, bool* hasComma )
|
|||
break;
|
||||
}
|
||||
|
||||
bool lComma = false;
|
||||
std::string tmp;
|
||||
|
||||
if( !ReadGlob( tmp, &lComma ) )
|
||||
if( !ReadGlob( tmp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -930,14 +921,11 @@ bool WRLPROC::ReadSFInt( int& aSFInt32, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = lComma;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadSFRotation( WRLROTATION& aSFRotation, bool* hasComma )
|
||||
bool WRLPROC::ReadSFRotation( WRLROTATION& aSFRotation )
|
||||
{
|
||||
if( !m_file )
|
||||
{
|
||||
|
@ -945,9 +933,6 @@ bool WRLPROC::ReadSFRotation( WRLROTATION& aSFRotation, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
aSFRotation.x = 0.0;
|
||||
aSFRotation.y = 0.0;
|
||||
aSFRotation.z = 1.0;
|
||||
|
@ -968,14 +953,12 @@ bool WRLPROC::ReadSFRotation( WRLROTATION& aSFRotation, bool* hasComma )
|
|||
break;
|
||||
}
|
||||
|
||||
bool lComma = false;
|
||||
std::string tmp;
|
||||
|
||||
float trot[4];
|
||||
|
||||
for( int i = 0; i < 4; ++i )
|
||||
{
|
||||
if( !ReadGlob( tmp, &lComma ) )
|
||||
if( !ReadGlob( tmp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -988,19 +971,6 @@ bool WRLPROC::ReadSFRotation( WRLROTATION& aSFRotation, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( lComma && i != 3 )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in space delimited quartet";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::istringstream istr;
|
||||
istr.str( tmp );
|
||||
|
||||
|
@ -1028,14 +998,11 @@ bool WRLPROC::ReadSFRotation( WRLROTATION& aSFRotation, bool* hasComma )
|
|||
aSFRotation.z = trot[2];
|
||||
aSFRotation.w = trot[3];
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = lComma;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadSFVec2f( WRLVEC2F& aSFVec2f, bool* hasComma )
|
||||
bool WRLPROC::ReadSFVec2f( WRLVEC2F& aSFVec2f )
|
||||
{
|
||||
if( !m_file )
|
||||
{
|
||||
|
@ -1043,9 +1010,6 @@ bool WRLPROC::ReadSFVec2f( WRLVEC2F& aSFVec2f, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
aSFVec2f.x = 0.0;
|
||||
aSFVec2f.y = 0.0;
|
||||
|
||||
|
@ -1064,14 +1028,13 @@ bool WRLPROC::ReadSFVec2f( WRLVEC2F& aSFVec2f, bool* hasComma )
|
|||
break;
|
||||
}
|
||||
|
||||
bool lComma = false;
|
||||
std::string tmp;
|
||||
|
||||
float tcol[2];
|
||||
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
if( !ReadGlob( tmp, &lComma ) )
|
||||
if( !ReadGlob( tmp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1084,19 +1047,6 @@ bool WRLPROC::ReadSFVec2f( WRLVEC2F& aSFVec2f, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( lComma && i != 1 )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in space delimited pair";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::istringstream istr;
|
||||
istr.str( tmp );
|
||||
|
||||
|
@ -1122,14 +1072,11 @@ bool WRLPROC::ReadSFVec2f( WRLVEC2F& aSFVec2f, bool* hasComma )
|
|||
aSFVec2f.x = tcol[0];
|
||||
aSFVec2f.y = tcol[1];
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = lComma;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WRLPROC::ReadSFVec3f( WRLVEC3F& aSFVec3f, bool* hasComma )
|
||||
bool WRLPROC::ReadSFVec3f( WRLVEC3F& aSFVec3f )
|
||||
{
|
||||
if( !m_file )
|
||||
{
|
||||
|
@ -1137,9 +1084,6 @@ bool WRLPROC::ReadSFVec3f( WRLVEC3F& aSFVec3f, bool* hasComma )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = false;
|
||||
|
||||
aSFVec3f.x = 0.0;
|
||||
aSFVec3f.y = 0.0;
|
||||
aSFVec3f.z = 0.0;
|
||||
|
@ -1159,14 +1103,13 @@ bool WRLPROC::ReadSFVec3f( WRLVEC3F& aSFVec3f, bool* hasComma )
|
|||
break;
|
||||
}
|
||||
|
||||
bool lComma = false;
|
||||
std::string tmp;
|
||||
|
||||
float tcol[3];
|
||||
|
||||
for( int i = 0; i < 3; ++i )
|
||||
{
|
||||
if( !ReadGlob( tmp, &lComma ) )
|
||||
if( !ReadGlob( tmp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1180,15 +1123,11 @@ bool WRLPROC::ReadSFVec3f( WRLVEC3F& aSFVec3f, bool* hasComma )
|
|||
}
|
||||
|
||||
// ignore any commas
|
||||
if( !lComma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( Peek() == ',' )
|
||||
Pop();
|
||||
|
||||
}
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
std::istringstream istr;
|
||||
istr.str( tmp );
|
||||
|
@ -1216,9 +1155,6 @@ bool WRLPROC::ReadSFVec3f( WRLVEC3F& aSFVec3f, bool* hasComma )
|
|||
aSFVec3f.y = tcol[1];
|
||||
aSFVec3f.z = tcol[2];
|
||||
|
||||
if( NULL != hasComma )
|
||||
*hasComma = lComma;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1278,17 +1214,7 @@ bool WRLPROC::ReadMFString( std::vector< std::string >& aMFString )
|
|||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
Pop();
|
||||
|
||||
aMFString.push_back( lstr );
|
||||
return true;
|
||||
|
@ -1325,7 +1251,7 @@ bool WRLPROC::ReadMFString( std::vector< std::string >& aMFString )
|
|||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
++m_bufpos;
|
||||
Pop();
|
||||
|
||||
aMFString.push_back( lstr );
|
||||
|
||||
|
@ -1365,7 +1291,6 @@ bool WRLPROC::ReadMFColor( std::vector< WRLVEC3F >& aMFColor )
|
|||
}
|
||||
|
||||
WRLVEC3F lcolor;
|
||||
bool lcomma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
@ -1381,7 +1306,7 @@ bool WRLPROC::ReadMFColor( std::vector< WRLVEC3F >& aMFColor )
|
|||
|
||||
if( m_buf[m_bufpos] != '[' )
|
||||
{
|
||||
if( !ReadSFColor( lcolor, &lcomma ) )
|
||||
if( !ReadSFColor( lcolor ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1394,38 +1319,22 @@ bool WRLPROC::ReadMFColor( std::vector< WRLVEC3F >& aMFColor )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( lcomma )
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
aMFColor.push_back( lcolor );
|
||||
return true;
|
||||
}
|
||||
|
@ -1440,7 +1349,7 @@ bool WRLPROC::ReadMFColor( std::vector< WRLVEC3F >& aMFColor )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFColor( lcolor, &lcomma ) )
|
||||
if( !ReadSFColor( lcolor ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1455,28 +1364,6 @@ bool WRLPROC::ReadMFColor( std::vector< WRLVEC3F >& aMFColor )
|
|||
|
||||
aMFColor.push_back( lcolor );
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -1493,6 +1380,9 @@ bool WRLPROC::ReadMFColor( std::vector< WRLVEC3F >& aMFColor )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
@ -1513,7 +1403,6 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat )
|
|||
}
|
||||
|
||||
float temp;
|
||||
bool lcomma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
@ -1529,7 +1418,7 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat )
|
|||
|
||||
if( m_buf[m_bufpos] != '[' )
|
||||
{
|
||||
if( !ReadSFFloat( temp, &lcomma ) )
|
||||
if( !ReadSFFloat( temp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1542,38 +1431,22 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( lcomma )
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
aMFFloat.push_back( temp );
|
||||
return true;
|
||||
}
|
||||
|
@ -1588,7 +1461,7 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFFloat( temp, &lcomma ) )
|
||||
if( !ReadSFFloat( temp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1603,18 +1476,6 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat )
|
|||
|
||||
aMFFloat.push_back( temp );
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -1631,6 +1492,9 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
@ -1651,7 +1515,6 @@ bool WRLPROC::ReadMFInt( std::vector< int >& aMFInt32 )
|
|||
}
|
||||
|
||||
int temp;
|
||||
bool lcomma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
@ -1667,7 +1530,7 @@ bool WRLPROC::ReadMFInt( std::vector< int >& aMFInt32 )
|
|||
|
||||
if( m_buf[m_bufpos] != '[' )
|
||||
{
|
||||
if( !ReadSFInt( temp, &lcomma ) )
|
||||
if( !ReadSFInt( temp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1680,38 +1543,22 @@ bool WRLPROC::ReadMFInt( std::vector< int >& aMFInt32 )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( lcomma )
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
aMFInt32.push_back( temp );
|
||||
return true;
|
||||
}
|
||||
|
@ -1726,7 +1573,7 @@ bool WRLPROC::ReadMFInt( std::vector< int >& aMFInt32 )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFInt( temp, &lcomma ) )
|
||||
if( !ReadSFInt( temp ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1741,21 +1588,6 @@ bool WRLPROC::ReadMFInt( std::vector< int >& aMFInt32 )
|
|||
|
||||
aMFInt32.push_back( temp );
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
{
|
||||
lcomma = true;
|
||||
Pop();
|
||||
}
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -1772,6 +1604,9 @@ bool WRLPROC::ReadMFInt( std::vector< int >& aMFInt32 )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
@ -1792,7 +1627,6 @@ bool WRLPROC::ReadMFRotation( std::vector< WRLROTATION >& aMFRotation )
|
|||
}
|
||||
|
||||
WRLROTATION lrot;
|
||||
bool lcomma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
@ -1808,7 +1642,7 @@ bool WRLPROC::ReadMFRotation( std::vector< WRLROTATION >& aMFRotation )
|
|||
|
||||
if( m_buf[m_bufpos] != '[' )
|
||||
{
|
||||
if( !ReadSFRotation( lrot, &lcomma ) )
|
||||
if( !ReadSFRotation( lrot ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1821,38 +1655,22 @@ bool WRLPROC::ReadMFRotation( std::vector< WRLROTATION >& aMFRotation )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( lcomma )
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
aMFRotation.push_back( lrot );
|
||||
return true;
|
||||
}
|
||||
|
@ -1867,7 +1685,7 @@ bool WRLPROC::ReadMFRotation( std::vector< WRLROTATION >& aMFRotation )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFRotation( lrot, &lcomma ) )
|
||||
if( !ReadSFRotation( lrot ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1882,18 +1700,6 @@ bool WRLPROC::ReadMFRotation( std::vector< WRLROTATION >& aMFRotation )
|
|||
|
||||
aMFRotation.push_back( lrot );
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -1910,6 +1716,9 @@ bool WRLPROC::ReadMFRotation( std::vector< WRLROTATION >& aMFRotation )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
@ -1930,7 +1739,6 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f )
|
|||
}
|
||||
|
||||
WRLVEC2F lvec2f;
|
||||
bool lcomma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
@ -1946,7 +1754,7 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f )
|
|||
|
||||
if( m_buf[m_bufpos] != '[' )
|
||||
{
|
||||
if( !ReadSFVec2f( lvec2f, &lcomma ) )
|
||||
if( !ReadSFVec2f( lvec2f ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -1959,38 +1767,22 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( lcomma )
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
aMFVec2f.push_back( lvec2f );
|
||||
return true;
|
||||
}
|
||||
|
@ -2005,7 +1797,7 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFVec2f( lvec2f, &lcomma ) )
|
||||
if( !ReadSFVec2f( lvec2f ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -2020,18 +1812,6 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f )
|
|||
|
||||
aMFVec2f.push_back( lvec2f );
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -2048,6 +1828,9 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f )
|
|||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
@ -2068,7 +1851,6 @@ bool WRLPROC::ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f )
|
|||
}
|
||||
|
||||
WRLVEC3F lvec3f;
|
||||
bool lcomma = false;
|
||||
|
||||
while( true )
|
||||
{
|
||||
|
@ -2084,7 +1866,7 @@ bool WRLPROC::ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f )
|
|||
|
||||
if( m_buf[m_bufpos] != '[' )
|
||||
{
|
||||
if( !ReadSFVec3f( lvec3f, &lcomma ) )
|
||||
if( !ReadSFVec3f( lvec3f ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
|
@ -2097,79 +1879,6 @@ bool WRLPROC::ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( lcomma )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] comma encountered in undelimited list";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
aMFVec3f.push_back( lvec3f );
|
||||
return true;
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFVec3f( lvec3f, &lcomma ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] " << m_error;
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
aMFVec3f.push_back( lvec3f );
|
||||
|
||||
if( !lcomma )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
lcomma = true;
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -2183,9 +1892,60 @@ bool WRLPROC::ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
aMFVec3f.push_back( lvec3f );
|
||||
return true;
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( !ReadSFVec3f( lvec3f ) )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] " << m_error;
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
aMFVec3f.push_back( lvec3f );
|
||||
|
||||
if( !EatSpace() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
|
||||
ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
|
||||
ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
|
||||
ostr << " * [INFO] could not check characters after the string";
|
||||
m_error = ostr.str();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !EatSpace() )
|
||||
return false;
|
||||
|
||||
if( ']' == m_buf[m_bufpos] )
|
||||
break;
|
||||
|
||||
if( ',' == m_buf[m_bufpos] )
|
||||
Pop();
|
||||
|
||||
}
|
||||
|
||||
++m_bufpos;
|
||||
|
|
|
@ -49,7 +49,8 @@ private:
|
|||
WRLVERSION m_fileVersion; // VRML file version
|
||||
std::string m_error; // error message
|
||||
std::string m_badchars; // characters forbidden in VRML{1|2} names
|
||||
std::string m_filename;
|
||||
std::string m_filename; // current file
|
||||
std::string m_filedir; // parent directory of the file
|
||||
|
||||
// getRawLine reads a single non-blank line and in the case of a VRML1 file
|
||||
// it checks for invalid characters (bit 8 set). If m_buf is not empty and
|
||||
|
@ -66,6 +67,8 @@ public:
|
|||
// return the VRML Version
|
||||
WRLVERSION GetVRMLType( void );
|
||||
|
||||
// return the parent directory of the current file
|
||||
const char* GetParentDir( void );
|
||||
|
||||
// helper routines
|
||||
std::string GetError( void );
|
||||
|
@ -81,7 +84,7 @@ public:
|
|||
void Pop( void );
|
||||
|
||||
// read up to the next whitespace or comma
|
||||
bool ReadGlob( std::string& aGlob, bool* hasComma = NULL );
|
||||
bool ReadGlob( std::string& aGlob );
|
||||
// read a VRML name; is similar to ReadGlob except that it enforces
|
||||
// name checking rules, does not allow a comma at the end, and
|
||||
// stops when a left brace or bracket is found.
|
||||
|
@ -92,12 +95,12 @@ public:
|
|||
// single variable readers
|
||||
bool ReadString( std::string& aSFString ); // read a VRML string
|
||||
bool ReadSFBool( bool& aSFBool );
|
||||
bool ReadSFColor( WRLVEC3F& aSFColor, bool* hasComma = NULL );
|
||||
bool ReadSFFloat( float& aSFFloat, bool* hasComma = NULL );
|
||||
bool ReadSFInt( int& aSFInt32, bool* hasComma = NULL );
|
||||
bool ReadSFRotation( WRLROTATION& aSFRotation, bool* hasComma = NULL );
|
||||
bool ReadSFVec2f( WRLVEC2F& aSFVec2f, bool* hasComma = NULL );
|
||||
bool ReadSFVec3f( WRLVEC3F& aSFVec3f, bool* hasComma = NULL );
|
||||
bool ReadSFColor( WRLVEC3F& aSFColor );
|
||||
bool ReadSFFloat( float& aSFFloat );
|
||||
bool ReadSFInt( int& aSFInt32 );
|
||||
bool ReadSFRotation( WRLROTATION& aSFRotation );
|
||||
bool ReadSFVec2f( WRLVEC2F& aSFVec2f );
|
||||
bool ReadSFVec3f( WRLVEC3F& aSFVec3f );
|
||||
|
||||
// array readers
|
||||
bool ReadMFString( std::vector< std::string >& aMFString );
|
||||
|
|
Loading…
Reference in New Issue