Changed VRML parsers to use LINE_READER
This commit is contained in:
parent
cbfd05e799
commit
c952cb4902
|
@ -7,6 +7,7 @@ include_directories(
|
|||
add_definitions( -DDEBUG_VRML1=2 -DDEBUG_VRML2=2 )
|
||||
|
||||
add_library( s3d_plugin_vrml MODULE
|
||||
${CMAKE_SOURCE_DIR}/common/richio.cpp
|
||||
vrml.cpp
|
||||
wrlproc.cpp
|
||||
v2/vrml2_node.cpp
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <string>
|
||||
#include <wx/string.h>
|
||||
#include <wx/filename.h>
|
||||
#include "richio.h"
|
||||
#include "plugins/3d/3d_plugin.h"
|
||||
#include "plugins/3dapi/ifsg_all.h"
|
||||
#include "wrlproc.h"
|
||||
|
@ -179,11 +180,25 @@ SCENEGRAPH* Load( char const* aFileName )
|
|||
LOCALESWITCH switcher;
|
||||
SCENEGRAPH* scene = NULL;
|
||||
|
||||
// VRML file processor
|
||||
WRLPROC proc;
|
||||
FILE_LINE_READER* modelFile = NULL;
|
||||
|
||||
if( !proc.Open( std::string( fname.ToUTF8() ) ) )
|
||||
try
|
||||
{
|
||||
// set the max char limit to 8MB; if a VRML file contains
|
||||
// longer lines then perhaps it shouldn't be used
|
||||
modelFile = new FILE_LINE_READER( fname, 0, 8388608 );
|
||||
}
|
||||
catch( IO_ERROR &e )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cout << " * [INFO] load failed: input line too long\n";
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// VRML file processor
|
||||
WRLPROC proc( modelFile );
|
||||
|
||||
if( proc.GetVRMLType() == VRML_V1 )
|
||||
{
|
||||
|
@ -243,6 +258,9 @@ SCENEGRAPH* Load( char const* aFileName )
|
|||
delete bp;
|
||||
}
|
||||
|
||||
if( NULL != modelFile )
|
||||
delete modelFile;
|
||||
|
||||
// DEBUG: WRITE OUT VRML2 FILE TO CONFIRM STRUCTURE
|
||||
#if defined( DEBUG_VRML1 ) || defined( DEBUG_VRML2 )
|
||||
if( scene )
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,21 +34,22 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "richio.h"
|
||||
#include "wrltypes.h"
|
||||
|
||||
class WRLPROC
|
||||
{
|
||||
private:
|
||||
std::ifstream m_file;
|
||||
std::string m_filename; // name of the open file
|
||||
size_t m_filepos; // position in the file
|
||||
size_t m_fileline; // line being processed
|
||||
size_t m_linepos; // position within 'buf'
|
||||
LINE_READER* m_file;
|
||||
std::string m_buf; // string being parsed
|
||||
bool m_eof;
|
||||
unsigned int m_fileline;
|
||||
unsigned int m_bufpos;
|
||||
|
||||
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;
|
||||
|
||||
// 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
|
||||
|
@ -57,11 +58,9 @@ private:
|
|||
bool getRawLine( void );
|
||||
|
||||
public:
|
||||
WRLPROC();
|
||||
WRLPROC( LINE_READER* aLineReader );
|
||||
~WRLPROC();
|
||||
|
||||
bool Open( const std::string& aFileName );
|
||||
void Close();
|
||||
bool eof( void );
|
||||
|
||||
// return the VRML Version
|
||||
|
|
Loading…
Reference in New Issue