3D plugin debugging output fixes.
This commit is contained in:
parent
1aadf45947
commit
728b160719
|
@ -47,8 +47,12 @@
|
|||
// number 0 is special (the PCB board color)
|
||||
#define NCOLORS 6
|
||||
|
||||
// log mask for wxLogTrace
|
||||
#define MASK_IDF "PLUGIN_IDF"
|
||||
/**
|
||||
* Flag to enable IDF plugin trace output.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
const wxChar* const traceIdfPlugin = wxT( "KICAD_IDF_PLUGIN" );
|
||||
|
||||
|
||||
// read and instantiate an IDF component outline
|
||||
|
@ -357,28 +361,16 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
|
|||
|
||||
if( nvcont < 0 )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] cannot create an outline";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [INFO] cannot create an outline",
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (*scont)->size() < 1 )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid contour: no vertices";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [INFO] invalid contour: no vertices",
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -394,14 +386,8 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
|
|||
|
||||
if( !addSegment( model, &lseg, nvcont, iseg ) )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] cannot add segment";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [BUG] cannot add segment",
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -428,14 +414,8 @@ static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg
|
|||
{
|
||||
if( iseg != 0 )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] adding a circle to an existing vertex list";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [INFO] adding a circle to an "
|
||||
"existing vertex list", __FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -473,28 +453,16 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do
|
|||
|
||||
if( !vpcb.Get3DTriangles( vertices, idxPlane, idxSide, top, bottom ) )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] no vertex data";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [INFO] no vertex data",
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if( ( idxPlane.size() % 3 ) || ( idxSide.size() % 3 ) )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [BUG] index lists are not a multiple of 3 "
|
||||
"(not a triangle list)", __FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -603,14 +571,8 @@ static SCENEGRAPH* addOutline( IDF3_COMP_OUTLINE* outline, int idxColor, SGNODE*
|
|||
|
||||
if( !getOutlineModel( vpcb, outline->GetOutlines() ) )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] no valid outline data";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [INFO] no valid outline data",
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -643,17 +605,9 @@ static SCENEGRAPH* loadIDFOutline( const wxString& aFileName )
|
|||
|
||||
if( nullptr == outline )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] Failed to read IDF data:\n";
|
||||
ostr << brd.GetError() << "\n\n";
|
||||
ostr << " * [INFO] no outline for file '";
|
||||
ostr << aFileName << "'";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n * [INFO] Failed to read IDF data:\n%s\n"
|
||||
" * [INFO] no outline for file '%s'", __FILE__, __FUNCTION__, __LINE__,
|
||||
brd.GetError(), aFileName );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -672,16 +626,9 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
|
|||
// note: if the IDF model is defective no outline substitutes shall be made
|
||||
if( !brd.ReadFile( aFileName, true ) )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] Failed to read IDF file:\n";
|
||||
ostr << brd.GetError() << "\n\n";
|
||||
ostr << " * [INFO] IDF file '" << aFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceIdfPlugin, "%s:%s:%s\n"
|
||||
"* [INFO] Error '%s' occurred reading IDF file: %s",
|
||||
__FILE__, __FUNCTION__, __LINE__, brd.GetError(), aFileName );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ WRL1BASE::WRL1BASE() : WRL1NODE( nullptr )
|
|||
|
||||
WRL1BASE::~WRL1BASE()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying virtual base node" );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Destroying virtual base node." ) );
|
||||
|
||||
cancelDict();
|
||||
}
|
||||
|
@ -57,64 +57,27 @@ WRL1BASE::~WRL1BASE()
|
|||
|
||||
bool WRL1BASE::SetParent( WRL1NODE* aParent, bool /* doUnlink */ )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] attempting to set parent on WRL1BASE node";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "Attempt to set parent on WRL1BASE node." ) );
|
||||
}
|
||||
|
||||
|
||||
std::string WRL1BASE::GetName( void )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return std::string( "" );
|
||||
wxCHECK_MSG( false, std::string( "" ),
|
||||
wxT( "Attempt to extract name from virtual base node." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1BASE::SetName( const std::string& aName )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "Attempt to set name on virtual base node." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1BASE::Read( WRLPROC& proc )
|
||||
{
|
||||
if( proc.GetVRMLType() != WRLVERSION::VRML_V1 )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] no open file or file is not a VRML1 file";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( proc.GetVRMLType() == WRLVERSION::VRML_V1, false,
|
||||
wxT( "No open file or file is not a VRML1 file" ) );
|
||||
|
||||
// Note: according to the VRML1 specification, a file may contain
|
||||
// only one grouping node at the top level. The following code
|
||||
|
@ -123,20 +86,11 @@ bool WRL1BASE::Read( WRLPROC& proc )
|
|||
|
||||
while( proc.Peek() )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n * [INFO] bad file format; unexpected eof %s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -144,14 +98,8 @@ bool WRL1BASE::Read( WRLPROC& proc )
|
|||
|
||||
if( !proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -165,32 +113,13 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
|
|||
if( nullptr != aNode )
|
||||
*aNode = nullptr;
|
||||
|
||||
if( !aParent )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aParent, false, wxT( "Invoked with invalid parent." ) );
|
||||
|
||||
std::string glob;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s" ), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -200,30 +129,19 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
|
|||
// return 'true' - the file may be defective but it may still be somewhat OK
|
||||
if( nullptr == ref )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n * [INFO] node '%s' not found." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, glob );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !aParent->AddRefNode( ref ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n * [INFO] failed to add node '%s' (%s) to parent of type %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, glob,
|
||||
ref->GetNodeTypeName( ref->GetNodeType() ),
|
||||
aParent->GetNodeTypeName( aParent->GetNodeType() ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -240,40 +158,19 @@ bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
|
|||
if( nullptr != aNode )
|
||||
*aNode = nullptr;
|
||||
|
||||
if( nullptr == aParent )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] invalid parent pointer (nullptr)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( nullptr != aParent, false, wxT( "Invalid parent pointer." ) );
|
||||
|
||||
std::string glob;
|
||||
WRL1NODE* lnode = nullptr;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( ReadNode( proc, aParent, &lnode ) )
|
||||
{
|
||||
if( nullptr != aNode )
|
||||
|
@ -281,17 +178,9 @@ bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode
|
|||
|
||||
if( lnode && !lnode->SetName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n * [INFO] bad formatting (invalid name) %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -319,34 +208,18 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
|
|||
if( nullptr != aNode )
|
||||
*aNode = nullptr;
|
||||
|
||||
if( nullptr == aParent )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aParent, false, wxT( "Invalid parent pointer." ) );
|
||||
|
||||
std::string glob;
|
||||
WRL1NODES ntype;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
if( !proc.eof() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -358,18 +231,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
|
|||
if( !glob.compare( "USE" ) )
|
||||
{
|
||||
if( !implementUse( proc, aParent, aNode ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -377,34 +239,14 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
|
|||
if( !glob.compare( "DEF" ) )
|
||||
{
|
||||
if( !implementDef( proc, aParent, aNode ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ntype = getNodeTypeID( glob );
|
||||
size_t line = 0;
|
||||
size_t column = 0;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Processing node '%s' ID: %d." ), glob, ntype );
|
||||
|
||||
switch( ntype )
|
||||
{
|
||||
|
@ -479,32 +321,20 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
|
|||
//
|
||||
default:
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n * [INFO] could not discard node %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] discarded node '" << glob << "' at line ";
|
||||
ostr << line << ", col " << column << " (currently unsupported)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] discarded node '%s' %s (currently unsupported)." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -515,18 +345,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode )
|
|||
|
||||
bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
// this function makes no sense in the base node
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << proc.GetError() << "\n";
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] this method must never be invoked on a WRL1BASE object";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "This method must never be invoked on a WRL1BASE object" ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -709,20 +528,14 @@ bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod
|
|||
|
||||
SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating VRML1 Base with " << m_Items.size();
|
||||
ostr << " items";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Translating VRML1 Base with %ul items." ),
|
||||
m_Items.size() );
|
||||
|
||||
if( m_Items.empty() )
|
||||
return nullptr;
|
||||
|
||||
if( m_Items.size() == 1 )
|
||||
return (*m_Items.begin())->TranslateToSG( nullptr, nullptr );
|
||||
return ( *m_Items.begin() )->TranslateToSG( nullptr, nullptr );
|
||||
|
||||
// Note: according to the VRML1 specification, a file may contain
|
||||
// only one grouping node at the top level. The following code
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -39,11 +40,27 @@ class SGNODE;
|
|||
class WRL1INLINE;
|
||||
|
||||
/**
|
||||
* WRL1BASE
|
||||
* represents the top node of a VRML1 model
|
||||
* Represent the top node of a VRML1 model.
|
||||
*/
|
||||
class WRL1BASE : public WRL1NODE
|
||||
{
|
||||
public:
|
||||
WRL1BASE();
|
||||
virtual ~WRL1BASE();
|
||||
|
||||
// function to read entire VRML file
|
||||
bool Read( WRLPROC& proc );
|
||||
|
||||
// read in a VRML node
|
||||
bool ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode );
|
||||
|
||||
virtual std::string GetName( void ) override;
|
||||
virtual bool SetName( const std::string& aName ) override;
|
||||
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool SetParent( WRL1NODE* aParent, bool doUnlink = true ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
private:
|
||||
// handle cases of USE / DEF
|
||||
bool implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode );
|
||||
|
@ -58,25 +75,6 @@ private:
|
|||
bool readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode );
|
||||
bool readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode );
|
||||
bool readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode );
|
||||
|
||||
public:
|
||||
WRL1BASE();
|
||||
virtual ~WRL1BASE();
|
||||
|
||||
// function to read entire VRML file
|
||||
bool Read( WRLPROC& proc );
|
||||
|
||||
// read in a VRML node
|
||||
bool ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode );
|
||||
|
||||
// overrides
|
||||
virtual std::string GetName( void ) override;
|
||||
virtual bool SetName( const std::string& aName ) override;
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool SetParent( WRL1NODE* aParent, bool doUnlink = true ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
};
|
||||
|
||||
#endif // VRML1_BASE_H
|
||||
|
|
|
@ -50,80 +50,44 @@ WRL1COORDS::WRL1COORDS( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1COORDS::~WRL1COORDS()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate3 node\n" );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Coordinate3 node." );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1COORDS::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1COORDS::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 << "\n";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -139,52 +103,34 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
// expecting 'point'
|
||||
if( !glob.compare( "point" ) )
|
||||
{
|
||||
if( !proc.ReadMFVec3f( points ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid point set 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid point set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Coordinate at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"* [INFO] bad Coordinate %s.\n"
|
||||
"* [INFO] file: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -208,18 +154,10 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
return true;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Coordinate at line " << line << ", column ";
|
||||
ostr << column << " (no closing brace)\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad Coordinate %s (no closing brace)." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -241,12 +179,7 @@ void WRL1COORDS::GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize )
|
|||
|
||||
SGNODE* WRL1COORDS::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||
{
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( sp, nullptr, wxT( "Inalid base data." ) );
|
||||
|
||||
sp->coord = this;
|
||||
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,26 +37,23 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1COORDS
|
||||
*/
|
||||
|
||||
class WRL1COORDS : public WRL1NODE
|
||||
{
|
||||
private:
|
||||
std::vector< WRLVEC3F > points;
|
||||
|
||||
public:
|
||||
WRL1COORDS( NAMEREGISTER* aDictionary );
|
||||
WRL1COORDS( NAMEREGISTER* aDictionary, WRL1NODE* aParent );
|
||||
virtual ~WRL1COORDS();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
void GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize );
|
||||
|
||||
private:
|
||||
std::vector< WRLVEC3F > points;
|
||||
};
|
||||
|
||||
#endif // VRML1_COORDS_H
|
||||
|
|
|
@ -54,86 +54,46 @@ WRL1FACESET::WRL1FACESET( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1FACESET::~WRL1FACESET()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying IndexedFaceSet 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Destroying IndexedFaceSet with %ul children, "
|
||||
"%ul references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1FACESET::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1FACESET::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -151,14 +111,8 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -167,23 +121,17 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
// coordIndex[]
|
||||
// materialIndex[]
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "coordIndex" ) )
|
||||
{
|
||||
if( !proc.ReadMFInt( coordIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid coordIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid coordIndex %s.\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -192,17 +140,13 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( matIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid materialIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid materialIndex %s.\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -211,17 +155,13 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( normIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid normalIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid normalIndex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -230,33 +170,25 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( texIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid textureCoordIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid textureCoordIndex %s.\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad IndexedFaceSet at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid IndexedFaceSet %s.\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -274,7 +206,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
// decompose into Rotate,Scale,Transform via an analytic expression.
|
||||
if( !m_Parent )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no parent node\n" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no parent node." );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -282,7 +214,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
{
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no base data given." );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -290,20 +222,15 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
|
||||
m_current = *sp;
|
||||
|
||||
if( nullptr == m_current.coord || nullptr == m_current.mat )
|
||||
if( nullptr == m_current.coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
if( nullptr == m_current.coord )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no vertex set\n" );
|
||||
}
|
||||
|
||||
if( nullptr == m_current.mat )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no material set\n" );
|
||||
}
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no vertex set." );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if( nullptr == m_current.mat )
|
||||
{
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no material set." );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -315,14 +242,9 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
|
||||
if( coordsize < 3 || vsize < 3 )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] bad model: coordsize, indexsize = " << coordsize;
|
||||
ostr << ", " << vsize;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] bad model: coordsize = %ul, indexsize = %ul" ),
|
||||
coordsize, vsize );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -343,7 +265,8 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
|
||||
if( matIndex.empty() )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: per face indexed but no indices\n" );
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] bad model: per face indexed but no indices" ) );
|
||||
|
||||
// support bad models by temporarily switching bindings
|
||||
mbind = WRL1_BINDING::BIND_OVERALL;
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,27 +37,23 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1FACESET
|
||||
*/
|
||||
class WRL1FACESET : public WRL1NODE
|
||||
{
|
||||
private:
|
||||
std::vector< int > coordIndex;
|
||||
std::vector< int > matIndex;
|
||||
std::vector< int > normIndex;
|
||||
std::vector< int > texIndex;
|
||||
|
||||
public:
|
||||
WRL1FACESET( NAMEREGISTER* aDictionary );
|
||||
WRL1FACESET( NAMEREGISTER* aDictionary, WRL1NODE* aParent );
|
||||
virtual ~WRL1FACESET();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
private:
|
||||
std::vector< int > coordIndex;
|
||||
std::vector< int > matIndex;
|
||||
std::vector< int > normIndex;
|
||||
std::vector< int > texIndex;
|
||||
};
|
||||
|
||||
#endif // VRML1_FACESET_H
|
||||
|
|
|
@ -56,15 +56,10 @@ WRL1GROUP::WRL1GROUP( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1GROUP::~WRL1GROUP()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying Group 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Group with %ul children, %ul references, and %ul "
|
||||
"back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,50 +67,31 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [BUG] aTopNode is NULL" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -130,19 +106,12 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
break;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -158,36 +127,20 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Group with " << m_Children.size();
|
||||
ostr << " children, " << m_Refs.size() << " references and ";
|
||||
ostr << m_BackPointers.size() << " backpointers (total ";
|
||||
ostr << m_Items.size() << " items)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxCHECK_MSG( m_Parent, nullptr, wxT( "Group has no parent." ) );
|
||||
|
||||
if( !m_Parent )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Group has no parent";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Group with %ul children, %ul references, %ul back "
|
||||
"pointers, and %ul items." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size(), m_Items.size() );
|
||||
|
||||
if( WRL1NODES::WRL1_BASE != m_Parent->GetNodeType() )
|
||||
{
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" );
|
||||
/// @todo Determine if this is a bug or can actually happen parsing a VRML file.
|
||||
/// If it's a bug, this should be an assertion not a trace.
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no base data given." );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -200,20 +153,10 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Group does not have a Transform parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( nullptr == aParent && ptype == S3D::SGTYPE_TRANSFORM, nullptr,
|
||||
wxString::Format(
|
||||
wxT(" * [BUG] Group does not have a Transform parent (parent ID: %d" ),
|
||||
ptype ) );
|
||||
|
||||
IFSG_TRANSFORM txNode( aParent );
|
||||
bool hasContent = false;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -34,9 +35,6 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1GROUP
|
||||
*/
|
||||
class WRL1GROUP : public WRL1NODE
|
||||
{
|
||||
public:
|
||||
|
@ -44,7 +42,6 @@ public:
|
|||
WRL1GROUP( NAMEREGISTER* aDictionary, WRL1NODE* aNode );
|
||||
virtual ~WRL1GROUP();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
};
|
||||
|
|
|
@ -53,92 +53,46 @@ WRL1MATBINDING::WRL1MATBINDING( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1MATBINDING::~WRL1MATBINDING()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying MaterialBinding node\n" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying MaterialBinding node\n" );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1MATBINDING::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1MATBINDING::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "aTopNode is NULL." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -156,44 +110,30 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( glob.compare( "value" ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad MaterialBinding at line " << line << ", column ";
|
||||
ostr << column << " (did not find keyword 'value')\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad MaterialBinding %s (expecting keyword 'value').\n"
|
||||
" * [INFO] file: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -208,8 +148,6 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
// PER_VERTEX
|
||||
// PER_VERTEX_INDEXED
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "DEFAULT" ) )
|
||||
{
|
||||
m_binding = WRL1_BINDING::BIND_DEFAULT;
|
||||
|
@ -244,16 +182,11 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad MaterialBinding at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad MaterialBinding %s\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
m_binding = WRL1_BINDING::BIND_OVERALL;
|
||||
}
|
||||
|
@ -265,12 +198,7 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL1MATBINDING::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||
{
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given" );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG ( sp, nullptr, wxT( "Bad model: no base data given." ) );
|
||||
|
||||
sp->matbind = m_binding;
|
||||
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -35,24 +36,20 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1MATBINDING
|
||||
*/
|
||||
class WRL1MATBINDING : public WRL1NODE
|
||||
{
|
||||
private:
|
||||
WRL1_BINDING m_binding;
|
||||
|
||||
public:
|
||||
WRL1MATBINDING( NAMEREGISTER* aDictionary );
|
||||
WRL1MATBINDING( NAMEREGISTER* aDictionary, WRL1NODE* aParent );
|
||||
virtual ~WRL1MATBINDING();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
private:
|
||||
WRL1_BINDING m_binding;
|
||||
};
|
||||
|
||||
#endif // VRML1_MATBINDING_H
|
||||
|
|
|
@ -55,31 +55,17 @@ WRL1MATERIAL::WRL1MATERIAL( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1MATERIAL::~WRL1MATERIAL()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Material node" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Material node." );
|
||||
|
||||
// destroy any orphaned color nodes
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
if( nullptr != colors[i] )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying SGCOLOR #" << i;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
if( nullptr == S3D::GetSGNodeParent( colors[i] ) )
|
||||
S3D::DestroyNode( colors[i] );
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] destroyed SGCOLOR #" << i;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] destroyed SGCOLOR #%d" ), i );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,85 +74,38 @@ WRL1MATERIAL::~WRL1MATERIAL()
|
|||
bool WRL1MATERIAL::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1MATERIAL::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] aTopNode is nullptr";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "aTopNode is nullptr." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -184,14 +123,9 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -204,23 +138,17 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
// specularColor
|
||||
// transparency
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "specularColor" ) )
|
||||
{
|
||||
if( !proc.ReadMFVec3f( specularColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid specularColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid specularColor %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -229,17 +157,12 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFVec3f( diffuseColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid diffuseColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid diffuseColor %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
" * [INFO] error: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -248,17 +171,12 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFVec3f( emissiveColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid emissiveColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid emissiveColor %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -267,17 +185,12 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFFloat( shininess ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid shininess 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid shininess at line %ul column %ul\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
" * [INFO] error: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -286,17 +199,12 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFFloat( transparency ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid transparency 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid transparency at line %ul column %ul\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
" * [INFO] error: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -305,33 +213,23 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFVec3f( ambientColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid ambientColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid ambientColor at line %ul column %ul\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
" * [INFO] error: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Material at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"* [INFO] bad Material %s.\n"
|
||||
"* [INFO] file: '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -343,12 +241,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL1MATERIAL::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||
{
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given" );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( sp, nullptr, wxT( "Bad model: no base data given." ) );
|
||||
|
||||
sp->mat = this;
|
||||
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -37,12 +38,36 @@ class WRL1BASE;
|
|||
class SGNODE;
|
||||
class SGCOLOR;
|
||||
|
||||
/**
|
||||
* WRL1MATERIAL
|
||||
*/
|
||||
class WRL1MATERIAL : public WRL1NODE
|
||||
{
|
||||
public:
|
||||
WRL1MATERIAL( NAMEREGISTER* aDictionary );
|
||||
WRL1MATERIAL( NAMEREGISTER* aDictionary, WRL1NODE* aParent );
|
||||
virtual ~WRL1MATERIAL();
|
||||
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
/**
|
||||
* Return an SGAPPEARANCE node representing the appearance for an IndexedFaceSet.
|
||||
*/
|
||||
SGNODE* GetAppearance( int aIndex );
|
||||
|
||||
/**
|
||||
* Compute an SGCOLOR representing the appearance of a vertex or face.
|
||||
*/
|
||||
void GetColor( SGCOLOR* aColor, int aIndex );
|
||||
|
||||
/**
|
||||
* Destroy the given color node if it does not have a parent.
|
||||
*/
|
||||
void Reclaim( SGNODE* aColor );
|
||||
|
||||
private:
|
||||
void checkRange( float& aValue );
|
||||
|
||||
std::vector< WRLVEC3F > diffuseColor;
|
||||
std::vector< WRLVEC3F > emissiveColor;
|
||||
std::vector< WRLVEC3F > specularColor;
|
||||
|
@ -51,38 +76,6 @@ private:
|
|||
std::vector< float > transparency;
|
||||
|
||||
SGNODE* colors[2];
|
||||
|
||||
void checkRange( float& aValue );
|
||||
|
||||
public:
|
||||
WRL1MATERIAL( NAMEREGISTER* aDictionary );
|
||||
WRL1MATERIAL( NAMEREGISTER* aDictionary, WRL1NODE* aParent );
|
||||
virtual ~WRL1MATERIAL();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
/**
|
||||
* Function GetAppearance
|
||||
* returns an SGAPPEARANCE node representing the appearance
|
||||
* for an IndexedFaceSet
|
||||
*/
|
||||
SGNODE* GetAppearance( int aIndex );
|
||||
|
||||
/**
|
||||
* Function GetColor
|
||||
* computes an SGCOLOR representing the appearance of a vertex or face
|
||||
*/
|
||||
void GetColor( SGCOLOR* aColor, int aIndex );
|
||||
|
||||
/**
|
||||
* Function Reclaim
|
||||
* will destroy the given color node if it does not have a parent
|
||||
*/
|
||||
void Reclaim( SGNODE* aColor );
|
||||
};
|
||||
|
||||
#endif // VRML1_MATERIAL_H
|
||||
|
|
|
@ -88,11 +88,6 @@ typedef std::map< std::string, WRL1NODES > NODEMAP;
|
|||
static NODEMAP nodenames;
|
||||
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
std::string WRL1NODE::tabs = "";
|
||||
#endif
|
||||
|
||||
|
||||
WRL1NODE::WRL1NODE( NAMEREGISTER* aDictionary )
|
||||
{
|
||||
m_sgNode = nullptr;
|
||||
|
@ -143,15 +138,10 @@ WRL1NODE::WRL1NODE( NAMEREGISTER* aDictionary )
|
|||
|
||||
WRL1NODE::~WRL1NODE()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] ^^ Destroying Type " << m_Type << " 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] ^^ Destroying Type %d with %ul children, %ul references, and %ul "
|
||||
"back pointers." ),
|
||||
m_Type, m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
|
||||
m_Items.clear();
|
||||
|
||||
|
@ -164,30 +154,18 @@ WRL1NODE::~WRL1NODE()
|
|||
std::list< WRL1NODE* >::iterator sBP = m_BackPointers.begin();
|
||||
std::list< WRL1NODE* >::iterator eBP = m_BackPointers.end();
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
int acc = 0;
|
||||
#endif
|
||||
|
||||
while( sBP != eBP )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
++acc;
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] " << tabs << "Type " << m_Type << " is Unlinking ref #";
|
||||
ostr << acc;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d is unlinking ref #%d" ),
|
||||
wxString( ' ', (size_t) std::distance( sBP, m_BackPointers.begin() ) * 2 ),
|
||||
m_Type, std::distance( sBP, m_BackPointers.begin() ) );
|
||||
|
||||
(*sBP)->unlinkRefNode( this );
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] " << tabs << "Type " << m_Type << " has unlinked ref #";
|
||||
ostr << acc;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d has unlinked ref #%d" ),
|
||||
wxString( ' ', (size_t) std::distance( sBP, m_BackPointers.begin() ) * 2 ),
|
||||
m_Type, std::distance( sBP, m_BackPointers.begin() ) );
|
||||
|
||||
++sBP;
|
||||
}
|
||||
|
||||
|
@ -196,53 +174,23 @@ WRL1NODE::~WRL1NODE()
|
|||
std::list< WRL1NODE* >::iterator sC = m_Children.begin();
|
||||
std::list< WRL1NODE* >::iterator eC = m_Children.end();
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
std::string otabs = tabs;
|
||||
tabs.append( " " );
|
||||
#endif
|
||||
|
||||
while( sC != eC )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
++acc;
|
||||
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] " << otabs << "Type " << m_Type << " is Deleting child #";
|
||||
ostr << acc;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
(*sC)->SetParent( nullptr, false );
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] " << otabs << "Type " << m_Type << " has unlinked child #";
|
||||
ostr << acc;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d has unlinked child #%d" ),
|
||||
wxString( ' ', (size_t) std::distance( sC, m_Children.begin() ) * 2 ),
|
||||
m_Type, std::distance( sC, m_Children.begin() ) );
|
||||
|
||||
delete *sC;
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] " << otabs << "Type " << m_Type << " has deleted child #";
|
||||
ostr << acc;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d has deleted child #%d" ),
|
||||
wxString( ' ', (size_t) std::distance( sC, m_Children.begin() ) * 2 ),
|
||||
m_Type, std::distance( sC, m_Children.begin() ) );
|
||||
|
||||
++sC;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
tabs = otabs;
|
||||
#endif
|
||||
|
||||
m_Children.clear();
|
||||
}
|
||||
|
||||
|
@ -288,8 +236,8 @@ void WRL1NODE::addNodeRef( WRL1NODE* aNode )
|
|||
|
||||
void WRL1NODE::delNodeRef( WRL1NODE* aNode )
|
||||
{
|
||||
std::list< WRL1NODE* >::iterator np =
|
||||
std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
|
||||
std::list< WRL1NODE* >::iterator np = std::find( m_BackPointers.begin(),
|
||||
m_BackPointers.end(), aNode );
|
||||
|
||||
if( np != m_BackPointers.end() )
|
||||
{
|
||||
|
@ -297,14 +245,9 @@ void WRL1NODE::delNodeRef( WRL1NODE* aNode )
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] delNodeRef() did not find its target";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [BUG] delNodeRef() did not find its target." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,14 +276,9 @@ bool WRL1NODE::SetName( const std::string& aName )
|
|||
|
||||
if( isdigit( aName[0] ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid node name '" << aName << "' (begins with digit)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid node name '%s' (begins with digit)" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aName );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -354,15 +292,10 @@ bool WRL1NODE::SetName( const std::string& aName )
|
|||
if( std::string::npos != aName.find_first_of( BAD_CHARS1 )
|
||||
|| std::string::npos != aName.find_first_of( BAD_CHARS2 ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid node name '" << aName;
|
||||
ostr << "' (contains invalid character)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid node name '%s' (contains invalid character)" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aName );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -442,19 +375,9 @@ bool WRL1NODE::SetParent( WRL1NODE* aParent, bool doUnlink )
|
|||
|
||||
bool WRL1NODE::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
if( aNode->GetNodeType() == WRL1NODES::WRL1_BASE )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] attempting to add a base node to another node";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
|
||||
wxCHECK_MSG( aNode->GetNodeType() != WRL1NODES::WRL1_BASE, false,
|
||||
wxT( "Attempting to add a base node to another node." ) );
|
||||
|
||||
std::list< WRL1NODE* >::iterator sC = m_Children.begin();
|
||||
std::list< WRL1NODE* >::iterator eC = m_Children.end();
|
||||
|
@ -479,33 +402,9 @@ bool WRL1NODE::AddChildNode( WRL1NODE* aNode )
|
|||
|
||||
bool WRL1NODE::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( aNode->GetNodeType() == WRL1NODES::WRL1_BASE )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] attempting to add a base node ref to another base node";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
|
||||
wxCHECK_MSG( aNode->GetNodeType() != WRL1NODES::WRL1_BASE, false,
|
||||
wxT( "Attempt to add a base node reference to another base node" ) );
|
||||
|
||||
// note: the VRML1 spec does not prevent the reuse of a node at
|
||||
// the same level; for example a Coordinate3 node can be recalled
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
/**
|
||||
* @file vrmlv1_node.h
|
||||
* defines the base class for VRML1.0 nodes
|
||||
* Define the base class for VRML1.0 nodes.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -43,16 +43,16 @@
|
|||
|
||||
class WRL1NODE;
|
||||
|
||||
// a class to hold the dictionary of node DEFs
|
||||
// The dictionary of node DEFs
|
||||
class NAMEREGISTER
|
||||
{
|
||||
private:
|
||||
std::map< std::string, WRL1NODE* > reg;
|
||||
|
||||
public:
|
||||
bool AddName( const std::string& aName, WRL1NODE* aNode );
|
||||
bool DelName( const std::string& aName, WRL1NODE* aNode );
|
||||
WRL1NODE* FindName( const std::string& aName );
|
||||
|
||||
private:
|
||||
std::map< std::string, WRL1NODE* > reg;
|
||||
};
|
||||
|
||||
|
||||
|
@ -62,10 +62,28 @@ class WRL1COORDS;
|
|||
class SGNODE;
|
||||
|
||||
|
||||
// current settings which may affect all subsequent nodes
|
||||
// during translation / rendering
|
||||
// current settings which may affect all subsequent nodes during translation / rendering
|
||||
struct WRL1STATUS
|
||||
{
|
||||
WRL1STATUS()
|
||||
{
|
||||
Init();
|
||||
return;
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
mat = nullptr;
|
||||
matbind = WRL1_BINDING::BIND_OVERALL;
|
||||
norm = nullptr;
|
||||
normbind = WRL1_BINDING::BIND_DEFAULT;
|
||||
coord = nullptr;
|
||||
txmatrix = glm::scale( glm::mat4( 1.0 ), glm::vec3( 1.0 ) );
|
||||
order = WRL1_ORDER::ORD_UNKNOWN;
|
||||
creaseLimit = 0.878f;
|
||||
return;
|
||||
}
|
||||
|
||||
// material
|
||||
WRL1MATERIAL* mat;
|
||||
|
||||
|
@ -89,38 +107,15 @@ struct WRL1STATUS
|
|||
|
||||
// cos( creaseAngle ) defines a boundary for normals smoothing
|
||||
float creaseLimit;
|
||||
|
||||
WRL1STATUS()
|
||||
{
|
||||
Init();
|
||||
return;
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
mat = nullptr;
|
||||
matbind = WRL1_BINDING::BIND_OVERALL;
|
||||
norm = nullptr;
|
||||
normbind = WRL1_BINDING::BIND_DEFAULT;
|
||||
coord = nullptr;
|
||||
txmatrix = glm::scale( glm::mat4( 1.0 ), glm::vec3( 1.0 ) );
|
||||
order = WRL1_ORDER::ORD_UNKNOWN;
|
||||
creaseLimit = 0.878f;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The base class of all VRML1 nodes
|
||||
* The base class of all VRML1 nodes.
|
||||
*/
|
||||
class WRL1NODE
|
||||
{
|
||||
public:
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
static std::string tabs;
|
||||
#endif
|
||||
|
||||
// cancel the dictionary pointer; for internal use only
|
||||
void cancelDict( void );
|
||||
|
||||
|
@ -163,7 +158,6 @@ public:
|
|||
*/
|
||||
void delNodeRef( WRL1NODE* aNode );
|
||||
|
||||
public:
|
||||
WRL1NODE( NAMEREGISTER* aDictionary );
|
||||
virtual ~WRL1NODE();
|
||||
|
||||
|
|
|
@ -50,66 +50,34 @@ WRL1SEPARATOR::WRL1SEPARATOR( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1SEPARATOR::~WRL1SEPARATOR()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying Separator 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Separator with %ul children %ul references, and %ul "
|
||||
"back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -124,19 +92,11 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
break;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -152,30 +112,12 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Separator with " << m_Children.size();
|
||||
ostr << " children, " << m_Refs.size() << " references and ";
|
||||
ostr << m_BackPointers.size() << " backpointers (total ";
|
||||
ostr << m_Items.size() << " items)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxCHECK_MSG( m_Parent, nullptr, wxT( "Separator has no parent." ) );
|
||||
|
||||
if( !m_Parent )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Separator has no parent";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Separator with %ul children, %ul references, and "
|
||||
"%ul back pointers (%ul total items)." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size(), m_Items.size() );
|
||||
|
||||
if( sp != nullptr )
|
||||
m_current = *sp;
|
||||
|
@ -184,20 +126,9 @@ SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Separator does not have a Transform parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
|
||||
wxString::Format( wxT( "Separator does not have a Transform parent (parent "
|
||||
"ID: %d)." ), ptype ) );
|
||||
|
||||
IFSG_TRANSFORM txNode( aParent );
|
||||
bool hasContent = false;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -34,9 +35,6 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1SEPARATOR
|
||||
*/
|
||||
class WRL1SEPARATOR : public WRL1NODE
|
||||
{
|
||||
public:
|
||||
|
@ -44,7 +42,6 @@ public:
|
|||
WRL1SEPARATOR( NAMEREGISTER* aDictionary, WRL1NODE* aNode );
|
||||
virtual ~WRL1SEPARATOR();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
};
|
||||
|
|
|
@ -56,92 +56,47 @@ WRL1SHAPEHINTS::WRL1SHAPEHINTS( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1SHAPEHINTS::~WRL1SHAPEHINTS()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying ShapeHints node\n" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying ShapeHints node." );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1SHAPEHINTS::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1SHAPEHINTS::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s.\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition(),
|
||||
proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -159,14 +114,9 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -181,36 +131,33 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !glob.compare( "UNKNOWN_ORDERING" ) )
|
||||
{
|
||||
m_order = WRL1_ORDER::ORD_UNKNOWN;
|
||||
}
|
||||
else if( !glob.compare( "CLOCKWISE" ) )
|
||||
{
|
||||
m_order = WRL1_ORDER::ORD_CLOCKWISE;
|
||||
}
|
||||
else if( !glob.compare( "COUNTERCLOCKWISE" ) )
|
||||
{
|
||||
m_order = WRL1_ORDER::ORD_CCW;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad ShapeHints at line " << line << ", column ";
|
||||
ostr << column << " (invalid value '" << glob << "')\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad ShapeHints %s (invalid value '%s')\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), glob,
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -219,14 +166,9 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -239,14 +181,9 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -261,14 +198,9 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadSFFloat( tmp ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -282,16 +214,12 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad ShapeHints at line " << line << ", column ";
|
||||
ostr << column << " (unexpected keyword '" << glob << "')\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad ShapeHints %s (unexpected keyword '%s')\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), glob,
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -305,13 +233,7 @@ SGNODE* WRL1SHAPEHINTS::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
{
|
||||
// note: this is not fully implemented since it is unlikely we shall
|
||||
// ever make use of the fields shapeType, faceType, and creaseAngle
|
||||
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( sp, nullptr, wxT( "Invalid base data." ) );
|
||||
|
||||
sp->order = m_order;
|
||||
sp->creaseLimit = cosf(m_crease);
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -35,25 +36,21 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1SHAPEHINTS
|
||||
*/
|
||||
class WRL1SHAPEHINTS : public WRL1NODE
|
||||
{
|
||||
private:
|
||||
WRL1_ORDER m_order; // vertex order
|
||||
float m_crease; // VRML creaseAngle
|
||||
|
||||
public:
|
||||
WRL1SHAPEHINTS( NAMEREGISTER* aDictionary );
|
||||
WRL1SHAPEHINTS( NAMEREGISTER* aDictionary, WRL1NODE* aParent );
|
||||
virtual ~WRL1SHAPEHINTS();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
private:
|
||||
WRL1_ORDER m_order; // vertex order
|
||||
float m_crease; // VRML creaseAngle
|
||||
};
|
||||
|
||||
#endif // VRML1_SHAPEHINTS_H
|
||||
|
|
|
@ -53,15 +53,10 @@ WRL1SWITCH::WRL1SWITCH( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
WRL1SWITCH::~WRL1SWITCH()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying Switch 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Switch node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,52 +71,27 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
* }
|
||||
*/
|
||||
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s.\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition(),
|
||||
proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -142,14 +112,9 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -158,17 +123,13 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFInt( whichChild ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid whichChild 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid whichChild %s (invalid value '%s')\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), glob,
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -176,33 +137,22 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
continue;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid Switch at line " << line << ", column ";
|
||||
ostr << column << " (expected 'whichChild')\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Switch %s (unexpected 'whichChild')\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s."),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -218,16 +168,10 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL1SWITCH::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Switch with " << m_Children.size();
|
||||
ostr << " children, " << m_Refs.size() << " references and ";
|
||||
ostr << m_BackPointers.size() << " backpointers (total ";
|
||||
ostr << m_Items.size() << " items)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Switch node with %ul children, %ul"
|
||||
"references, and %ul back pointers (%ul total items)." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size(), m_Items.size() );
|
||||
|
||||
if( m_Items.empty() )
|
||||
return nullptr;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -34,22 +35,18 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1SWITCH
|
||||
*/
|
||||
class WRL1SWITCH : public WRL1NODE
|
||||
{
|
||||
private:
|
||||
int whichChild;
|
||||
|
||||
public:
|
||||
WRL1SWITCH( NAMEREGISTER* aDictionary );
|
||||
WRL1SWITCH( NAMEREGISTER* aDictionary, WRL1NODE* aNode );
|
||||
virtual ~WRL1SWITCH();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
private:
|
||||
int whichChild;
|
||||
};
|
||||
|
||||
#endif // VRML1_SWITCH_H
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
WRL1TRANSFORM::WRL1TRANSFORM( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary )
|
||||
{
|
||||
m_Type = WRL1NODES::WRL1_TRANSFORM;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,22 +45,15 @@ WRL1TRANSFORM::WRL1TRANSFORM( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|||
|
||||
if( nullptr != m_Parent )
|
||||
m_Parent->AddChildNode( this );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WRL1TRANSFORM::~WRL1TRANSFORM()
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Transform node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,19 +71,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
* }
|
||||
*/
|
||||
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML1
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
center.x = 0.0;
|
||||
center.y = 0.0;
|
||||
|
@ -110,38 +90,23 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
scale.y = 1.0;
|
||||
scale.z = 1.0;
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -159,14 +124,9 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -178,23 +138,16 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
// ScaleOrientation
|
||||
// translation
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "center" ) )
|
||||
{
|
||||
if( !proc.ReadSFVec3f( center ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid center %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -208,17 +161,12 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFRotation( rotation ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid rotation %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -227,17 +175,12 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( scale ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid scale %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -246,17 +189,12 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFRotation( scaleOrientation ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid scaleOrientation %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -265,17 +203,12 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( translation ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid translation %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -287,16 +220,11 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid Transform %s\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -309,34 +237,14 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|||
bool WRL1TRANSFORM::AddRefNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable" ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL1TRANSFORM::AddChildNode( WRL1NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML1
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -348,12 +256,7 @@ SGNODE* WRL1TRANSFORM::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
|||
if( WRL1NODES::WRL1_BASE == m_Parent->GetNodeType() )
|
||||
return nullptr;
|
||||
|
||||
if( nullptr == sp )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given" );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( sp, nullptr, wxT( "Bad model: no base data given" ) );
|
||||
|
||||
// rotation
|
||||
float rX, rY, rZ, rW;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -34,28 +35,24 @@
|
|||
class WRL1BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL1TRANSFORM
|
||||
*/
|
||||
class WRL1TRANSFORM : public WRL1NODE
|
||||
{
|
||||
public:
|
||||
WRL1TRANSFORM( NAMEREGISTER* aDictionary );
|
||||
WRL1TRANSFORM( NAMEREGISTER* aDictionary, WRL1NODE* aNode );
|
||||
virtual ~WRL1TRANSFORM();
|
||||
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
|
||||
private:
|
||||
WRLVEC3F center;
|
||||
WRLVEC3F scale;
|
||||
WRLVEC3F translation;
|
||||
WRLROTATION rotation;
|
||||
WRLROTATION scaleOrientation;
|
||||
|
||||
public:
|
||||
WRL1TRANSFORM( NAMEREGISTER* aDictionary );
|
||||
WRL1TRANSFORM( NAMEREGISTER* aDictionary, WRL1NODE* aNode );
|
||||
virtual ~WRL1TRANSFORM();
|
||||
|
||||
// functions inherited from WRL1NODE
|
||||
bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL1NODE* aNode ) override;
|
||||
bool AddChildNode( WRL1NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) override;
|
||||
};
|
||||
|
||||
#endif // VRML1_TRANSFORM_H
|
||||
|
|
|
@ -56,15 +56,10 @@ WRL2APPEARANCE::WRL2APPEARANCE( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2APPEARANCE::~WRL2APPEARANCE()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying Appearance 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Appearance node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +86,6 @@ bool WRL2APPEARANCE::checkNodeType( WRL2NODES aType )
|
|||
bool WRL2APPEARANCE::isDangling( void )
|
||||
{
|
||||
// this node is dangling unless it has a parent of type WRL2_SHAPE
|
||||
|
||||
if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE )
|
||||
return true;
|
||||
|
||||
|
@ -101,33 +95,16 @@ bool WRL2APPEARANCE::isDangling( void )
|
|||
|
||||
bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -136,14 +113,10 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != material )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple material nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple material nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -156,14 +129,10 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != textureTransform )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple textureTransform nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple textureTransform nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -174,14 +143,10 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
if( nullptr != texture )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple texture nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple texture nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -193,33 +158,16 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -228,14 +176,10 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != material )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple material nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple material nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -248,14 +192,10 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != textureTransform )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple textureTransform nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple textureTransform nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -266,14 +206,10 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
if( nullptr != texture )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple texture nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple texture nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -285,52 +221,25 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -348,14 +257,9 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -365,20 +269,14 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// texture
|
||||
// textureTransform
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "material" ) )
|
||||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read material information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read material information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -387,14 +285,10 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read texture information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read texture information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -403,30 +297,21 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read textureTransform information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read textureTransform information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Appearance at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad Appearance %s.\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -443,30 +328,14 @@ SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent )
|
|||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Appearance does not have a Shape parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
|
||||
wxString::Format( wxT( " * [BUG] Appearance does not have a Shape parent "
|
||||
"(parent ID: %d)." ), ptype ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Appearance 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Appearance node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
|
||||
if( m_sgNode )
|
||||
{
|
||||
|
@ -494,6 +363,7 @@ SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent )
|
|||
matNode.SetEmissive( 0.0f, 0.0f, 0.0f );
|
||||
matNode.SetSpecular( 0.65f, 0.65f, 0.65f );
|
||||
matNode.SetDiffuse( 0.65f, 0.65f, 0.65f );
|
||||
|
||||
// default ambient
|
||||
matNode.SetShininess( 0.2f );
|
||||
matNode.SetTransparency( 0.0f );
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,41 +35,32 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2APPEARANCE
|
||||
*/
|
||||
class WRL2APPEARANCE : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
WRL2NODE* material;
|
||||
WRL2NODE* texture;
|
||||
WRL2NODE* textureTransform;
|
||||
|
||||
/**
|
||||
* Function checkNodeType
|
||||
* returns true if the node type is a material description class
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
// overloads
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2APPEARANCE();
|
||||
WRL2APPEARANCE( WRL2NODE* aParent );
|
||||
virtual ~WRL2APPEARANCE();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Return true if the node type is a material description class.
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
WRL2NODE* material;
|
||||
WRL2NODE* texture;
|
||||
WRL2NODE* textureTransform;
|
||||
};
|
||||
|
||||
#endif // VRML2_APPEARANCE_H
|
||||
|
|
|
@ -78,16 +78,7 @@ WRL2BASE::~WRL2BASE()
|
|||
|
||||
bool WRL2BASE::SetParent( WRL2NODE* aParent, bool /* doUnlink */ )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "Attempt to set parent on WRL2BASE node." ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,49 +150,20 @@ SGNODE* WRL2BASE::GetInlineData( const std::string& aName )
|
|||
|
||||
std::string WRL2BASE::GetName( void )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return std::string( "" );
|
||||
wxCHECK_MSG( false, std::string( "" ), wxT( "Attempt to extract name from base node." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2BASE::SetName( const std::string& aName )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "Attempt to set name of base node." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2BASE::Read( WRLPROC& proc )
|
||||
{
|
||||
if( proc.GetVRMLType() != WRLVERSION::VRML_V2 )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( proc.GetVRMLType() == WRLVERSION::VRML_V2, false,
|
||||
wxT( "No open file or file is not a VRML2 file." ) );
|
||||
|
||||
WRL2NODE* node = nullptr;
|
||||
m_dir = proc.GetParentDir();
|
||||
|
@ -227,32 +189,15 @@ bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode
|
|||
if( nullptr != aNode )
|
||||
*aNode = nullptr;
|
||||
|
||||
if( !aParent )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
|
||||
|
||||
std::string glob;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -262,30 +207,20 @@ bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode
|
|||
// return 'true' - the file may be defective but it may still be somewhat OK
|
||||
if( nullptr == ref )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] node '%s' not found." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, glob );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !aParent->AddRefNode( ref ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] failed to add node '%s' (%d) to parent of type %d" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, glob, ref->GetNodeType(),
|
||||
aParent->GetNodeType() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -302,40 +237,20 @@ bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode
|
|||
if( nullptr != aNode )
|
||||
*aNode = nullptr;
|
||||
|
||||
if( nullptr == aParent )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
|
||||
|
||||
std::string glob;
|
||||
WRL2NODE* lnode = nullptr;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( ReadNode( proc, aParent, &lnode ) )
|
||||
{
|
||||
if( nullptr != aNode )
|
||||
|
@ -343,17 +258,10 @@ bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode
|
|||
|
||||
if( lnode && !lnode->SetName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad formatting (invalid name) %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -376,34 +284,16 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
if( nullptr != aNode )
|
||||
*aNode = nullptr;
|
||||
|
||||
if( nullptr == aParent )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
|
||||
|
||||
std::string glob;
|
||||
WRL2NODES ntype;
|
||||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
if( !proc.eof() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
}
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -423,14 +313,9 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
{
|
||||
if( !implementUse( proc, aParent, aNode ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -442,14 +327,9 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
{
|
||||
if( !implementDef( proc, aParent, aNode ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -462,14 +342,9 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
{
|
||||
if( !proc.ReadName( glob ) || !proc.DiscardList() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -482,14 +357,9 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
{
|
||||
if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -502,14 +372,9 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
{
|
||||
if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -518,17 +383,8 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
}
|
||||
|
||||
ntype = getNodeTypeID( glob );
|
||||
size_t line = 0;
|
||||
size_t column = 0;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Processing node '%s' ID: %d" ), glob, ntype );
|
||||
|
||||
switch( ntype )
|
||||
{
|
||||
|
@ -560,28 +416,16 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
// XXX - IMPLEMENT
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_VRML2
|
||||
else
|
||||
{
|
||||
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 );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
|
@ -596,26 +440,16 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
// XXX - IMPLEMENT
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_VRML2
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
||||
ostr << line << ", c" << column;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
|
@ -623,28 +457,16 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
// XXX - IMPLEMENT
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_VRML2
|
||||
else
|
||||
{
|
||||
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 );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
|
@ -652,26 +474,16 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
// XXX - IMPLEMENT
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_VRML2
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
||||
ostr << line << ", c" << column;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
|
@ -721,26 +533,16 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
// XXX - IMPLEMENT
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_VRML2
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] OK: discard " << glob << " node at l";
|
||||
ostr << line << ", c" << column;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
|
@ -807,32 +609,18 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
case WRL2NODES::WRL2_INVALID:
|
||||
default:
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !proc.DiscardNode() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG_VRML2
|
||||
else
|
||||
{
|
||||
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() );
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
|
||||
glob, proc.GetFilePosition() );
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -843,18 +631,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
|
||||
bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
// this function makes no sense in the base node
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "This method must never be invoked on a WRL2BASE object." ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1105,22 +882,10 @@ bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
|
||||
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 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard in line node %s." ),
|
||||
proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1150,20 +915,9 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent )
|
|||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
|
||||
wxString::Format( wxT( " * [BUG] WRL2BASE does not have a Transform parent "
|
||||
"(parent ID: %d)." ), ptype ) );
|
||||
|
||||
if( m_sgNode )
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -53,15 +54,37 @@ class SGNODE;
|
|||
class WRL2INLINE;
|
||||
|
||||
/**
|
||||
* WRL2BASE
|
||||
* represents the top node of a VRML2 model
|
||||
* The top node of a VRML2 model.
|
||||
*/
|
||||
class WRL2BASE : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
bool m_useInline;
|
||||
std::string m_dir; // parent directory of the file
|
||||
public:
|
||||
WRL2BASE();
|
||||
virtual ~WRL2BASE();
|
||||
|
||||
// function to enable/disable Inline{} expansion
|
||||
void SetEnableInline( bool enable );
|
||||
bool GetEnableInline( void );
|
||||
|
||||
// function to manipulate Inline{} objects
|
||||
SGNODE* GetInlineData( const std::string& aName );
|
||||
|
||||
// function to read entire VRML file
|
||||
bool Read( WRLPROC& proc );
|
||||
|
||||
// read in a VRML node
|
||||
bool ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
|
||||
|
||||
virtual std::string GetName( void ) override;
|
||||
virtual bool SetName( const std::string& aName ) override;
|
||||
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool SetParent( WRL2NODE* aParent, bool doUnlink = true ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
// handle cases of USE / DEF
|
||||
bool implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
|
||||
bool implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
|
||||
|
@ -80,38 +103,9 @@ private:
|
|||
bool readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
|
||||
bool readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
|
||||
|
||||
bool m_useInline;
|
||||
std::string m_dir; // parent directory of the file
|
||||
std::map< std::string, SGNODE* > m_inlineModels;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2BASE();
|
||||
virtual ~WRL2BASE();
|
||||
|
||||
// function to enable/disable Inline{} expansion
|
||||
void SetEnableInline( bool enable );
|
||||
bool GetEnableInline( void );
|
||||
|
||||
// functions to manipulate Inline{} objects
|
||||
SGNODE* GetInlineData( const std::string& aName );
|
||||
|
||||
// function to read entire VRML file
|
||||
bool Read( WRLPROC& proc );
|
||||
|
||||
// read in a VRML node
|
||||
bool ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
|
||||
|
||||
// overrides
|
||||
virtual std::string GetName( void ) override;
|
||||
virtual bool SetName( const std::string& aName ) override;
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool SetParent( WRL2NODE* aParent, bool doUnlink = true ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
};
|
||||
|
||||
#endif // VRML2_BASE_H
|
||||
|
|
|
@ -56,7 +56,7 @@ WRL2BOX::WRL2BOX( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2BOX::~WRL2BOX()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Box node" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Box node." );
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,38 +73,23 @@ bool WRL2BOX::isDangling( void )
|
|||
|
||||
bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -120,36 +105,24 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
// expecting 'size'
|
||||
if( !glob.compare( "size" ) )
|
||||
{
|
||||
if( !proc.ReadSFVec3f( size ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid size 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid size %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -159,32 +132,24 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Box at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid Box %s\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( size.x < 1e-6 || size.y < 1e-6 || size.z < 1e-6 )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Box (invalid size) at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid Box size %s\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
/// @note If this box is bad, should false be returned here?
|
||||
}
|
||||
|
||||
if( proc.Peek() == '}' )
|
||||
|
@ -193,18 +158,10 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
return true;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Box at line " << line << ", column ";
|
||||
ostr << column << " (no closing brace)\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid size %s (no closing brace).\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -213,34 +170,14 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
bool WRL2BOX::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2BOX::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -248,20 +185,9 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent )
|
|||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Box does not have a Shape parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
|
||||
wxString::Format( wxT( "Box does not have a Shape parent (parent ID: %s)" ),
|
||||
ptype ) );
|
||||
|
||||
// do not render a bad box
|
||||
if( size.x < 1e-6 || size.y < 1e-6 || size.z < 1e-6 )
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,29 +35,22 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2BOX
|
||||
*/
|
||||
class WRL2BOX : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
WRLVEC3F size;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2BOX();
|
||||
WRL2BOX( WRL2NODE* aParent );
|
||||
virtual ~WRL2BOX();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
WRLVEC3F size;
|
||||
};
|
||||
|
||||
#endif // VRML2_BOX_H
|
||||
|
|
|
@ -49,14 +49,13 @@ WRL2COLOR::WRL2COLOR( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2COLOR::~WRL2COLOR()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Color node" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Color node" );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2COLOR::isDangling( void )
|
||||
{
|
||||
// this node is dangling unless it has a parent of type WRL2_INDEXEDFACESET
|
||||
|
||||
if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET )
|
||||
return true;
|
||||
|
||||
|
@ -67,71 +66,36 @@ bool WRL2COLOR::isDangling( void )
|
|||
bool WRL2COLOR::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2COLOR::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -147,52 +111,34 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
// expecting 'color'
|
||||
if( !glob.compare( "color" ) )
|
||||
{
|
||||
if( !proc.ReadMFVec3f( colors ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid color set 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid color set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Color at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Color %s\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -203,18 +149,10 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
return true;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Color at line " << line << ", column ";
|
||||
ostr << column << " (no closing brace)\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Color %s (no closing brace)\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,47 +37,37 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2COLOR
|
||||
*/
|
||||
class WRL2COLOR : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
std::vector< WRLVEC3F > colors;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2COLOR();
|
||||
WRL2COLOR( WRL2NODE* aParent );
|
||||
virtual ~WRL2COLOR();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
* returns true if the color set is non-empty
|
||||
* @return true if the color set is non-empty.
|
||||
*/
|
||||
bool HasColors( void );
|
||||
|
||||
/**
|
||||
* Function GetColor
|
||||
* retrieves the given color (or default 0.8, 0.8, 0.8 if index is invalid)
|
||||
* Retrieve the given color (or default 0.8, 0.8, 0.8 if index is invalid).
|
||||
*/
|
||||
void GetColor( int aIndex, float& red, float& green, float& blue );
|
||||
|
||||
/**
|
||||
* Function GetColors
|
||||
* retrieves the current list of colors
|
||||
* Retrieve the current list of colors.
|
||||
*/
|
||||
void GetColors( WRLVEC3F*& aColorList, size_t& aListSize);
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
std::vector< WRLVEC3F > colors;
|
||||
};
|
||||
|
||||
#endif // VRML2_COLOR_H
|
||||
|
|
|
@ -49,7 +49,7 @@ WRL2COORDS::WRL2COORDS( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2COORDS::~WRL2COORDS()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate node" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Coordinate node." );
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,71 +67,36 @@ bool WRL2COORDS::isDangling( void )
|
|||
bool WRL2COORDS::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2COORDS::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable\n";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -147,50 +112,34 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
// expecting 'point'
|
||||
if( !glob.compare( "point" ) )
|
||||
{
|
||||
if( !proc.ReadMFVec3f( points ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid point set 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid Coordinate point set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Coordinate at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid Coordinate %s\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -214,18 +163,10 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
return true;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Coordinate at line " << line << ", column ";
|
||||
ostr << column << " (no closing brace)\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d"
|
||||
" * [INFO] invalid Coordinate %s (no closing brace)\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,31 +37,24 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2COORDS
|
||||
*/
|
||||
class WRL2COORDS : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
std::vector< WRLVEC3F > points;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2COORDS();
|
||||
WRL2COORDS( WRL2NODE* aParent );
|
||||
virtual ~WRL2COORDS();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
void GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize );
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
std::vector< WRLVEC3F > points;
|
||||
};
|
||||
|
||||
#endif // VRML2_COORDS_H
|
||||
|
|
|
@ -55,15 +55,10 @@ WRL2FACESET::WRL2FACESET( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2FACESET::~WRL2FACESET()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying IndexedFaceSet 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying IndexedFaceSet node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -123,33 +118,16 @@ bool WRL2FACESET::isDangling( void )
|
|||
|
||||
bool WRL2FACESET::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -158,14 +136,10 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != color )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple color nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple color nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -178,14 +152,10 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple coordinate nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple coord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -198,14 +168,10 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != normal )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple normal nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple normal nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -214,30 +180,15 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode )
|
|||
return WRL2NODE::AddRefNode( aNode );
|
||||
}
|
||||
|
||||
if( WRL2NODES::WRL2_TEXTURECOORDINATE != type )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] unexpected code branch";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( WRL2NODES::WRL2_TEXTURECOORDINATE == type, false,
|
||||
wxT( "Unexpected code branch." ) );
|
||||
|
||||
if( nullptr != texCoord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple texCoord nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple texCoord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -249,33 +200,16 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2FACESET::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -284,14 +218,10 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != color )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple color nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple color nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -304,14 +234,10 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple coordinate nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple coord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -324,14 +250,10 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != normal )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple normal nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple normal nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -340,30 +262,15 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode )
|
|||
return WRL2NODE::AddChildNode( aNode );
|
||||
}
|
||||
|
||||
if( WRL2NODES::WRL2_TEXTURECOORDINATE != type )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] unexpected code branch";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( WRL2NODES::WRL2_TEXTURECOORDINATE == type, false,
|
||||
wxT( "Unexpected code branch." ) );
|
||||
|
||||
if( nullptr != texCoord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple texCoord nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple texCoord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -376,38 +283,23 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -425,14 +317,9 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -456,23 +343,16 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// [float]
|
||||
// creaseAngle
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "ccw" ) )
|
||||
{
|
||||
if( !proc.ReadSFBool( ccw ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid ccw 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid ccw %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -481,17 +361,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFBool( colorPerVertex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid colorPerVertex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid colorPerVertex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -500,17 +375,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFBool( convex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid convex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid convex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -519,17 +389,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFBool( normalPerVertex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid normalPerVertex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid normalPerVertex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -538,17 +403,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFBool( solid ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid solid 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid solid %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -557,17 +417,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFFloat( creaseAngle ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid creaseAngle at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'\n";
|
||||
ostr << " * [INFO] message: '" << proc.GetError() << "'\n";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid creaseAngle %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -583,17 +438,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( colorIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid colorIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid colorIndex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -602,17 +452,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( coordIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid coordIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid coordIndex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -621,17 +466,12 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( normalIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid normalIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid normalIndex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -640,14 +480,10 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read color node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read color node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -656,14 +492,10 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read coord node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read coord node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -672,14 +504,10 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read normal node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read normal node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -688,30 +516,22 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read texCoord node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read texCoord node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad IndexedFaceSet at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid IndexedFaceSet %s (no closing brace)\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -725,31 +545,14 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent )
|
|||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] IndexedFaceSet does not have a Shape parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
|
||||
wxString::Format( wxT( "IndexedFaceSet does not have a Shape parent (parent "
|
||||
"ID: %d)." ), ptype ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating IndexedFaceSet with " << m_Children.size();
|
||||
ostr << " children, " << m_Refs.size() << " references, ";
|
||||
ostr << m_BackPointers.size() << " backpointers and ";
|
||||
ostr << coordIndex.size() << " coord indices";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating IndexedFaceSet with %ul children, %ul references, "
|
||||
"%ul back pointers, and %ul coord indices." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size(), coordIndex.size() );
|
||||
|
||||
if( m_sgNode )
|
||||
{
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,12 +37,36 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2FACESET
|
||||
*/
|
||||
class WRL2FACESET : public WRL2NODE
|
||||
{
|
||||
public:
|
||||
WRL2FACESET();
|
||||
WRL2FACESET( WRL2NODE* aParent );
|
||||
virtual ~WRL2FACESET();
|
||||
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
/**
|
||||
* @return true if the face set has a color node.
|
||||
*/
|
||||
bool HasColors( void );
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @return true if the node type is a valid subnode of FaceSet.
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
WRL2NODE* color;
|
||||
WRL2NODE* coord;
|
||||
WRL2NODE* normal;
|
||||
|
@ -59,42 +84,6 @@ private:
|
|||
|
||||
float creaseAngle;
|
||||
float creaseLimit;
|
||||
|
||||
|
||||
/**
|
||||
* Function checkNodeType
|
||||
* returns true if the node type is a valid subnode of FaceSet
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
|
||||
// overloads
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
public:
|
||||
WRL2FACESET();
|
||||
WRL2FACESET( WRL2NODE* aParent );
|
||||
virtual ~WRL2FACESET();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
* returns true if the face set has a color node
|
||||
*/
|
||||
bool HasColors( void );
|
||||
};
|
||||
|
||||
#endif // VRML2_FACESET_H
|
||||
|
|
|
@ -53,7 +53,7 @@ WRL2INLINE::WRL2INLINE( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2INLINE::~WRL2INLINE()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Inline node\n" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Inline node." );
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,37 +70,23 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
return false;
|
||||
|
||||
m_VRML2Base = aTopNode;
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -119,36 +105,24 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
// expecting one of 'url', 'bboxCenter', 'bboxSize'
|
||||
if( !glob.compare( "url" ) )
|
||||
{
|
||||
if( !proc.ReadMFString( url ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid url 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid url %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -157,17 +131,12 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( bboxCenter ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid bboxCenter 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid bboxCenter %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -176,50 +145,35 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( bboxSize ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid bboxSize 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid bboxSize %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Inline at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Inline %s\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Inline at line " << line << ", column ";
|
||||
ostr << column << " (no closing brace)\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Inline %s (no closing brace)\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -228,32 +182,14 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
bool WRL2INLINE::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2INLINE::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable\n";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -269,20 +205,9 @@ SGNODE* WRL2INLINE::TranslateToSG( SGNODE* aParent )
|
|||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Inline does not have a Transform parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
|
||||
wxString::Format( wxT( " * [BUG] Appearance does not have a Transform parent "
|
||||
"(parent ID: %d)." ), ptype ) );
|
||||
|
||||
SGNODE* np = m_VRML2Base->GetInlineData( url.front() );
|
||||
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,32 +35,25 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2INLINE
|
||||
*/
|
||||
class WRL2INLINE : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
WRL2BASE* m_VRML2Base;
|
||||
std::vector< std::string > url;
|
||||
WRLVEC3F bboxCenter;
|
||||
WRLVEC3F bboxSize;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2INLINE();
|
||||
WRL2INLINE( WRL2NODE* aParent );
|
||||
virtual ~WRL2INLINE();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
WRL2BASE* m_VRML2Base;
|
||||
std::vector< std::string > url;
|
||||
WRLVEC3F bboxCenter;
|
||||
WRLVEC3F bboxSize;
|
||||
};
|
||||
|
||||
#endif // VRML2_INLINE_H
|
||||
|
|
|
@ -54,15 +54,10 @@ WRL2LINESET::WRL2LINESET( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2LINESET::~WRL2LINESET()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying IndexedLineSet 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying IndexedLineSet node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,33 +103,16 @@ bool WRL2LINESET::isDangling( void )
|
|||
|
||||
bool WRL2LINESET::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -143,14 +121,10 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != color )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple color nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple color nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -163,14 +137,10 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple coordinate nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple coord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -185,33 +155,16 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2LINESET::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -220,14 +173,10 @@ bool WRL2LINESET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != color )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple color nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple color nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -240,14 +189,10 @@ bool WRL2LINESET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple coordinate nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple coord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -263,38 +208,23 @@ bool WRL2LINESET::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -312,14 +242,9 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -334,23 +259,16 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// colorIndex
|
||||
// coordIndex
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "colorPerVertex" ) )
|
||||
{
|
||||
if( !proc.ReadSFBool( colorPerVertex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid colorPerVertex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid colorPerVertex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -359,17 +277,12 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( colorIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid colorIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid colorIndex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -378,17 +291,12 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadMFInt( coordIndex ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid coordIndex 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid coordIndex %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -397,14 +305,10 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read color node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read color node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -413,30 +317,22 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read coord node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read coord node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad IndexedLineSet at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid IndexedFaceSet %s\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,12 +37,36 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2LINESET
|
||||
*/
|
||||
class WRL2LINESET : public WRL2NODE
|
||||
{
|
||||
public:
|
||||
WRL2LINESET();
|
||||
WRL2LINESET( WRL2NODE* aParent );
|
||||
virtual ~WRL2LINESET();
|
||||
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
/**
|
||||
* @return true if the line set has a color node.
|
||||
*/
|
||||
bool HasColors( void );
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @return true if the node type is a valid subnode of LineSet.
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
WRL2NODE* color;
|
||||
WRL2NODE* coord;
|
||||
|
||||
|
@ -49,41 +74,6 @@ private:
|
|||
|
||||
std::vector< int > colorIndex;
|
||||
std::vector< int > coordIndex;
|
||||
|
||||
/**
|
||||
* Function checkNodeType
|
||||
* returns true if the node type is a valid subnode of LineSet
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
|
||||
// overloads
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
public:
|
||||
WRL2LINESET();
|
||||
WRL2LINESET( WRL2NODE* aParent );
|
||||
virtual ~WRL2LINESET();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
* returns true if the face set has a color node
|
||||
*/
|
||||
bool HasColors( void );
|
||||
};
|
||||
|
||||
#endif // VRML2_LINESET_H
|
||||
|
|
|
@ -52,7 +52,7 @@ WRL2MATERIAL::WRL2MATERIAL( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2MATERIAL::~WRL2MATERIAL()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Material node" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Material node." );
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,85 +89,38 @@ bool WRL2MATERIAL::isDangling( void )
|
|||
bool WRL2MATERIAL::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2MATERIAL::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -185,14 +138,9 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -205,23 +153,16 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// specularColor
|
||||
// transparency
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "specularColor" ) )
|
||||
{
|
||||
if( !proc.ReadSFVec3f( specularColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid specularColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid specularColor set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -230,17 +171,12 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( diffuseColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid diffuseColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid diffuseColor set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -249,17 +185,12 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( emissiveColor ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid emissiveColor 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid emissiveColor set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -268,17 +199,12 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFFloat( shininess ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid shininess 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid shininess set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -287,17 +213,12 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFFloat( transparency ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid transparency 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid transparency set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -306,33 +227,23 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFFloat( ambientIntensity ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid ambientIntensity 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid ambientIntensity set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Material at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Material %s.\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -346,30 +257,14 @@ SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent )
|
|||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Material does not have a Shape parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
|
||||
wxString::Format( wxT( "IndexedFaceSet does not have a Shape parent (parent "
|
||||
"ID: %d)." ), ptype ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Material 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating IndexedFaceSet with %ul children, %ul references, and"
|
||||
"%ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
|
||||
if( m_sgNode )
|
||||
{
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,36 +35,29 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2MATERIAL
|
||||
*/
|
||||
class WRL2MATERIAL : public WRL2NODE
|
||||
{
|
||||
public:
|
||||
WRL2MATERIAL();
|
||||
WRL2MATERIAL( WRL2NODE* aParent );
|
||||
virtual ~WRL2MATERIAL();
|
||||
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
void setDefaults( void );
|
||||
|
||||
WRLVEC3F diffuseColor;
|
||||
WRLVEC3F emissiveColor;
|
||||
WRLVEC3F specularColor;
|
||||
float ambientIntensity;
|
||||
float shininess;
|
||||
float transparency;
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2MATERIAL();
|
||||
WRL2MATERIAL( WRL2NODE* aParent );
|
||||
virtual ~WRL2MATERIAL();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
};
|
||||
|
||||
#endif // VRML2_MATERIAL_H
|
||||
|
|
|
@ -80,7 +80,8 @@ WRL2NODE::WRL2NODE()
|
|||
nodenames.insert( NODEITEM( "ColorInterpolator", WRL2NODES::WRL2_COLORINTERPOLATOR ) );
|
||||
nodenames.insert( NODEITEM( "Cone", WRL2NODES::WRL2_CONE ) );
|
||||
nodenames.insert( NODEITEM( "Coordinate", WRL2NODES::WRL2_COORDINATE ) );
|
||||
nodenames.insert( NODEITEM( "CoordinateInterpolator", WRL2NODES::WRL2_COORDINATEINTERPOLATOR ) );
|
||||
nodenames.insert( NODEITEM( "CoordinateInterpolator",
|
||||
WRL2NODES::WRL2_COORDINATEINTERPOLATOR ) );
|
||||
nodenames.insert( NODEITEM( "Cylinder", WRL2NODES::WRL2_CYLINDER ) );
|
||||
nodenames.insert( NODEITEM( "CylinderSensor", WRL2NODES::WRL2_CYLINDERSENSOR ) );
|
||||
nodenames.insert( NODEITEM( "DirectionalLight", WRL2NODES::WRL2_DIRECTIONALLIGHT ) );
|
||||
|
@ -194,14 +195,9 @@ void WRL2NODE::delNodeRef( WRL2NODE* aNode )
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] delNodeRef() did not find its target";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [BUG] delNodeRef() did not find its target." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,14 +228,10 @@ bool WRL2NODE::SetName( const std::string& aName )
|
|||
|
||||
if( item != badNames.end() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid node name '" << *item << "' (matches restricted word)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid node name '%s' (matches restricted word)" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, *item );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -247,14 +239,9 @@ bool WRL2NODE::SetName( const std::string& aName )
|
|||
|
||||
if( isdigit( aName[0] ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid node name '" << *item << "' (begins with digit)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid node name '%s' (begins with digit)" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aName );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -269,15 +256,10 @@ bool WRL2NODE::SetName( const std::string& aName )
|
|||
if( std::string::npos != aName.find_first_of( BAD_CHARS1 )
|
||||
|| std::string::npos != aName.find_first_of( BAD_CHARS2 ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid node name '" << aName;
|
||||
ostr << "' (contains invalid character)";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid node name '%s' (contains invalid character)" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aName );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -373,22 +355,10 @@ bool WRL2NODE::SetParent( WRL2NODE* aParent, bool doUnlink )
|
|||
|
||||
bool WRL2NODE::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( aNode == nullptr )
|
||||
return false;
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
|
||||
wxCHECK_MSG( aNode->GetNodeType() != WRL2NODES::WRL2_BASE, false,
|
||||
wxT( "Attempting to add a base node to another node." ) );
|
||||
|
||||
if( aNode->GetNodeType() == WRL2NODES::WRL2_BASE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] attempting to add a base node to another node";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list< WRL2NODE* >::iterator sC = m_Children.begin();
|
||||
std::list< WRL2NODE* >::iterator eC = m_Children.end();
|
||||
|
@ -412,33 +382,9 @@ bool WRL2NODE::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2NODE::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( aNode->GetNodeType() == WRL2NODES::WRL2_BASE )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] attempting to add a base node ref to another base node";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
|
||||
wxCHECK_MSG( aNode->GetNodeType() != WRL2NODES::WRL2_BASE, false,
|
||||
wxT( "Attempt to add a base node reference to another base node" ) );
|
||||
|
||||
std::list< WRL2NODE* >::iterator sR = m_Refs.begin();
|
||||
std::list< WRL2NODE* >::iterator eR = m_Refs.end();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
*
|
||||
|
@ -51,12 +52,119 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2NODE
|
||||
* represents the base class of all VRML2 nodes
|
||||
*/
|
||||
class WRL2NODE
|
||||
{
|
||||
public:
|
||||
WRL2NODE();
|
||||
virtual ~WRL2NODE();
|
||||
|
||||
// read data via the given file processor and WRL2BASE object
|
||||
virtual bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) = 0;
|
||||
|
||||
/**
|
||||
* @return the type of this node instance.
|
||||
*/
|
||||
WRL2NODES GetNodeType( void ) const;
|
||||
|
||||
/**
|
||||
* @return a pointer to the parent SGNODE of this object or NULL if the object has no
|
||||
* parent (ie. top level transform).
|
||||
*/
|
||||
WRL2NODE* GetParent( void ) const;
|
||||
|
||||
/**
|
||||
* Set the parent WRL2NODE of this object.
|
||||
*
|
||||
* @param aParent [in] is the desired parent node.
|
||||
* @param doUnlink indicates that the child must be unlinked from the parent
|
||||
* @return true if the operation succeeds of false if the given node is not allowed to be
|
||||
* a parent to the derived object.
|
||||
*/
|
||||
virtual bool SetParent( WRL2NODE* aParent, bool doUnlink = true );
|
||||
|
||||
virtual std::string GetName( void );
|
||||
virtual bool SetName( const std::string& aName );
|
||||
|
||||
const char* GetNodeTypeName( WRL2NODES aNodeType ) const;
|
||||
|
||||
/**
|
||||
* Search the tree of linked nodes and returns a reference to the first node found with
|
||||
* the given name. The reference is then typically added to another node via AddRefNode().
|
||||
*
|
||||
* @param aNodeName is the name of the node to search for.
|
||||
* @param aCaller is a pointer to the node invoking this function.
|
||||
* @return is a valid node pointer on success or NULL.
|
||||
*/
|
||||
virtual WRL2NODE* FindNode( const std::string& aNodeName, const WRL2NODE *aCaller );
|
||||
|
||||
virtual bool AddChildNode( WRL2NODE* aNode );
|
||||
|
||||
virtual bool AddRefNode( WRL2NODE* aNode );
|
||||
|
||||
std::string GetError( void );
|
||||
|
||||
/**
|
||||
* Produce a representation of the data using the intermediate scenegraph structures of the
|
||||
* kicad_3dsg library.
|
||||
*
|
||||
* @param aParent is a pointer to the parent SG node.
|
||||
* @return is non-NULL on success.
|
||||
*/
|
||||
virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
|
||||
|
||||
/**
|
||||
* @return The ID based on the given aNodeName or WRL2_INVALID (WRL2_END) if no such node
|
||||
* name exists.
|
||||
*/
|
||||
WRL2NODES getNodeTypeID( const std::string& aNodeName );
|
||||
|
||||
/**
|
||||
* Remove references to an owned child.
|
||||
*
|
||||
* It is invoked by the child upon destruction to ensure that the parent has no invalid
|
||||
* references.
|
||||
*
|
||||
* @param aNode is the child which is being deleted.
|
||||
*/
|
||||
virtual void unlinkChildNode( const WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Remove pointers to a referenced node.
|
||||
*
|
||||
* It is invoked by the referenced node upon destruction to ensure that the referring node
|
||||
* has no invalid references.
|
||||
*
|
||||
* @param aNode is the node which is being deleted.
|
||||
*/
|
||||
virtual void unlinkRefNode( const WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Add a pointer to a node which references but does not own this node.
|
||||
*
|
||||
* Such back-pointers are required to ensure that invalidated references are removed when
|
||||
* a node is deleted.
|
||||
*
|
||||
* @param aNode is the node holding a reference to this object.
|
||||
*/
|
||||
void addNodeRef( WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Remove a pointer to a node which references but does not own this node.
|
||||
*
|
||||
* @param aNode is the node holding a reference to this object
|
||||
*/
|
||||
void delNodeRef( WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Determine whether an object should be moved to a different parent during the VRML to
|
||||
* SG* translation.
|
||||
*
|
||||
* @return true if the object does not have a parent which is a logical
|
||||
* container for the object for example if a Shape has a parent which
|
||||
* is a Base node.
|
||||
*/
|
||||
virtual bool isDangling( void ) = 0;
|
||||
|
||||
protected:
|
||||
WRL2NODE* m_Parent; // pointer to parent node; may be NULL for top level node
|
||||
WRL2NODES m_Type; // type of VRML node
|
||||
|
@ -68,124 +176,6 @@ protected:
|
|||
std::string m_error;
|
||||
|
||||
SGNODE* m_sgNode; // the SGNODE representation of the display data
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Function getNodeTypeID
|
||||
* returns the ID based on the given aNodeName or WRL2_INVALID (WRL2_END)
|
||||
* if no such node name exists
|
||||
*/
|
||||
WRL2NODES getNodeTypeID( const std::string& aNodeName );
|
||||
|
||||
/**
|
||||
* Function unlinkChild
|
||||
* removes references to an owned child; it is invoked by the child upon destruction
|
||||
* to ensure that the parent has no invalid references.
|
||||
*
|
||||
* @param aNode is the child which is being deleted
|
||||
*/
|
||||
virtual void unlinkChildNode( const WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Function unlinkRef
|
||||
* removes pointers to a referenced node; it is invoked by the referenced node
|
||||
* upon destruction to ensure that the referring node has no invalid references.
|
||||
*
|
||||
* @param aNode is the node which is being deleted
|
||||
*/
|
||||
virtual void unlinkRefNode( const WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Function addNodeRef
|
||||
* adds a pointer to a node which references, but does not own, this node.
|
||||
* Such back-pointers are required to ensure that invalidated references
|
||||
* are removed when a node is deleted
|
||||
*
|
||||
* @param aNode is the node holding a reference to this object
|
||||
*/
|
||||
void addNodeRef( WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Function delNodeRef
|
||||
* removes a pointer to a node which references, but does not own, this node.
|
||||
*
|
||||
* @param aNode is the node holding a reference to this object
|
||||
*/
|
||||
void delNodeRef( WRL2NODE* aNode );
|
||||
|
||||
/**
|
||||
* Function isDangling
|
||||
* returns true if the object does not have a parent which is a logical
|
||||
* container for the object - for example if a Shape has a parent which
|
||||
* is a Base node. This function is used to determine whether an object
|
||||
* should be moved to a different parent during the VRML to SG* translation.
|
||||
*/
|
||||
virtual bool isDangling( void ) = 0;
|
||||
|
||||
public:
|
||||
WRL2NODE();
|
||||
virtual ~WRL2NODE();
|
||||
|
||||
// read data via the given file processor and WRL2BASE object
|
||||
virtual bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) = 0;
|
||||
|
||||
/**
|
||||
* Function GetNodeType
|
||||
* returns the type of this node instance
|
||||
*/
|
||||
WRL2NODES GetNodeType( void ) const;
|
||||
|
||||
/**
|
||||
* Function GetParent
|
||||
* returns a pointer to the parent SGNODE of this object
|
||||
* or NULL if the object has no parent (ie. top level transform)
|
||||
*/
|
||||
WRL2NODE* GetParent( void ) const;
|
||||
|
||||
/**
|
||||
* Function SetParent
|
||||
* sets the parent WRL2NODE of this object.
|
||||
*
|
||||
* @param aParent [in] is the desired parent node
|
||||
* @param doUnlink indicates that the child must be unlinked from the parent
|
||||
* @return true if the operation succeeds; false if
|
||||
* the given node is not allowed to be a parent to
|
||||
* the derived object.
|
||||
*/
|
||||
virtual bool SetParent( WRL2NODE* aParent, bool doUnlink = true );
|
||||
|
||||
virtual std::string GetName( void );
|
||||
virtual bool SetName( const std::string& aName );
|
||||
|
||||
const char* GetNodeTypeName( WRL2NODES aNodeType ) const;
|
||||
|
||||
/**
|
||||
* Function FindNode searches the tree of linked nodes and returns a
|
||||
* reference to the first node found with the given name. The reference
|
||||
* is then typically added to another node via AddRefNode().
|
||||
*
|
||||
* @param aNodeName is the name of the node to search for
|
||||
* @param aCaller is a pointer to the node invoking this function
|
||||
* @return is a valid node pointer on success, otherwise NULL
|
||||
*/
|
||||
virtual WRL2NODE* FindNode( const std::string& aNodeName, const WRL2NODE *aCaller );
|
||||
|
||||
virtual bool AddChildNode( WRL2NODE* aNode );
|
||||
|
||||
virtual bool AddRefNode( WRL2NODE* aNode );
|
||||
|
||||
std::string GetError( void );
|
||||
|
||||
/**
|
||||
* Function TranslateToSG
|
||||
* produces a representation of the data using the intermediate
|
||||
* scenegraph structures of the kicad_3dsg library.
|
||||
*
|
||||
* @param aParent is a pointer to the parent SG node
|
||||
* @return is non-NULL on success
|
||||
*/
|
||||
virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
|
||||
};
|
||||
|
||||
#endif // VRML2_NODE_H
|
||||
|
|
|
@ -49,7 +49,7 @@ WRL2NORMS::WRL2NORMS( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2NORMS::~WRL2NORMS()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Normal node" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Normal node." );
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,71 +67,36 @@ bool WRL2NORMS::isDangling( void )
|
|||
bool WRL2NORMS::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr<< " * [BUG] AddRefNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2NORMS::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
// this node may not own or reference any other node
|
||||
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr<< " * [BUG] AddChildNode is not applicable";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
||||
}
|
||||
|
||||
|
||||
bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -147,52 +112,34 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr<< proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
// expecting 'vector'
|
||||
if( !glob.compare( "vector" ) )
|
||||
{
|
||||
if( !proc.ReadMFVec3f( vectors ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr<< " * [INFO] invalid vector set 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid vector set %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr<< " * [INFO] bad Normal at line " << line << ", column ";
|
||||
ostr<< column << "\n";
|
||||
ostr<< " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Normal %s\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -203,18 +150,10 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
return true;
|
||||
}
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr<< " * [INFO] bad Normal at line " << line << ", column ";
|
||||
ostr<< column << " (no closing brace)\n";
|
||||
ostr<< " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Normal %s (no closing brace)\n"
|
||||
" * [INFO] file: '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(), proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,29 +37,22 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2NORMS
|
||||
*/
|
||||
class WRL2NORMS : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
std::vector< WRLVEC3F > vectors;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2NORMS();
|
||||
WRL2NORMS( WRL2NODE* aParent );
|
||||
virtual ~WRL2NORMS();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
std::vector< WRLVEC3F > vectors;
|
||||
};
|
||||
|
||||
#endif // VRML2_NORMS_H
|
||||
|
|
|
@ -54,15 +54,10 @@ WRL2POINTSET::WRL2POINTSET( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2POINTSET::~WRL2POINTSET()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying PointSet 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying PointSet node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,33 +101,16 @@ bool WRL2POINTSET::isDangling( void )
|
|||
|
||||
bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -141,14 +119,10 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != color )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple color nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple color nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -161,14 +135,10 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple coordinate nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple coord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -183,33 +153,16 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -218,14 +171,10 @@ bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != color )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple color nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple color nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -238,14 +187,10 @@ bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != coord )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple coordinate nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple coord nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -261,38 +206,23 @@ bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -310,14 +240,9 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -325,21 +250,14 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// expecting one of:
|
||||
// color
|
||||
// coord
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "color" ) )
|
||||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read color node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read color node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -348,30 +266,22 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read coord node information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read coord node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad PointSet at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid PointSet %s (no closing brace)\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,49 +37,38 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2POINTSET
|
||||
*/
|
||||
class WRL2POINTSET : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
WRL2NODE* color;
|
||||
WRL2NODE* coord;
|
||||
|
||||
/**
|
||||
* Function checkNodeType
|
||||
* returns true if the node type is a valid subnode of PointSet
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
|
||||
// overloads
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
public:
|
||||
WRL2POINTSET();
|
||||
WRL2POINTSET( WRL2NODE* aParent );
|
||||
virtual ~WRL2POINTSET();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
* returns true if the face set has a color node
|
||||
* @return true if the face set has a color node.
|
||||
*/
|
||||
bool HasColors( void );
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @return true if the node type is a valid subnode of PointSet.
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void setDefaults( void );
|
||||
|
||||
WRL2NODE* color;
|
||||
WRL2NODE* coord;
|
||||
};
|
||||
|
||||
#endif // VRML2_POINTSET_H
|
||||
|
|
|
@ -55,15 +55,10 @@ WRL2SHAPE::WRL2SHAPE( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2SHAPE::~WRL2SHAPE()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying Shape 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Shape node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,33 +79,16 @@ bool WRL2SHAPE::isDangling( void )
|
|||
|
||||
bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -119,14 +97,10 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != appearance )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple appearance nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple appearance nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -137,14 +111,10 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
if( nullptr != geometry )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple geometry nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple geometry nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -156,33 +126,16 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] NULL passed for aNode";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
WRL2NODES type = aNode->GetNodeType();
|
||||
|
||||
if( !checkNodeType( type ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; unexpected child node '";
|
||||
ostr << aNode->GetNodeTypeName( type ) << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected child node '%s'." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -191,14 +144,10 @@ bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode )
|
|||
{
|
||||
if( nullptr != appearance )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple appearance nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple appearance nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -209,14 +158,10 @@ bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode )
|
|||
|
||||
if( nullptr != geometry )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad file format; multiple geometry nodes";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; multiple geometry nodes." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -254,52 +199,25 @@ bool WRL2SHAPE::checkNodeType( WRL2NODES aType )
|
|||
|
||||
bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -317,14 +235,9 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -332,21 +245,14 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// expecting one of:
|
||||
// appearance
|
||||
// geometry
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "appearance" ) )
|
||||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read appearance information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read appearance node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -355,30 +261,22 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !aTopNode->ReadNode( proc, this, nullptr ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] could not read geometry information";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] could not read geometry node information." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Shape at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Shape %s.\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -407,15 +305,10 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent )
|
|||
break;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Shape 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Shape with %ul children, %ul references, and"
|
||||
"%ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
|
||||
bool vcolors = false;
|
||||
|
||||
|
@ -434,20 +327,9 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent )
|
|||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Shape does not have a Transform parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
|
||||
wxString::Format( wxT( "Shape does not have a Transform parent (parent "
|
||||
"ID: %d)." ), ptype ) );
|
||||
|
||||
if( m_sgNode )
|
||||
{
|
||||
|
|
|
@ -2,6 +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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,40 +35,31 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2SHAPE
|
||||
*/
|
||||
class WRL2SHAPE : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
WRL2NODE* appearance;
|
||||
WRL2NODE* geometry;
|
||||
|
||||
/**
|
||||
* Function checkNodeType
|
||||
* returns true if the node type is an appearance or geometry class
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
// overloads
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2SHAPE();
|
||||
WRL2SHAPE( WRL2NODE* aParent );
|
||||
virtual ~WRL2SHAPE();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
bool AddChildNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @return true if the node type is an appearance or geometry class.
|
||||
*/
|
||||
bool checkNodeType( WRL2NODES aType );
|
||||
|
||||
void unlinkChildNode( const WRL2NODE* aNode ) override;
|
||||
void unlinkRefNode( const WRL2NODE* aNode ) override;
|
||||
|
||||
WRL2NODE* appearance;
|
||||
WRL2NODE* geometry;
|
||||
};
|
||||
|
||||
#endif // VRML2_SHAPE_H
|
||||
|
|
|
@ -51,15 +51,10 @@ WRL2SWITCH::WRL2SWITCH( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2SWITCH::~WRL2SWITCH()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Destroying Switch 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Switch node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +65,6 @@ bool WRL2SWITCH::isDangling( void )
|
|||
}
|
||||
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
/*
|
||||
|
@ -82,52 +76,25 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
* }
|
||||
*/
|
||||
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] aTopNode is nullptr";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( '{' != tok )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -145,14 +112,9 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( !proc.ReadName( glob ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << proc.GetError();
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -160,24 +122,16 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// expecting one of:
|
||||
// choice
|
||||
// whichChoice
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "whichChoice" ) )
|
||||
{
|
||||
if( !proc.ReadSFInt( whichChoice ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] invalid whichChoice 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid whichChoice %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -189,16 +143,12 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] bad Switch at line " << line << ", column ";
|
||||
ostr << column << "\n";
|
||||
ostr << " * [INFO] file: '" << proc.GetFileName() << "'";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] invalid Switch %s.\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -210,19 +160,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
bool WRL2SWITCH::AddRefNode( WRL2NODE* aNode )
|
||||
{
|
||||
if( nullptr == aNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
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 );
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
|
||||
|
||||
// take possession if the node is dangling WRL2_SHAPE
|
||||
if( WRL2NODES::WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() )
|
||||
|
@ -248,22 +186,13 @@ bool WRL2SWITCH::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
size_t line, column;
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
char tok = proc.Peek();
|
||||
|
||||
if( proc.eof() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] bad file format; unexpected eof %s." ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -312,50 +241,29 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Switch 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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Switch with %ul children, %ul references, and"
|
||||
"%ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
|
||||
if( choices.empty() )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Switch translation: no choices" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Switch translation: no choices." );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Switch does not have a Transform parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
|
||||
wxString::Format( wxT( "Switch does not have a Transform parent (parent "
|
||||
"ID: %d)." ), ptype ) );
|
||||
|
||||
if( whichChoice < 0 || whichChoice >= (int)choices.size() )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Switch translation: no choice (choices = ";
|
||||
ostr << choices.size() << "), whichChoice = " << whichChoice;
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Switch translation: no choice (choices = %ul), "
|
||||
"whichChoice = %d." ), choices.size(), whichChoice );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2021 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
|
||||
|
@ -34,31 +35,25 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2SWITCH
|
||||
*/
|
||||
|
||||
class WRL2SWITCH : public WRL2NODE
|
||||
{
|
||||
private:
|
||||
int whichChoice;
|
||||
std::vector< WRL2NODE* > choices;
|
||||
|
||||
bool readChildren( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2SWITCH();
|
||||
WRL2SWITCH( WRL2NODE* aNode );
|
||||
virtual ~WRL2SWITCH();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
int whichChoice;
|
||||
std::vector< WRL2NODE* > choices;
|
||||
|
||||
bool readChildren( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
};
|
||||
|
||||
#endif // VRML2_SWITCH_H
|
||||
|
|
|
@ -49,15 +49,10 @@ WRL2TRANSFORM::WRL2TRANSFORM( WRL2NODE* aParent ) : WRL2NODE()
|
|||
|
||||
WRL2TRANSFORM::~WRL2TRANSFORM()
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
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 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Transform node with %ul children, %ul"
|
||||
"references, and %ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +63,6 @@ bool WRL2TRANSFORM::isDangling( void )
|
|||
}
|
||||
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
{
|
||||
/*
|
||||
|
@ -88,19 +82,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
* }
|
||||
*/
|
||||
|
||||
if( nullptr == aTopNode )
|
||||
{
|
||||
#ifdef DEBUG_VRML2
|
||||
do {
|
||||