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;
|
std::string glob;
|
||||||
WRL1NODES ntype;
|
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";
|
// read the name and discard it; we must not add it to the dictionary
|
||||||
std::cerr << proc.GetError() << "\n";
|
// because that invites the possibility of a circular reference
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
for( int i = 0; i < 2; ++i )
|
||||||
}
|
|
||||||
|
|
||||||
// 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 ) )
|
|
||||||
{
|
{
|
||||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
if( !proc.ReadName( glob ) )
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
{
|
||||||
std::cerr << proc.GetError() << "\n";
|
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||||
#endif
|
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 );
|
if( !proc.eof() )
|
||||||
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 )
|
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
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
|
#endif
|
||||||
|
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,15 +725,32 @@ SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ )
|
||||||
if( m_Items.empty() )
|
if( m_Items.empty() )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if( m_Items.size() != 1 )
|
if( m_Items.size() == 1 )
|
||||||
{
|
return (*m_Items.begin())->TranslateToSG( NULL, NULL );
|
||||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
|
||||||
std::cerr << " * [INFO] Bad VRML file, >1 top level transform (";
|
|
||||||
std::cerr << m_Items.size() << ")\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
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 NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*m_Items.begin())->TranslateToSG( NULL, NULL );
|
return node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if( NULL == sp )
|
||||||
{
|
{
|
||||||
m_current.Init();
|
m_current.Init();
|
||||||
sp = &m_current;
|
sp = &m_current;
|
||||||
|
|
Loading…
Reference in New Issue