Fix X3D model parser.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10385
This commit is contained in:
Wayne Stambaugh 2022-01-12 18:55:18 -05:00
parent e244ce1431
commit 44e4abde0e
4 changed files with 37 additions and 17 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -232,9 +232,14 @@ SGNODE* X3DAPP::TranslateToSG( SGNODE* aParent )
{
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
wxString::Format( wxT( "Appearance does not have a Shape parent (parent ID: %d)" ),
ptype ) );
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
{
wxLogTrace( traceVrmlPlugin,
wxT( " * [BUG] Appearance does not have a Shape parent (parent ID: %d)" ),
ptype );
return nullptr;
}
wxLogTrace( traceVrmlPlugin,
wxT( " * [INFO] Translating Appearance node with %zu children, %zu"

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -227,10 +227,14 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent )
{
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
wxString::Format( wxT( "IndexedFaceSet does not have a valid Shape parent "
"(parent ID: %d)" ),
ptype ) );
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
{
wxLogTrace( traceVrmlPlugin,
wxT( " * [BUG] IndexedFaceSet does not have a valid Shape parent "
"(parent ID: %d)" ), ptype );
return nullptr;
}
wxLogTrace( traceVrmlPlugin,
wxT( " * [INFO] Translating IndexedFaceSet with %zu children, %zu references, "

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -252,9 +252,14 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent )
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
wxString::Format( wxT( "Shape does not have a Transform parent (parent ID: %d)" ),
ptype ) );
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
{
wxLogTrace( traceVrmlPlugin,
wxT( " * [BUG] Shape does not have a Transform parent (parent ID: %d)" ),
ptype );
return nullptr;
}
if( m_sgNode )
{

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -38,6 +38,7 @@ X3DTRANSFORM::X3DTRANSFORM() : X3DNODE()
init();
}
X3DTRANSFORM::X3DTRANSFORM( X3DNODE* aParent ) : X3DNODE()
{
m_Type = X3D_TRANSFORM;
@ -267,9 +268,14 @@ SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent )
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
wxString::Format( wxT( "Transform does not have a Transform parent "
"(parent ID: %d)" ), ptype ) );
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
{
wxLogTrace( traceVrmlPlugin,
wxT( " * [BUG] Transform does not have a Transform parent (parent ID: %d)" ),
ptype );
return nullptr;
}
if( m_sgNode )
{