2015-12-20 07:59:26 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-01-01 05:05:14 +00:00
|
|
|
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2015-12-20 07:59:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2016-02-23 02:31:51 +00:00
|
|
|
#include <sstream>
|
2016-02-22 08:59:07 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/filename.h>
|
2016-02-23 02:31:51 +00:00
|
|
|
#include <wx/log.h>
|
2015-12-20 07:59:26 +00:00
|
|
|
|
|
|
|
#include "vrml2_base.h"
|
2015-12-22 06:02:33 +00:00
|
|
|
#include "vrml2_transform.h"
|
2016-01-01 05:05:14 +00:00
|
|
|
#include "vrml2_shape.h"
|
|
|
|
#include "vrml2_appearance.h"
|
|
|
|
#include "vrml2_material.h"
|
|
|
|
#include "vrml2_faceset.h"
|
2016-01-07 00:24:11 +00:00
|
|
|
#include "vrml2_lineset.h"
|
|
|
|
#include "vrml2_pointset.h"
|
2016-01-01 05:05:14 +00:00
|
|
|
#include "vrml2_coords.h"
|
|
|
|
#include "vrml2_norms.h"
|
|
|
|
#include "vrml2_color.h"
|
2016-01-03 05:55:53 +00:00
|
|
|
#include "vrml2_box.h"
|
2016-01-04 07:10:15 +00:00
|
|
|
#include "vrml2_switch.h"
|
2016-02-22 08:59:07 +00:00
|
|
|
#include "vrml2_inline.h"
|
2016-01-01 07:55:43 +00:00
|
|
|
#include "plugins/3dapi/ifsg_all.h"
|
2015-12-20 07:59:26 +00:00
|
|
|
|
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline );
|
|
|
|
|
2015-12-20 12:37:04 +00:00
|
|
|
WRL2BASE::WRL2BASE() : WRL2NODE()
|
2015-12-20 07:59:26 +00:00
|
|
|
{
|
2016-01-04 07:10:15 +00:00
|
|
|
m_useInline = false;
|
2015-12-20 12:37:04 +00:00
|
|
|
m_Type = WRL2_BASE;
|
2015-12-20 07:59:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WRL2BASE::~WRL2BASE()
|
|
|
|
{
|
2016-02-22 08:59:07 +00:00
|
|
|
std::map< std::string, SGNODE* >::iterator iS = m_inlineModels.begin();
|
|
|
|
std::map< std::string, SGNODE* >::iterator eS = m_inlineModels.end();
|
|
|
|
|
|
|
|
while( iS != eS )
|
|
|
|
{
|
|
|
|
SGNODE* np = iS->second;
|
|
|
|
|
|
|
|
// destroy any orphaned Inline{} node data
|
|
|
|
if( np && NULL == S3D::GetSGNodeParent( np ) )
|
|
|
|
S3D::DestroyNode( np );
|
|
|
|
|
|
|
|
++iS;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_inlineModels.clear();
|
|
|
|
|
2015-12-20 07:59:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// functions inherited from WRL2NODE
|
2016-02-29 23:08:19 +00:00
|
|
|
bool WRL2BASE::SetParent( WRL2NODE* aParent, bool /* doUnlink */ )
|
2015-12-20 07:59:26 +00:00
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] attempting to set parent on WRL2BASE node";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-20 07:59:26 +00:00
|
|
|
#endif
|
2015-12-20 12:37:04 +00:00
|
|
|
|
|
|
|
return false;
|
2015-12-20 07:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-04 07:10:15 +00:00
|
|
|
void WRL2BASE::SetEnableInline( bool enable )
|
|
|
|
{
|
|
|
|
m_useInline = enable;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::GetEnableInline( void )
|
|
|
|
{
|
|
|
|
return m_useInline;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
SGNODE* WRL2BASE::GetInlineData( const std::string& aName )
|
2016-01-04 07:10:15 +00:00
|
|
|
{
|
2016-02-22 08:59:07 +00:00
|
|
|
if( aName.empty() )
|
|
|
|
return NULL;
|
2016-01-04 07:10:15 +00:00
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
std::map< std::string, SGNODE* >::iterator dp = m_inlineModels.find( aName );
|
2016-01-04 07:10:15 +00:00
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
if( dp != m_inlineModels.end() )
|
|
|
|
return dp->second;
|
2016-01-04 07:10:15 +00:00
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
wxString tname;
|
2016-01-04 07:10:15 +00:00
|
|
|
|
2016-04-05 10:32:22 +00:00
|
|
|
if( aName.compare( 0, 7, "file://" ) == 0 )
|
2016-02-22 08:59:07 +00:00
|
|
|
{
|
|
|
|
if( aName.length() <= 7 )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tname = wxString::FromUTF8Unchecked( aName.c_str() );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxFileName fn;
|
|
|
|
fn.Assign( tname );
|
|
|
|
|
2016-04-03 00:55:22 +00:00
|
|
|
if( fn.IsRelative() && !m_dir.empty() )
|
|
|
|
{
|
|
|
|
wxString fname = wxString::FromUTF8Unchecked( m_dir.c_str() );
|
|
|
|
fname.append( tname );
|
|
|
|
fn.Assign( fname );
|
|
|
|
}
|
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
if( !fn.Normalize() )
|
|
|
|
{
|
|
|
|
m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, NULL ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SCENEGRAPH* sp = LoadVRML( fn.GetFullPath(), false );
|
|
|
|
|
|
|
|
if( NULL == sp )
|
|
|
|
{
|
|
|
|
m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, NULL ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, (SGNODE*)sp ) );
|
|
|
|
|
|
|
|
return (SGNODE*)sp;
|
2016-01-04 07:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
std::string WRL2BASE::GetName( void )
|
2015-12-20 07:59:26 +00:00
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] attempting to extract name from virtual base node";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-20 07:59:26 +00:00
|
|
|
#endif
|
2015-12-22 06:02:33 +00:00
|
|
|
|
|
|
|
return std::string( "" );
|
2015-12-20 07:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
bool WRL2BASE::SetName( const std::string& aName )
|
2015-12-20 07:59:26 +00:00
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] attempting to set name on virtual base node";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-20 07:59:26 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-20 07:59:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::Read( WRLPROC& proc )
|
|
|
|
{
|
|
|
|
if( proc.GetVRMLType() != VRML_V2 )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] no open file or file is not a VRML2 file";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-20 07:59:26 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-20 07:59:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
WRL2NODE* node = NULL;
|
2016-04-03 00:55:22 +00:00
|
|
|
m_dir = proc.GetParentDir();
|
2015-12-22 00:08:39 +00:00
|
|
|
|
2015-12-30 23:31:35 +00:00
|
|
|
while( ReadNode( proc, this, &node ) && !proc.eof() );
|
2015-12-22 00:08:39 +00:00
|
|
|
|
|
|
|
if( proc.eof() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::isDangling( void )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
// the base node is never dangling
|
2015-12-22 00:08:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
2015-12-22 00:08:39 +00:00
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
if( !aParent )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] invoked with NULL parent";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string glob;
|
|
|
|
|
|
|
|
if( !proc.ReadName( glob ) )
|
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
WRL2NODE* ref = aParent->FindNode( glob, NULL );
|
|
|
|
|
|
|
|
// return 'true' - the file may be defective but it may still be somewhat OK
|
|
|
|
if( NULL == ref )
|
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [INFO] node '" << glob << "' not found";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aParent->AddRefNode( ref ) )
|
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [INFO] failed to add node '" << glob << "' (";
|
|
|
|
ostr << ref->GetNodeTypeName( ref->GetNodeType() ) << ") to parent of type ";
|
|
|
|
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = ref;
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
2015-12-22 00:08:39 +00:00
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
2015-12-22 06:02:33 +00:00
|
|
|
|
|
|
|
if( NULL == aParent )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] invalid parent pointer (NULL)";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 06:02:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string glob;
|
2016-01-01 05:05:14 +00:00
|
|
|
WRL2NODE* lnode = NULL;
|
2015-12-22 06:02:33 +00:00
|
|
|
|
|
|
|
if( !proc.ReadName( glob ) )
|
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 06:02:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t line, column;
|
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( ReadNode( proc, aParent, &lnode ) )
|
2015-12-22 06:02:33 +00:00
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = lnode;
|
|
|
|
|
|
|
|
if( lnode && !lnode->SetName( glob ) )
|
2015-12-22 06:02:33 +00:00
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
size_t line, column;
|
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [INFO] bad formatting (invalid name) at line";
|
|
|
|
ostr << line << ", column " << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 06:02:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
return true;
|
2015-12-22 06:02:33 +00:00
|
|
|
}
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
2015-12-22 00:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
2015-12-22 00:08:39 +00:00
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
// This function reads a node and stores a pointer to it in aNode.
|
|
|
|
// A value 'true' is returned if a node is successfully read or,
|
|
|
|
// if the node is not supported, successfully discarded. Callers
|
|
|
|
// must always check the value of aNode when the function returns
|
|
|
|
// 'true' since it will be NULL if the node type is not supported.
|
2015-12-22 00:08:39 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
2015-12-22 00:08:39 +00:00
|
|
|
|
|
|
|
if( NULL == aParent )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] invalid parent pointer (NULL)";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-20 07:59:26 +00:00
|
|
|
std::string glob;
|
2015-12-20 12:37:04 +00:00
|
|
|
WRL2NODES ntype;
|
2015-12-20 07:59:26 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
if( !proc.ReadName( glob ) )
|
2015-12-20 07:59:26 +00:00
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2015-12-30 23:31:35 +00:00
|
|
|
if( !proc.eof() )
|
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
2015-12-30 23:31:35 +00:00
|
|
|
}
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
// Process node name:
|
|
|
|
// the names encountered at this point should be one of the
|
|
|
|
// built-in node names or one of:
|
|
|
|
// DEF, USE
|
|
|
|
// PROTO, EXTERNPROTO
|
|
|
|
// ROUTE
|
|
|
|
// any PROTO or EXTERNPROTO defined name
|
|
|
|
// since we do not support PROTO or EXTERNPROTO, any unmatched names are
|
|
|
|
// assumed to be defined via PROTO/EXTERNPROTO and deleted according to
|
|
|
|
// a typical pattern.
|
2016-01-01 05:05:14 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
if( !glob.compare( "USE" ) )
|
|
|
|
{
|
2015-12-22 06:02:33 +00:00
|
|
|
if( !implementUse( proc, aParent, aNode ) )
|
2015-12-20 12:37:04 +00:00
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
2015-12-20 12:37:04 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !glob.compare( "DEF" ) )
|
|
|
|
{
|
2015-12-22 06:02:33 +00:00
|
|
|
if( !implementDef( proc, aParent, aNode ) )
|
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 06:02:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2015-12-22 00:08:39 +00:00
|
|
|
}
|
|
|
|
|
2017-04-16 00:23:04 +00:00
|
|
|
// pattern to skip: PROTO name list
|
2015-12-22 00:08:39 +00:00
|
|
|
if( !glob.compare( "PROTO" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadName( glob ) || !proc.DiscardList() )
|
2015-12-20 12:37:04 +00:00
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
2015-12-20 12:37:04 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-16 00:23:04 +00:00
|
|
|
// pattern to skip: EXTERNPROTO name1 name2 list
|
2015-12-22 00:08:39 +00:00
|
|
|
if( !glob.compare( "EXTERNPROTO" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() )
|
2015-12-20 12:37:04 +00:00
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
2015-12-20 12:37:04 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-16 00:23:04 +00:00
|
|
|
// pattern to skip: ROUTE glob1 glob2 glob3
|
2015-12-22 00:08:39 +00:00
|
|
|
if( !glob.compare( "ROUTE" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) )
|
2015-12-20 12:37:04 +00:00
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << proc.GetError();
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 00:08:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
2015-12-20 12:37:04 +00:00
|
|
|
}
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ntype = getNodeTypeID( glob );
|
2015-12-22 06:02:33 +00:00
|
|
|
size_t line = 0;
|
|
|
|
size_t column = 0;
|
2015-12-22 08:02:18 +00:00
|
|
|
proc.GetFilePosData( line, column );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
#endif
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
switch( ntype )
|
|
|
|
{
|
2015-12-20 12:37:04 +00:00
|
|
|
//
|
|
|
|
// items to be implemented:
|
|
|
|
//
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_APPEARANCE:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readAppearance( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_BOX:
|
2016-01-03 05:55:53 +00:00
|
|
|
|
|
|
|
if( !readBox( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_COLOR:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readColor( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_CONE:
|
2015-12-22 06:02:33 +00:00
|
|
|
// XXX - IMPLEMENT
|
2015-12-22 08:02:18 +00:00
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] FAIL: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2015-12-22 08:02:18 +00:00
|
|
|
else
|
2015-12-30 22:56:56 +00:00
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_COORDINATE:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readCoords( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_CYLINDER:
|
2015-12-22 06:02:33 +00:00
|
|
|
// XXX - IMPLEMENT
|
2015-12-22 08:02:18 +00:00
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] FAIL: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2015-12-22 08:02:18 +00:00
|
|
|
else
|
2015-12-30 22:56:56 +00:00
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
2015-12-30 22:56:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_ELEVATIONGRID:
|
2015-12-22 06:02:33 +00:00
|
|
|
// XXX - IMPLEMENT
|
2015-12-22 08:02:18 +00:00
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] FAIL: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2015-12-22 08:02:18 +00:00
|
|
|
else
|
2015-12-30 22:56:56 +00:00
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_EXTRUSION:
|
2015-12-22 06:02:33 +00:00
|
|
|
// XXX - IMPLEMENT
|
2015-12-22 08:02:18 +00:00
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] FAIL: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2015-12-22 08:02:18 +00:00
|
|
|
else
|
2015-12-30 22:56:56 +00:00
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
2015-12-30 22:56:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_INDEXEDFACESET:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readFaceSet( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2016-01-07 00:24:11 +00:00
|
|
|
case WRL2_INDEXEDLINESET:
|
|
|
|
|
|
|
|
if( !readLineSet( proc, aParent, aNode ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRL2_POINTSET:
|
|
|
|
|
|
|
|
if( !readPointSet( proc, aParent, aNode ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_MATERIAL:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readMaterial( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_NORMAL:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readNorms( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_SHAPE:
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
if( !readShape( proc, aParent, aNode ) )
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
2015-12-30 22:56:56 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_SPHERE:
|
2015-12-22 06:02:33 +00:00
|
|
|
// XXX - IMPLEMENT
|
2015-12-22 08:02:18 +00:00
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] FAIL: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:56:56 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-22 08:02:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2015-12-22 08:02:18 +00:00
|
|
|
else
|
2015-12-30 22:56:56 +00:00
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
2015-12-30 22:56:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2016-01-04 07:10:15 +00:00
|
|
|
case WRL2_SWITCH:
|
|
|
|
|
|
|
|
if( !readSwitch( proc, aParent, aNode ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_TRANSFORM:
|
|
|
|
case WRL2_GROUP:
|
2015-12-22 08:02:18 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !readTransform( proc, aParent, aNode ) )
|
|
|
|
return false;
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
2015-12-20 12:37:04 +00:00
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
case WRL2_INLINE:
|
|
|
|
|
|
|
|
if( !readInline( proc, aParent, aNode ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
//
|
|
|
|
// items not implemented or for optional future implementation:
|
|
|
|
//
|
2015-12-22 00:08:39 +00:00
|
|
|
case WRL2_ANCHOR:
|
|
|
|
case WRL2_AUDIOCLIP:
|
|
|
|
case WRL2_BACKGROUND:
|
|
|
|
case WRL2_BILLBOARD:
|
|
|
|
case WRL2_COLLISION:
|
|
|
|
case WRL2_COLORINTERPOLATOR:
|
|
|
|
case WRL2_COORDINATEINTERPOLATOR:
|
|
|
|
case WRL2_CYLINDERSENSOR:
|
|
|
|
case WRL2_DIRECTIONALLIGHT:
|
|
|
|
case WRL2_FOG:
|
|
|
|
case WRL2_FONTSTYLE:
|
|
|
|
case WRL2_IMAGETEXTURE:
|
|
|
|
case WRL2_LOD:
|
|
|
|
case WRL2_MOVIETEXTURE:
|
|
|
|
case WRL2_NAVIGATIONINFO:
|
|
|
|
case WRL2_NORMALINTERPOLATOR:
|
|
|
|
case WRL2_ORIENTATIONINTERPOLATOR:
|
|
|
|
case WRL2_PIXELTEXTURE:
|
|
|
|
case WRL2_PLANESENSOR:
|
|
|
|
case WRL2_POINTLIGHT:
|
|
|
|
case WRL2_POSITIONINTERPOLATOR:
|
|
|
|
case WRL2_PROXIMITYSENSOR:
|
|
|
|
case WRL2_SCALARINTERPOLATOR:
|
|
|
|
case WRL2_SCRIPT:
|
|
|
|
case WRL2_SOUND:
|
|
|
|
case WRL2_SPHERESENSOR:
|
|
|
|
case WRL2_SPOTLIGHT:
|
|
|
|
case WRL2_TEXT:
|
|
|
|
case WRL2_TEXTURECOORDINATE:
|
|
|
|
case WRL2_TEXTURETRANSFORM:
|
|
|
|
case WRL2_TIMESENSOR:
|
|
|
|
case WRL2_TOUCHSENSOR:
|
|
|
|
case WRL2_VIEWPOINT:
|
|
|
|
case WRL2_VISIBILITYSENSOR:
|
|
|
|
case WRL2_WORLDINFO:
|
|
|
|
case WRL2_INVALID:
|
2015-12-22 06:02:33 +00:00
|
|
|
default:
|
|
|
|
|
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
|
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
2016-01-02 22:57:41 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << proc.GetError() << "\n";
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [INFO] could not discard node at line " << line;
|
|
|
|
ostr << ", column " << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 06:02:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-07 04:43:32 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
|
|
|
else
|
|
|
|
{
|
2016-02-23 02:31:51 +00:00
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] OK: discard unsupported " << glob << " node at l";
|
|
|
|
ostr << line << ", c" << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
2016-01-07 04:43:32 +00:00
|
|
|
}
|
|
|
|
#endif
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2015-12-22 00:08:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-12-21 21:19:05 +00:00
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|
|
|
{
|
|
|
|
// this function makes no sense in the base node
|
2016-01-02 03:41:54 +00:00
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << proc.GetError() << "\n";
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] this method must never be invoked on a WRL2BASE object";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
bool WRL2BASE::readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2TRANSFORM* np = new WRL2TRANSFORM( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
bool WRL2BASE::readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
2015-12-22 06:02:33 +00:00
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
WRL2SHAPE* np = new WRL2SHAPE( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2APPEARANCE* np = new WRL2APPEARANCE( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2MATERIAL* np = new WRL2MATERIAL( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2FACESET* np = new WRL2FACESET( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
2016-01-07 00:24:11 +00:00
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2LINESET* np = new WRL2LINESET( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2POINTSET* np = new WRL2POINTSET( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2COORDS* np = new WRL2COORDS( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2NORMS* np = new WRL2NORMS( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2COLOR* np = new WRL2COLOR( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
2015-12-21 21:19:05 +00:00
|
|
|
}
|
2016-01-01 07:55:43 +00:00
|
|
|
|
|
|
|
|
2016-01-03 05:55:53 +00:00
|
|
|
bool WRL2BASE::readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2BOX* np = new WRL2BOX( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-04 07:10:15 +00:00
|
|
|
bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
WRL2SWITCH* np = new WRL2SWITCH( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-22 08:59:07 +00:00
|
|
|
bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|
|
|
{
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = NULL;
|
|
|
|
|
|
|
|
if( !m_useInline )
|
|
|
|
{
|
|
|
|
size_t line = 0;
|
|
|
|
size_t column = 0;
|
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
|
|
|
|
if( !proc.DiscardNode() )
|
|
|
|
{
|
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << proc.GetError() << "\n";
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [INFO] could not discard Inline node at line " << line;
|
|
|
|
ostr << ", column " << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-02-22 08:59:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
WRL2INLINE* np = new WRL2INLINE( aParent );
|
|
|
|
|
|
|
|
if( !np->Read( proc, this ) )
|
|
|
|
{
|
|
|
|
delete np;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( NULL != aNode )
|
|
|
|
*aNode = (WRL2NODE*) np;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-02 05:50:46 +00:00
|
|
|
SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent )
|
2016-01-01 07:55:43 +00:00
|
|
|
{
|
|
|
|
if( m_Children.empty() )
|
|
|
|
return NULL;
|
|
|
|
|
2016-01-04 07:10:15 +00:00
|
|
|
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
|
|
|
|
|
|
|
if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE )
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_VRML2
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
|
|
|
ostr << " * [BUG] WRL2BASE does not have a Transform parent (parent ID: ";
|
|
|
|
ostr << ptype << ")";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-04 07:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-01-02 01:21:02 +00:00
|
|
|
if( m_sgNode )
|
2016-01-04 07:10:15 +00:00
|
|
|
{
|
|
|
|
if( NULL != aParent )
|
|
|
|
{
|
|
|
|
if( NULL == S3D::GetSGNodeParent( m_sgNode )
|
|
|
|
&& !S3D::AddSGNodeChild( aParent, m_sgNode ) )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if( aParent != S3D::GetSGNodeParent( m_sgNode )
|
|
|
|
&& !S3D::AddSGNodeRef( aParent, m_sgNode ) )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-02 01:21:02 +00:00
|
|
|
return m_sgNode;
|
2016-01-04 07:10:15 +00:00
|
|
|
}
|
2016-01-01 07:55:43 +00:00
|
|
|
|
|
|
|
IFSG_TRANSFORM topNode( aParent );
|
|
|
|
|
|
|
|
std::list< WRL2NODE* >::iterator sC = m_Children.begin();
|
|
|
|
std::list< WRL2NODE* >::iterator eC = m_Children.end();
|
|
|
|
WRL2NODES type;
|
|
|
|
|
|
|
|
// Include only Shape and Transform nodes in the top node
|
|
|
|
bool test = false; // set to true if there are any subnodes for display
|
|
|
|
|
|
|
|
while( sC != eC )
|
|
|
|
{
|
|
|
|
type = (*sC)->GetNodeType();
|
|
|
|
|
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case WRL2_SHAPE:
|
|
|
|
// wrap the shape in a transform
|
|
|
|
do
|
|
|
|
{
|
|
|
|
IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
|
2016-02-02 05:50:46 +00:00
|
|
|
SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
|
2016-01-01 07:55:43 +00:00
|
|
|
|
|
|
|
if( NULL != pshape )
|
|
|
|
test = true;
|
|
|
|
else
|
|
|
|
wrapper.Destroy();
|
|
|
|
|
|
|
|
} while( 0 );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRL2_TRANSFORM:
|
2016-01-04 07:10:15 +00:00
|
|
|
case WRL2_SWITCH:
|
2016-02-22 08:59:07 +00:00
|
|
|
case WRL2_INLINE:
|
2016-01-01 07:55:43 +00:00
|
|
|
|
2016-02-02 05:50:46 +00:00
|
|
|
if( NULL != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
|
2016-01-01 07:55:43 +00:00
|
|
|
test = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++ sC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( false == test )
|
|
|
|
{
|
|
|
|
topNode.Destroy();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-01-02 01:21:02 +00:00
|
|
|
m_sgNode = topNode.GetRawPtr();
|
2016-01-01 07:55:43 +00:00
|
|
|
|
2016-01-02 01:21:02 +00:00
|
|
|
return m_sgNode;
|
2016-01-01 07:55:43 +00:00
|
|
|
}
|