Relax VRML1 specifications conformance to support more non-conformant models
This commit is contained in:
parent
ece1291d93
commit
b1d35965f5
|
@ -143,81 +143,83 @@ bool WRL1BASE::Read( WRLPROC& proc )
|
|||
std::string glob;
|
||||
WRL1NODES ntype;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
while( proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
if( !proc.eof() )
|
||||
|
||||
// Process node name: only Separator, Switch and DEF are acceptable;
|
||||
// WWWAnchor and LOD will not be supported
|
||||
if( !glob.compare( "DEF" ) )
|
||||
{
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << proc.GetError() << "\n";
|
||||
}
|
||||
#endif
|
||||
// read the name and discard it; we must not add it to the dictionary
|
||||
// because that invites the possibility of a circular reference
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process node name: only Separator, Switch and DEF are acceptable;
|
||||
// WWWAnchor and LOD will not be supported
|
||||
if( !glob.compare( "DEF" ) )
|
||||
{
|
||||
// read the name and discard it; we must not add it to the dictionary
|
||||
// because that invites the possibility of a circular reference
|
||||
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
if( !proc.ReadName( glob ) )
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << proc.GetError() << "\n";
|
||||
#endif
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << proc.GetError() << "\n";
|
||||
#endif
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ntype = getNodeTypeID( glob );
|
||||
size_t line = 0;
|
||||
size_t column = 0;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
std::cerr << " * [INFO] Processing node '" << glob << "' ID: " << ntype << "\n";
|
||||
#endif
|
||||
|
||||
if( ntype != WRL1_SEPARATOR && ntype != WRL1_SWITCH && ntype != WRL1_GROUP )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * [INFO] bad file - top node is not a Separator, Switch, or Group\n";
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
switch( ntype )
|
||||
{
|
||||
case WRL1_SEPARATOR:
|
||||
|
||||
if( !readSeparator( proc, this, NULL ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case WRL1_GROUP:
|
||||
|
||||
if( !readGroup( proc, this, NULL ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if( !readSwitch( proc, this, NULL ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ntype = getNodeTypeID( glob );
|
||||
size_t line = 0;
|
||||
size_t column = 0;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
std::cerr << " * [INFO] Processing node '" << glob << "' ID: " << ntype << "\n";
|
||||
#endif
|
||||
|
||||
if( ntype != WRL1_SEPARATOR && ntype != WRL1_SWITCH && ntype != WRL1_GROUP )
|
||||
if( !proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * [INFO] bad file - top node is not a Separator, Switch, or Group\n";
|
||||
std::cerr << proc.GetError() << "\n";
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
switch( ntype )
|
||||
{
|
||||
case WRL1_SEPARATOR:
|
||||
|
||||
if( !readSeparator( proc, this, NULL ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case WRL1_GROUP:
|
||||
|
||||
if( !readGroup( proc, this, NULL ) )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if( !readSwitch( proc, this, NULL ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -723,15 +725,32 @@ SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ )
|
|||
if( m_Items.empty() )
|
||||
return NULL;
|
||||
|
||||
if( m_Items.size() != 1 )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
std::cerr << " * [INFO] Bad VRML file, >1 top level transform (";
|
||||
std::cerr << m_Items.size() << ")\n";
|
||||
#endif
|
||||
if( m_Items.size() == 1 )
|
||||
return (*m_Items.begin())->TranslateToSG( NULL, NULL );
|
||||
|
||||
m_current.Init();
|
||||
|
||||
IFSG_TRANSFORM txNode( true );
|
||||
bool hasContent = false;
|
||||
|
||||
std::list< WRL1NODE* >::iterator sI = m_Items.begin();
|
||||
std::list< WRL1NODE* >::iterator eI = m_Items.end();
|
||||
|
||||
SGNODE* node = txNode.GetRawPtr();
|
||||
|
||||
while( sI != eI )
|
||||
{
|
||||
if( NULL != (*sI)->TranslateToSG( node, &m_current ) )
|
||||
hasContent = true;
|
||||
|
||||
++sI;
|
||||
}
|
||||
|
||||
if( !hasContent )
|
||||
{
|
||||
txNode.Destroy();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (*m_Items.begin())->TranslateToSG( NULL, NULL );
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( NULL == sp )
|
||||
{
|
||||
m_current.Init();
|
||||
sp = &m_current;
|
||||
|
|
Loading…
Reference in New Issue