2015-12-22 06:02:33 +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-22 06:02:33 +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>
|
|
|
|
#include <wx/log.h>
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
#include "vrml2_base.h"
|
2015-12-22 06:02:33 +00:00
|
|
|
#include "vrml2_transform.h"
|
2016-01-02 01:21:02 +00:00
|
|
|
#include "plugins/3dapi/ifsg_all.h"
|
2015-12-22 06:02:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
WRL2TRANSFORM::WRL2TRANSFORM() : WRL2NODE()
|
|
|
|
{
|
2021-03-10 23:49:09 +00:00
|
|
|
m_Type = WRL2NODES::WRL2_TRANSFORM;
|
2015-12-22 06:02:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WRL2TRANSFORM::WRL2TRANSFORM( WRL2NODE* aParent ) : WRL2NODE()
|
|
|
|
{
|
2021-03-10 23:49:09 +00:00
|
|
|
m_Type = WRL2NODES::WRL2_TRANSFORM;
|
2015-12-22 06:02:33 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL != m_Parent )
|
|
|
|
m_Parent->AddChildNode( this );
|
2015-12-22 06:02:33 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
WRL2TRANSFORM::~WRL2TRANSFORM()
|
2015-12-22 06:02:33 +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] Destroying Transform with " << m_Children.size();
|
|
|
|
ostr << " children, " << m_Refs.size() << " references and ";
|
|
|
|
ostr << m_BackPointers.size() << " backpointers";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return;
|
2015-12-22 06:02:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2TRANSFORM::isDangling( void )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
// a Transform node is never dangling
|
2015-12-22 06:02:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// functions inherited from WRL2NODE
|
|
|
|
bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Structure of a Transform node (p.120):
|
|
|
|
*
|
|
|
|
* Transform {
|
|
|
|
* eventIn MFNode addChildren
|
|
|
|
* eventIn MFNode removeChildren
|
|
|
|
* exposedField SFVec3f center 0 0 0
|
|
|
|
* exposedField MFNode children []
|
|
|
|
* exposedField SFRotation rotation 0 0 1 0
|
|
|
|
* exposedField SFVec3f scale 1 1 1
|
2015-12-30 22:28:39 +00:00
|
|
|
* exposedField SFRotation scaleOrientation 0 0 1 0
|
2015-12-22 06:02:33 +00:00
|
|
|
* exposedField SFVec3f translation 0 0 0
|
|
|
|
* field SFVec3f bboxCenter 0 0 0
|
|
|
|
* field SFVec3f bboxSize 0 0 0
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( NULL == aTopNode )
|
|
|
|
{
|
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] aTopNode is NULL";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-30 22:28:39 +00:00
|
|
|
center.x = 0.0;
|
|
|
|
center.y = 0.0;
|
|
|
|
center.z = 0.0;
|
|
|
|
|
|
|
|
translation = center;
|
|
|
|
bboxCenter = center;
|
|
|
|
bboxSize = center;
|
|
|
|
|
|
|
|
rotation.x = 0.0;
|
|
|
|
rotation.y = 0.0;
|
|
|
|
rotation.z = 1.0;
|
|
|
|
rotation.w = 0.0;
|
|
|
|
|
|
|
|
scaleOrientation = rotation;
|
|
|
|
|
|
|
|
scale.x = 1.0;
|
|
|
|
scale.y = 1.0;
|
|
|
|
scale.z = 1.0;
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
size_t line, column;
|
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
|
|
|
|
char tok = proc.Peek();
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
if( proc.eof() )
|
|
|
|
{
|
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] bad file format; unexpected eof at line ";
|
|
|
|
ostr << line << ", column " << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-12-22 06:02:33 +00:00
|
|
|
|
|
|
|
if( '{' != tok )
|
|
|
|
{
|
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] bad file format; expecting '{' but got '" << tok;
|
|
|
|
ostr << "' at line " << 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc.Pop();
|
|
|
|
std::string glob;
|
|
|
|
|
|
|
|
while( true )
|
|
|
|
{
|
|
|
|
if( proc.Peek() == '}' )
|
2015-12-30 22:28:39 +00:00
|
|
|
{
|
|
|
|
proc.Pop();
|
|
|
|
break;
|
|
|
|
}
|
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;
|
|
|
|
}
|
2015-12-22 08:02:18 +00:00
|
|
|
|
|
|
|
// expecting one of:
|
|
|
|
// center
|
|
|
|
// children
|
|
|
|
// rotation
|
|
|
|
// scale
|
|
|
|
// ScaleOrientation
|
2015-12-30 22:28:39 +00:00
|
|
|
// translation
|
2015-12-22 08:02:18 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
|
2015-12-30 22:28:39 +00:00
|
|
|
if( !glob.compare( "center" ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !proc.ReadSFVec3f( center ) )
|
|
|
|
{
|
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] invalid center at line " << line << ", column ";
|
|
|
|
ostr << column << "\n";
|
|
|
|
ostr << " * [INFO] file: '" << proc.GetFileName() << "'\n";
|
|
|
|
ostr << " * [INFO] message: '" << proc.GetError() << "'";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-17 23:39:51 +00:00
|
|
|
|
|
|
|
// convert from 1 VRML Unit = 0.1 inch to 1 VRML Unit = 1 mm
|
2019-12-12 21:51:21 +00:00
|
|
|
center.x *= 2.54f;
|
|
|
|
center.y *= 2.54f;
|
|
|
|
center.z *= 2.54f;
|
2015-12-30 22:28:39 +00:00
|
|
|
}
|
|
|
|
else if( !glob.compare( "rotation" ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !proc.ReadSFRotation( rotation ) )
|
|
|
|
{
|
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] invalid rotation at line " << line << ", column ";
|
|
|
|
ostr << column << "\n";
|
|
|
|
ostr << " * [INFO] file: '" << proc.GetFileName() << "'\n";
|
|
|
|
ostr << " * [INFO] message: '" << proc.GetError() << "'";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-12-30 22:28:39 +00:00
|
|
|
}
|
|
|
|
else if( !glob.compare( "scale" ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !proc.ReadSFVec3f( scale ) )
|
|
|
|
{
|
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] invalid scale at line " << line << ", column ";
|
|
|
|
ostr << column << "\n";
|
|
|
|
ostr << " * [INFO] file: '" << proc.GetFileName() << "'\n";
|
|
|
|
ostr << " * [INFO] message: '" << proc.GetError() << "'";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-12-30 22:28:39 +00:00
|
|
|
}
|
|
|
|
else if( !glob.compare( "scaleOrientation" ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !proc.ReadSFRotation( scaleOrientation ) )
|
|
|
|
{
|
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] invalid scaleOrientation at line " << line << ", column ";
|
|
|
|
ostr << column << "\n";
|
|
|
|
ostr << " * [INFO] file: '" << proc.GetFileName() << "'\n";
|
|
|
|
ostr << " * [INFO] message: '" << proc.GetError() << "'";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-12-30 22:28:39 +00:00
|
|
|
}
|
|
|
|
else if( !glob.compare( "translation" ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !proc.ReadSFVec3f( translation ) )
|
|
|
|
{
|
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] invalid translation at line " << line << ", column ";
|
|
|
|
ostr << column << "\n";
|
|
|
|
ostr << " * [INFO] file: '" << proc.GetFileName() << "'\n";
|
|
|
|
ostr << " * [INFO] message: '" << proc.GetError() << "'";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-17 23:39:51 +00:00
|
|
|
|
|
|
|
// convert from 1 VRML Unit = 0.1 inch to 1 VRML Unit = 1 mm
|
2019-12-12 21:51:21 +00:00
|
|
|
translation.x *= 2.54f;
|
|
|
|
translation.y *= 2.54f;
|
|
|
|
translation.z *= 2.54f;
|
2015-12-30 22:28:39 +00:00
|
|
|
}
|
|
|
|
else if( !glob.compare( "children" ) )
|
|
|
|
{
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !readChildren( proc, aTopNode ) )
|
|
|
|
return false;
|
2015-12-30 22:28:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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] bad Transform at line " << line << ", column ";
|
|
|
|
ostr << column << "\n";
|
|
|
|
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-30 22:28:39 +00:00
|
|
|
#endif
|
2015-12-22 06:02:33 +00:00
|
|
|
|
2015-12-30 22:28:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} // while( true ) -- reading contents of Transform{}
|
|
|
|
|
|
|
|
return true;
|
2015-12-22 06:02:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode )
|
|
|
|
{
|
|
|
|
if( NULL == aNode )
|
|
|
|
{
|
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] NULL passed as node pointer";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2015-12-22 06:02:33 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// take possession if the node is dangling WRL2_SHAPE
|
|
|
|
|
2021-03-10 23:49:09 +00:00
|
|
|
if( WRL2NODES::WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() )
|
2015-12-22 06:02:33 +00:00
|
|
|
{
|
|
|
|
WRL2NODE* np = aNode->GetParent();
|
|
|
|
|
|
|
|
if( NULL != np )
|
|
|
|
aNode->SetParent( this );
|
2016-02-05 22:38:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
if( !WRL2NODE::AddChildNode( aNode ) )
|
|
|
|
{
|
|
|
|
aNode->SetParent( NULL );
|
|
|
|
return false;
|
|
|
|
}
|
2015-12-22 06:02:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 22:38:03 +00:00
|
|
|
if( !WRL2NODE::AddRefNode( aNode ) )
|
|
|
|
return false;
|
|
|
|
|
2015-12-22 06:02:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-01-01 05:05:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
|
|
|
{
|
|
|
|
size_t line, column;
|
|
|
|
proc.GetFilePosData( line, column );
|
|
|
|
|
|
|
|
char tok = proc.Peek();
|
|
|
|
|
|
|
|
if( proc.eof() )
|
|
|
|
{
|
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] bad file format; unexpected eof at line ";
|
|
|
|
ostr << line << ", column " << column;
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-01 05:05:14 +00:00
|
|
|
#endif
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( '[' != tok )
|
|
|
|
{
|
2021-06-09 19:32:58 +00:00
|
|
|
// since there are no delimiters we expect a single child
|
2016-01-01 05:05:14 +00:00
|
|
|
if( !aTopNode->ReadNode( proc, this, NULL ) )
|
|
|
|
return false;
|
|
|
|
|
2016-01-04 07:10:15 +00:00
|
|
|
if( proc.Peek() == ',' )
|
|
|
|
proc.Pop();
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc.Pop();
|
|
|
|
|
|
|
|
while( true )
|
|
|
|
{
|
|
|
|
if( proc.Peek() == ']' )
|
|
|
|
{
|
|
|
|
proc.Pop();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aTopNode->ReadNode( proc, this, NULL ) )
|
|
|
|
return false;
|
2016-01-04 07:10:15 +00:00
|
|
|
|
|
|
|
if( proc.Peek() == ',' )
|
|
|
|
proc.Pop();
|
|
|
|
|
2016-01-01 05:05:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-01 07:55:43 +00:00
|
|
|
|
|
|
|
|
2016-02-02 05:50:46 +00:00
|
|
|
SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent )
|
2016-01-01 07:55:43 +00:00
|
|
|
{
|
2016-01-04 07:10:15 +00:00
|
|
|
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
2016-02-23 02:31:51 +00:00
|
|
|
do {
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << " * [INFO] Translating Transform with " << m_Children.size();
|
|
|
|
ostr << " children, " << m_Refs.size() << " references and ";
|
|
|
|
ostr << m_BackPointers.size() << " backpointers";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-04 07:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2016-01-02 01:21:02 +00:00
|
|
|
if( m_Children.empty() && m_Refs.empty() )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
|
|
|
|
|
|
|
if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
|
|
|
{
|
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] Transform does not have a Transform parent (parent ID: ";
|
|
|
|
ostr << ptype << ")";
|
|
|
|
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
|
|
|
} while( 0 );
|
2016-01-02 01:21:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_sgNode )
|
|
|
|
{
|
2016-01-04 07:10:15 +00:00
|
|
|
if( NULL != aParent )
|
2016-01-02 01:21:02 +00:00
|
|
|
{
|
2016-01-04 07:10:15 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
IFSG_TRANSFORM txNode( aParent );
|
|
|
|
|
|
|
|
std::list< WRL2NODE* >::iterator sC = m_Children.begin();
|
|
|
|
std::list< WRL2NODE* >::iterator eC = m_Children.end();
|
|
|
|
WRL2NODES type;
|
|
|
|
|
2016-01-04 07:10:15 +00:00
|
|
|
// Include only the following in a Transform node:
|
|
|
|
// Shape
|
|
|
|
// Switch
|
|
|
|
// Transform
|
|
|
|
// Inline
|
2016-01-02 01:21:02 +00:00
|
|
|
bool test = false; // set to true if there are any subnodes for display
|
|
|
|
|
2016-01-02 03:41:54 +00:00
|
|
|
for( int i = 0; i < 2; ++i )
|
2016-01-02 01:21:02 +00:00
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
while( sC != eC )
|
2016-01-02 01:21:02 +00:00
|
|
|
{
|
2016-01-02 03:41:54 +00:00
|
|
|
type = (*sC)->GetNodeType();
|
2016-01-02 01:21:02 +00:00
|
|
|
|
2016-01-02 03:41:54 +00:00
|
|
|
switch( type )
|
|
|
|
{
|
2021-03-10 23:49:09 +00:00
|
|
|
case WRL2NODES::WRL2_SHAPE:
|
|
|
|
case WRL2NODES::WRL2_SWITCH:
|
|
|
|
case WRL2NODES::WRL2_INLINE:
|
|
|
|
case WRL2NODES::WRL2_TRANSFORM:
|
2016-01-02 01:21:02 +00:00
|
|
|
|
2016-02-02 05:50:46 +00:00
|
|
|
if( NULL != (*sC)->TranslateToSG( txNode.GetRawPtr() ) )
|
2016-01-02 03:41:54 +00:00
|
|
|
test = true;
|
2016-01-02 01:21:02 +00:00
|
|
|
|
2016-01-02 03:41:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++ sC;
|
2016-01-02 01:21:02 +00:00
|
|
|
}
|
|
|
|
|
2016-01-02 03:41:54 +00:00
|
|
|
sC = m_Refs.begin();
|
|
|
|
eC = m_Refs.end();
|
2016-01-02 01:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( false == test )
|
|
|
|
{
|
|
|
|
txNode.Destroy();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
txNode.SetScale( SGPOINT( scale.x, scale.y, scale.z ) );
|
|
|
|
txNode.SetCenter( SGPOINT( center.x, center.y, center.z ) );
|
|
|
|
txNode.SetTranslation( SGPOINT( translation.x, translation.y, translation.z ) );
|
|
|
|
txNode.SetScaleOrientation( SGVECTOR( scaleOrientation.x, scaleOrientation.y,
|
|
|
|
scaleOrientation.z ), scaleOrientation.w );
|
|
|
|
txNode.SetRotation( SGVECTOR( rotation.x, rotation.y, rotation.z), rotation.w );
|
|
|
|
|
|
|
|
m_sgNode = txNode.GetRawPtr();
|
|
|
|
|
|
|
|
return m_sgNode;
|
2016-01-01 07:55:43 +00:00
|
|
|
}
|