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 {
|
||||
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;
|
||||
|
@ -128,31 +110,19 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -170,14 +140,9 @@ bool WRL2TRANSFORM::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;
|
||||
}
|
||||
|
@ -189,24 +154,16 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
// scale
|
||||
// ScaleOrientation
|
||||
// translation
|
||||
|
||||
proc.GetFilePosData( line, column );
|
||||
|
||||
if( !glob.compare( "center" ) )
|
||||
{
|
||||
if( !proc.ReadSFVec3f( center ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 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\n"
|
||||
" * [INFO] invalid center %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -220,17 +177,12 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFRotation( rotation ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 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\n"
|
||||
" * [INFO] invalid rotation %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -239,17 +191,12 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( scale ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 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\n"
|
||||
" * [INFO] invalid scale %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -258,17 +205,12 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFRotation( scaleOrientation ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 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\n"
|
||||
" * [INFO] invalid scaleOrientation %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -277,17 +219,12 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
{
|
||||
if( !proc.ReadSFVec3f( translation ) )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 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\n"
|
||||
" * [INFO] invalid translation %s\n"
|
||||
" * [INFO] file: '%s'\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName(), proc.GetError() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -304,16 +241,12 @@ bool WRL2TRANSFORM::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 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\n"
|
||||
" * [INFO] invalid Transform %s.\n"
|
||||
" * [INFO] file: '%s'\n" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
||||
proc.GetFileName() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -325,19 +258,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
bool WRL2TRANSFORM::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
|
||||
|
||||
|
@ -365,22 +286,13 @@ bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode )
|
|||
|
||||
bool WRL2TRANSFORM::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;
|
||||
}
|
||||
|
@ -412,7 +324,6 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
if( proc.Peek() == ',' )
|
||||
proc.Pop();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -421,35 +332,19 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Transform with " << m_Children.size();
|
||||
ostr << " children, " << m_Refs.size() << " references and ";
|
||||
ostr << m_BackPointers.size() << " backpointers";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#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( m_Children.empty() && m_Refs.empty() )
|
||||
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] Transform 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( "Transform 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
|
||||
|
@ -34,12 +35,23 @@
|
|||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* WRL2TRANSFORM
|
||||
*/
|
||||
|
||||
class WRL2TRANSFORM : public WRL2NODE
|
||||
{
|
||||
public:
|
||||
WRL2TRANSFORM();
|
||||
WRL2TRANSFORM( WRL2NODE* aNode );
|
||||
virtual ~WRL2TRANSFORM();
|
||||
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
bool isDangling( void ) override;
|
||||
|
||||
private:
|
||||
bool readChildren( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
|
||||
WRLVEC3F center;
|
||||
WRLVEC3F scale;
|
||||
WRLVEC3F translation;
|
||||
|
@ -47,23 +59,6 @@ private:
|
|||
WRLROTATION scaleOrientation;
|
||||
WRLVEC3F bboxCenter;
|
||||
WRLVEC3F bboxSize;
|
||||
|
||||
bool readChildren( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
|
||||
public:
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool isDangling( void ) override;
|
||||
|
||||
public:
|
||||
WRL2TRANSFORM();
|
||||
WRL2TRANSFORM( WRL2NODE* aNode );
|
||||
virtual ~WRL2TRANSFORM();
|
||||
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
|
||||
bool AddRefNode( WRL2NODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
};
|
||||
|
||||
#endif // VRML2_TRANSFORM_H
|
||||
|
|
|
@ -55,6 +55,14 @@
|
|||
#define PLUGIN_VRML_REVNO 2
|
||||
|
||||
|
||||
/**
|
||||
* Flag to enable VRML plugin trace output.
|
||||
*
|
||||
* @ingroup trace_env_vars
|
||||
*/
|
||||
const wxChar* const traceVrmlPlugin = wxT( "KICAD_VRML_PLUGIN" );
|
||||
|
||||
|
||||
const char* GetKicadPluginName( void )
|
||||
{
|
||||
return "PLUGIN_3D_VRML";
|
||||
|
@ -141,9 +149,6 @@ bool CanRender( void )
|
|||
|
||||
class LOCALESWITCH
|
||||
{
|
||||
// Store the user locale name, to restore this locale later, in dtor
|
||||
std::string m_locale;
|
||||
|
||||
public:
|
||||
LOCALESWITCH()
|
||||
{
|
||||
|
@ -155,6 +160,10 @@ public:
|
|||
{
|
||||
setlocale( LC_NUMERIC, m_locale.c_str() );
|
||||
}
|
||||
|
||||
private:
|
||||
// Store the user locale name, to restore this locale later, in dtor
|
||||
std::string m_locale;
|
||||
};
|
||||
|
||||
|
||||
|
@ -230,17 +239,17 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline )
|
|||
|
||||
if( proc.GetVRMLType() == WRLVERSION::VRML_V1 )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Processing VRML 1.0 file" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Processing VRML 1.0 file" );
|
||||
|
||||
WRL1BASE* bp = new WRL1BASE;
|
||||
|
||||
if( !bp->Read( proc ) )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] load failed" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] load failed" );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] load completed" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] load completed" );
|
||||
|
||||
scene = (SCENEGRAPH*)bp->TranslateToSG( nullptr, nullptr );
|
||||
}
|
||||
|
@ -249,7 +258,7 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline )
|
|||
}
|
||||
else
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Processing VRML 2.0 file" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Processing VRML 2.0 file" );
|
||||
|
||||
WRL2BASE* bp = new WRL2BASE;
|
||||
|
||||
|
@ -258,11 +267,11 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline )
|
|||
|
||||
if( !bp->Read( proc ) )
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] load failed" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] load failed" );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] load completed" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] load completed" );
|
||||
|
||||
// for now we recalculate all normals per-vertex per-face
|
||||
scene = (SCENEGRAPH*)bp->TranslateToSG( nullptr );
|
||||
|
|
|
@ -135,8 +135,7 @@ static float VCalcCosAngle( const WRLVEC3F& p1, const WRLVEC3F& p2, const WRLVEC
|
|||
|
||||
float cosAngle = ( p12 + p13 - p23 ) / dn;
|
||||
|
||||
// check the domain; errors in the cosAngle calculation
|
||||
// can result in domain errors
|
||||
// check the domain; errors in the cosAngle calculation can result in domain errors
|
||||
if( cosAngle > 1.0f )
|
||||
cosAngle = 1.0f;
|
||||
else if( cosAngle < -1.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
|
||||
|
@ -40,17 +41,6 @@ class SGNODE;
|
|||
|
||||
class FACET
|
||||
{
|
||||
private:
|
||||
std::vector< WRLVEC3F > vertices; // vertices of the facet
|
||||
std::vector< SGCOLOR > colors; // per-vertex/per-face color (if any)
|
||||
std::vector< int > indices; // index of each vertex
|
||||
|
||||
WRLVEC3F face_normal; // normal of this facet
|
||||
std::vector< WRLVEC3F > norms; // per-vertex normals
|
||||
std::vector< WRLVEC3F > vnweight; // angle weighted per vertex normal
|
||||
|
||||
int maxIdx; // maximum index used
|
||||
|
||||
public:
|
||||
FACET();
|
||||
|
||||
|
@ -59,67 +49,59 @@ public:
|
|||
bool HasColors();
|
||||
|
||||
/**
|
||||
* Function AddVertex
|
||||
* adds the vertex and its associated index to the internal list
|
||||
* of polygon vertices
|
||||
* Add the vertex and its associated index to the internal list of polygon vertices.
|
||||
*/
|
||||
void AddVertex( WRLVEC3F& aVertex, int aIndex );
|
||||
|
||||
/**
|
||||
* Function AddColor
|
||||
* adds the given RGB color to the internal list. For per-face
|
||||
* coloring only a single color needs to be specified; for a
|
||||
* per-vertex coloring the color must be specified for each
|
||||
* vertex
|
||||
* Add the given RGB color to the internal list.
|
||||
*
|
||||
* For per-face coloring only a single color needs to be specified. For a per-vertex
|
||||
* coloring the color must be specified for each vertex.
|
||||
*/
|
||||
void AddColor( const SGCOLOR& aColor );
|
||||
|
||||
/**
|
||||
* Function CalcFaceNormal
|
||||
* calculates the normal to the facet assuming a CCW orientation
|
||||
* and performs the calculation of the angle weighted vertex normals.
|
||||
* Calculate the normal to the facet assuming a CCW orientation and perform the calculation
|
||||
* of the angle weighted vertex normals.
|
||||
*
|
||||
* @return is the max. magnitude of any component of the normal or zero
|
||||
* if there is a fault or the normal has already been calculated.
|
||||
* @return is the max. magnitude of any component of the normal or zero if there is a
|
||||
* fault or the normal has already been calculated.
|
||||
*/
|
||||
float CalcFaceNormal();
|
||||
|
||||
void Renormalize( float aMaxValue );
|
||||
|
||||
/**
|
||||
* Function CalcVertexNormal
|
||||
* calculates the weighted normal for the given vertex
|
||||
* Calculate the weighted normal for the given vertex.
|
||||
*
|
||||
* @param aIndex is the VRML file's Vertex Index for the vertex to be processed
|
||||
* @param aFacetList is the list of all faces which share this vertex
|
||||
* @param aIndex is the VRML file's Vertex Index for the vertex to be processed.
|
||||
* @param aFacetList is the list of all faces which share this vertex.
|
||||
*/
|
||||
void CalcVertexNormal( int aIndex, std::list< FACET* >& aFacetList, float aCreaseAngle );
|
||||
|
||||
/**
|
||||
* Function GetWeightedNormal
|
||||
* retrieves the angle weighted normal for the given vertex index
|
||||
* Retrieve the angle weighted normal for the given vertex index.
|
||||
*
|
||||
* @param aIndex is the VRML file's Vertex Index for the vertex to be processed
|
||||
* @param aNorm will hold the result
|
||||
* @param aIndex is the VRML file's Vertex Index for the vertex to be processed.
|
||||
* @param aNorm will hold the result.
|
||||
*/
|
||||
bool GetWeightedNormal( int aIndex, WRLVEC3F& aNorm );
|
||||
|
||||
/**
|
||||
* Function GetFaceNormal
|
||||
* retrieves the normal for this facet
|
||||
* Retrieve the normal for this facet.
|
||||
*
|
||||
* @param aNorm will hold the result
|
||||
* @param aNorm will hold the result.
|
||||
*/
|
||||
bool GetFaceNormal( WRLVEC3F& aNorm );
|
||||
|
||||
/**
|
||||
* Function GetData
|
||||
* packages the internal data as triangles with corresponding per-vertex normals
|
||||
* Package the internal data as triangles with corresponding per-vertex normals.
|
||||
*
|
||||
* @param aVertexList is the list of vertices to add to
|
||||
* @param aNormalsList is the list of per-vertex normals to add to
|
||||
* @param aColorsList is the list of per-vertex colors (if any) to add to
|
||||
* @param aVertexOrder informs the function of the vertex winding order
|
||||
* @param aVertexList is the list of vertices to add to.
|
||||
* @param aNormalsList is the list of per-vertex normals to add to.
|
||||
* @param aColorsList is the list of per-vertex colors (if any) to add to.
|
||||
* @param aVertexOrder informs the function of the vertex winding order.
|
||||
*/
|
||||
bool GetData( std::vector< WRLVEC3F >& aVertexList, std::vector< WRLVEC3F >& aNormalsList,
|
||||
std::vector< SGCOLOR >& aColorsList, WRL1_ORDER aVertexOrder );
|
||||
|
@ -130,24 +112,35 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function CollectVertices
|
||||
* adds a pointer to this object at each position within aFacetList
|
||||
* referenced by the internal vertex indices
|
||||
* Add a pointer to this object at each position within \a aFacetList referenced by the
|
||||
* internal vertex indices.
|
||||
*/
|
||||
void CollectVertices( std::vector< std::list< FACET* > >& aFacetList );
|
||||
|
||||
private:
|
||||
std::vector< WRLVEC3F > vertices; // vertices of the facet
|
||||
std::vector< SGCOLOR > colors; // per-vertex/per-face color (if any)
|
||||
std::vector< int > indices; // index of each vertex
|
||||
|
||||
WRLVEC3F face_normal; // normal of this facet
|
||||
std::vector< WRLVEC3F > norms; // per-vertex normals
|
||||
std::vector< WRLVEC3F > vnweight; // angle weighted per vertex normal
|
||||
|
||||
int maxIdx; // maximum index used
|
||||
};
|
||||
|
||||
|
||||
class SHAPE
|
||||
{
|
||||
std::list< FACET* > facets;
|
||||
|
||||
public:
|
||||
~SHAPE();
|
||||
|
||||
FACET* NewFacet();
|
||||
SGNODE* CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrder,
|
||||
float aCreaseLimit = 0.74317, bool isVRML2 = false );
|
||||
|
||||
private:
|
||||
std::list< FACET* > facets;
|
||||
};
|
||||
|
||||
#endif // WRLFACET_H
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
try \
|
||||
{ \
|
||||
char* cp = m_file->ReadLine(); \
|
||||
\
|
||||
if( nullptr == cp ) \
|
||||
{ \
|
||||
m_eof = true; \
|
||||
|
@ -45,6 +46,7 @@
|
|||
m_buf = cp; \
|
||||
m_bufpos = 0; \
|
||||
} \
|
||||
\
|
||||
m_fileline = m_file->LineNumber(); \
|
||||
} \
|
||||
catch( ... ) \
|
||||
|
@ -172,7 +174,7 @@ bool WRLPROC::getRawLine( void )
|
|||
|
||||
while( sS != eS )
|
||||
{
|
||||
if( ((*sS) & 0x80) )
|
||||
if( ( ( *sS ) & 0x80 ) )
|
||||
{
|
||||
m_error = " non-ASCII character sequence in VRML1 file";
|
||||
return false;
|
||||
|
@ -391,7 +393,7 @@ bool WRLPROC::DiscardNode( void )
|
|||
ostr << ", column " << m_bufpos;
|
||||
m_error = ostr.str();
|
||||
|
||||
wxLogTrace( MASK_VRML, "%s\n", m_error.c_str() );
|
||||
wxLogTrace( traceVrmlPlugin, "%s\n", m_error.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1977,6 +1979,19 @@ bool WRLPROC::GetFilePosData( size_t& line, size_t& column )
|
|||
}
|
||||
|
||||
|
||||
std::string WRLPROC::GetFilePosition() const
|
||||
{
|
||||
std::ostringstream retv;
|
||||
|
||||
if( !m_file )
|
||||
retv << "no file loaded to provide file position information";
|
||||
else
|
||||
retv << "at line " << m_fileline << ", column " << m_bufpos;
|
||||
|
||||
return retv.str();
|
||||
}
|
||||
|
||||
|
||||
std::string WRLPROC::GetFileName( void )
|
||||
{
|
||||
if( !m_file )
|
||||
|
|
|
@ -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,25 +40,6 @@
|
|||
|
||||
class WRLPROC
|
||||
{
|
||||
private:
|
||||
LINE_READER* m_file;
|
||||
std::string m_buf; // string being parsed
|
||||
bool m_eof;
|
||||
unsigned int m_fileline;
|
||||
unsigned int m_bufpos;
|
||||
|
||||
WRLVERSION m_fileVersion; // VRML file version
|
||||
std::string m_error; // error message
|
||||
std::string m_badchars; // characters forbidden in VRML{1|2} names
|
||||
std::string m_filename; // current file
|
||||
std::string m_filedir; // parent directory of the file
|
||||
|
||||
// getRawLine reads a single non-blank line and in the case of a VRML1 file
|
||||
// it checks for invalid characters (bit 8 set). If m_buf is not empty and
|
||||
// not completely parsed the function returns 'true'. The file position
|
||||
// parameters are updated as appropriate.
|
||||
bool getRawLine( void );
|
||||
|
||||
public:
|
||||
WRLPROC( LINE_READER* aLineReader );
|
||||
~WRLPROC();
|
||||
|
@ -73,18 +55,23 @@ public:
|
|||
// helper routines
|
||||
std::string GetError( void );
|
||||
bool GetFilePosData( size_t& line, size_t& column );
|
||||
std::string GetFilePosition() const;
|
||||
std::string GetFileName( void );
|
||||
|
||||
// eatSpace discards all leading white space from the current m_linepos
|
||||
// and continues until a non-empty line is found which contains non-blank
|
||||
// characters
|
||||
bool EatSpace( void );
|
||||
|
||||
// Peek returns the next non-white char in the file or '\0' on failure
|
||||
char Peek( void );
|
||||
|
||||
// Pop removes the current char from the buffer
|
||||
void Pop( void );
|
||||
|
||||
// read up to the next whitespace or comma
|
||||
bool ReadGlob( std::string& aGlob );
|
||||
|
||||
// read a VRML name; is similar to ReadGlob except that it enforces
|
||||
// name checking rules, does not allow a comma at the end, and
|
||||
// stops when a left/right brace or bracket is found.
|
||||
|
@ -110,6 +97,25 @@ public:
|
|||
bool ReadMFRotation( std::vector< WRLROTATION >& aMFRotation );
|
||||
bool ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f );
|
||||
bool ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f );
|
||||
|
||||
// getRawLine reads a single non-blank line and in the case of a VRML1 file
|
||||
// it checks for invalid characters (bit 8 set). If m_buf is not empty and
|
||||
// not completely parsed the function returns 'true'. The file position
|
||||
// parameters are updated as appropriate.
|
||||
bool getRawLine( void );
|
||||
|
||||
private:
|
||||
LINE_READER* m_file;
|
||||
std::string m_buf; // string being parsed
|
||||
bool m_eof;
|
||||
unsigned int m_fileline;
|
||||
unsigned int m_bufpos;
|
||||
|
||||
WRLVERSION m_fileVersion; // VRML file version
|
||||
std::string m_error; // error message
|
||||
std::string m_badchars; // characters forbidden in VRML{1|2} names
|
||||
std::string m_filename; // current file
|
||||
std::string m_filedir; // parent directory of the file
|
||||
};
|
||||
|
||||
#endif // WRLPROC_H
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 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
|
||||
|
@ -30,11 +31,13 @@
|
|||
#ifndef WRLTYPES_H
|
||||
#define WRLTYPES_H
|
||||
|
||||
#include <wx/defs.h>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
// log mask for wxLogTrace
|
||||
#define MASK_VRML "PLUGIN_VRML"
|
||||
// Mask for VRML tracing.
|
||||
extern const wxChar* const traceVrmlPlugin;
|
||||
|
||||
// version of the VRML file being parsed
|
||||
enum class WRLVERSION
|
||||
|
|
|
@ -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,16 +35,14 @@ class wxString;
|
|||
|
||||
class X3DPARSER
|
||||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Function getGroupingNodes
|
||||
* retrieves all permissible top-level nodes in an X3D/VRML file
|
||||
*/
|
||||
bool getGroupingNodes( wxXmlNode* aNode, std::vector<wxXmlNode*>& aResult );
|
||||
|
||||
public:
|
||||
SCENEGRAPH* Load( const wxString& aFileName );
|
||||
|
||||
private:
|
||||
/**
|
||||
* Retrieve all permissible top-level nodes in an X3D/VRML file.
|
||||
*/
|
||||
bool getGroupingNodes( wxXmlNode* aNode, std::vector<wxXmlNode*>& aResult );
|
||||
};
|
||||
|
||||
#endif // S3D_X3D_H
|
||||
|
|
|
@ -36,8 +36,6 @@ X3DAPP::X3DAPP() : X3DNODE()
|
|||
{
|
||||
m_Type = X3D_APPEARANCE;
|
||||
init();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,19 +54,15 @@ X3DAPP::X3DAPP( X3DNODE* aParent ) : X3DNODE()
|
|||
|
||||
if( nullptr != m_Parent )
|
||||
m_Parent->AddChildNode( this );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
X3DAPP::~X3DAPP()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Appearance" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Appearance" );
|
||||
|
||||
if( !m_MatName.empty() && m_Dict )
|
||||
m_Dict->DelName( m_MatName, this );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,28 +232,14 @@ SGNODE* X3DAPP::TranslateToSG( SGNODE* aParent )
|
|||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_X3D
|
||||
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() );
|
||||
#endif
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
|
||||
wxString::Format( wxT( "Appearance does not have a Shape parent (parent ID: %d)" ),
|
||||
ptype ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 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 )
|
||||
{
|
||||
|
|
|
@ -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,8 @@
|
|||
#include "x3d_shape.h"
|
||||
|
||||
|
||||
/**
|
||||
* X3DAPP
|
||||
*/
|
||||
class X3DAPP : public X3DNODE
|
||||
{
|
||||
private:
|
||||
void init();
|
||||
void readFields( wxXmlNode* aNode );
|
||||
wxString m_MatName; // material name
|
||||
|
||||
protected:
|
||||
WRLVEC3F diffuseColor;
|
||||
WRLVEC3F emissiveColor;
|
||||
WRLVEC3F specularColor;
|
||||
float ambientIntensity;
|
||||
float shininess;
|
||||
float transparency;
|
||||
|
||||
public:
|
||||
X3DAPP();
|
||||
X3DAPP( X3DNODE* aParent );
|
||||
|
@ -64,6 +49,22 @@ public:
|
|||
bool AddChildNode( X3DNODE* aNode ) override;
|
||||
bool AddRefNode( X3DNODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
void readFields( wxXmlNode* aNode );
|
||||
|
||||
protected:
|
||||
WRLVEC3F diffuseColor;
|
||||
WRLVEC3F emissiveColor;
|
||||
WRLVEC3F specularColor;
|
||||
float ambientIntensity;
|
||||
float shininess;
|
||||
float transparency;
|
||||
|
||||
private:
|
||||
wxString m_MatName; // material name
|
||||
|
||||
};
|
||||
|
||||
#endif // X3D_APPEARANCE_H
|
||||
|
|
|
@ -173,12 +173,9 @@ void X3DNODE::delNodeRef( X3DNODE* aNode )
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_X3D
|
||||
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() );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
|
||||
" * [BUG] delNodeRef() did not find its target." ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ typedef std::vector< wxXmlNode* > NODE_LIST;
|
|||
// a class to hold the dictionary of node DEFs
|
||||
class X3D_DICT
|
||||
{
|
||||
private:
|
||||
std::map< wxString, X3DNODE* > reg;
|
||||
|
||||
public:
|
||||
bool AddName( const wxString& aName, X3DNODE* aNode );
|
||||
bool DelName( const wxString& aName, X3DNODE* aNode );
|
||||
X3DNODE* FindName( const wxString& aName );
|
||||
|
||||
private:
|
||||
std::map< wxString, X3DNODE* > reg;
|
||||
};
|
||||
|
||||
enum X3DNODES
|
||||
|
@ -69,11 +69,92 @@ enum X3DNODES
|
|||
};
|
||||
|
||||
/**
|
||||
* X3DNODE
|
||||
* represents the base class of all X3D nodes
|
||||
* The base class of all X3D nodes.
|
||||
*/
|
||||
class X3DNODE
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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 X3DNODE* 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 X3DNODE* 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( X3DNODE* 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( X3DNODE* aNode );
|
||||
|
||||
X3DNODE();
|
||||
virtual ~X3DNODE();
|
||||
|
||||
// read data and return TRUE on success
|
||||
virtual bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) = 0;
|
||||
|
||||
/**
|
||||
* Return the type of this node instance.
|
||||
*/
|
||||
X3DNODES GetNodeType( void ) const;
|
||||
|
||||
/**
|
||||
* Return a pointer to the parent node of this object or NULL if the object has no
|
||||
* parent (ie. top level transform).
|
||||
*/
|
||||
X3DNODE* GetParent( void ) const;
|
||||
|
||||
/**
|
||||
* Return the name of this object.
|
||||
*/
|
||||
wxString GetName( void ) const;
|
||||
|
||||
/**
|
||||
* Set the parent X3DNODE 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 or false if the given node is not allowed to
|
||||
* be a parent to the derived object.
|
||||
*/
|
||||
virtual bool SetParent( X3DNODE* aParent, bool doUnlink = true ) = 0;
|
||||
|
||||
virtual bool AddChildNode( X3DNODE* aNode ) = 0;
|
||||
|
||||
virtual bool AddRefNode( X3DNODE* aNode ) = 0;
|
||||
|
||||
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;
|
||||
|
||||
protected:
|
||||
X3DNODE* m_Parent; // pointer to parent node; may be NULL for top level node
|
||||
X3DNODES m_Type; // type of node
|
||||
|
@ -86,98 +167,6 @@ protected:
|
|||
|
||||
wxString m_Name; // name to use for referencing the node by name
|
||||
SGNODE* m_sgNode; // the SGNODE representation of the display data
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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 X3DNODE* 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 X3DNODE* 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( X3DNODE* 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( X3DNODE* aNode );
|
||||
|
||||
public:
|
||||
X3DNODE();
|
||||
virtual ~X3DNODE();
|
||||
|
||||
// read data and return TRUE on success
|
||||
virtual bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) = 0;
|
||||
|
||||
/**
|
||||
* Function GetNodeType
|
||||
* returns the type of this node instance
|
||||
*/
|
||||
X3DNODES GetNodeType( void ) const;
|
||||
|
||||
/**
|
||||
* Function GetParent
|
||||
* returns a pointer to the parent node of this object
|
||||
* or NULL if the object has no parent (ie. top level transform)
|
||||
*/
|
||||
X3DNODE* GetParent( void ) const;
|
||||
|
||||
/**
|
||||
* Function GetName
|
||||
* returns the name of this object
|
||||
*/
|
||||
wxString GetName( void ) const;
|
||||
|
||||
/**
|
||||
* Function SetParent
|
||||
* sets the parent X3DNODE 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( X3DNODE* aParent, bool doUnlink = true ) = 0;
|
||||
|
||||
virtual bool AddChildNode( X3DNODE* aNode ) = 0;
|
||||
|
||||
virtual bool AddRefNode( X3DNODE* aNode ) = 0;
|
||||
|
||||
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 // X3D_BASE_H
|
||||
|
|
|
@ -56,7 +56,7 @@ X3DCOORDS::X3DCOORDS( X3DNODE* aParent ) : X3DNODE()
|
|||
|
||||
X3DCOORDS::~X3DCOORDS()
|
||||
{
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate" );
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying Coordinate" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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,14 +36,8 @@
|
|||
#include "x3d_ifaceset.h"
|
||||
|
||||
|
||||
/**
|
||||
* X3DCOORDS
|
||||
*/
|
||||
class X3DCOORDS : public X3DNODE
|
||||
{
|
||||
private:
|
||||
std::vector< WRLVEC3F > points;
|
||||
|
||||
public:
|
||||
X3DCOORDS();
|
||||
X3DCOORDS( X3DNODE* aParent );
|
||||
|
@ -56,6 +51,9 @@ public:
|
|||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
void GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize );
|
||||
|
||||
private:
|
||||
std::vector< WRLVEC3F > points;
|
||||
};
|
||||
|
||||
#endif // X3D_COORDS_H
|
||||
|
|
|
@ -41,8 +41,6 @@ X3DIFACESET::X3DIFACESET() : X3DNODE()
|
|||
m_Type = X3D_INDEXED_FACE_SET;
|
||||
coord = nullptr;
|
||||
init();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,18 +60,12 @@ X3DIFACESET::X3DIFACESET( X3DNODE* aParent ) : X3DNODE()
|
|||
|
||||
if( nullptr != m_Parent )
|
||||
m_Parent->AddChildNode( this );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
X3DIFACESET::~X3DIFACESET()
|
||||
{
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 )
|
||||
wxLogTrace( MASK_VRML, " * [INFO] Destroying IndexedFaceSet\n" );
|
||||
#endif
|
||||
|
||||
return;
|
||||
wxLogTrace( traceVrmlPlugin, " * [INFO] Destroying IndexedFaceSet." );
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +76,6 @@ void X3DIFACESET::init()
|
|||
ccw = true;
|
||||
creaseAngle = 0.733f; // approx 42 degrees; this is larger than VRML spec.
|
||||
creaseLimit = 0.74317f; // cos( 0.733 )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,8 +124,6 @@ void X3DIFACESET::readFields( wxXmlNode* aNode )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,7 +146,6 @@ bool X3DIFACESET::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict )
|
|||
if( false == ok )
|
||||
return false;
|
||||
|
||||
|
||||
if( !SetParent( aTopNode ) )
|
||||
return false;
|
||||
|
||||
|
@ -239,31 +227,15 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent )
|
|||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE )
|
||||
{
|
||||
#ifdef DEBUG_X3D
|
||||
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 valid Shape parent "
|
||||
"(parent ID: %d)" ),
|
||||
ptype ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 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 coordinate 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
|
||||
|
@ -35,11 +36,19 @@
|
|||
#include "x3d_shape.h"
|
||||
|
||||
|
||||
/**
|
||||
* X3DIFACESET
|
||||
*/
|
||||
class X3DIFACESET : public X3DNODE
|
||||
{
|
||||
public:
|
||||
X3DIFACESET();
|
||||
X3DIFACESET( X3DNODE* aParent );
|
||||
virtual ~X3DIFACESET();
|
||||
|
||||
bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) override;
|
||||
bool SetParent( X3DNODE* aParent, bool doUnlink = true ) override;
|
||||
bool AddChildNode( X3DNODE* aNode ) override;
|
||||
bool AddRefNode( X3DNODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
private:
|
||||
X3DNODE* coord;
|
||||
|
||||
|
@ -50,18 +59,6 @@ private:
|
|||
|
||||
void init();
|
||||
void readFields( wxXmlNode* aNode );
|
||||
|
||||
public:
|
||||
X3DIFACESET();
|
||||
X3DIFACESET( X3DNODE* aParent );
|
||||
virtual ~X3DIFACESET();
|
||||
|
||||
// functions inherited from X3DNODE
|
||||
bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) override;
|
||||
bool SetParent( X3DNODE* aParent, bool doUnlink = true ) override;
|
||||
bool AddChildNode( X3DNODE* aNode ) override;
|
||||
bool AddRefNode( X3DNODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
};
|
||||
|
||||
#endif // X3D_IFACESET_H
|
||||
|
|
|
@ -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,7 +36,6 @@
|
|||
namespace X3D
|
||||
{
|
||||
/* Functions to create and read X3D Nodes */
|
||||
|
||||
bool ReadTransform( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict );
|
||||
bool ReadSwitch( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict );
|
||||
bool ReadShape( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict );
|
||||
|
@ -47,7 +47,6 @@ namespace X3D
|
|||
bool ParseSFFloat( const wxString& aSource, float& aResult );
|
||||
bool ParseSFVec3( const wxString& aSource, WRLVEC3F& aResult );
|
||||
bool ParseSFRotation( const wxString& aSource, WRLROTATION& aResult );
|
||||
|
||||
}
|
||||
|
||||
#endif // X3D_OPS_H
|
||||
|
|
|
@ -61,17 +61,10 @@ X3DSHAPE::X3DSHAPE( X3DNODE* aParent ) : X3DNODE()
|
|||
|
||||
X3DSHAPE::~X3DSHAPE()
|
||||
{
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 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
|
||||
|
||||
return;
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Shape with %ul children, %ul references, "
|
||||
"%and ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,32 +245,16 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent )
|
|||
if( nullptr == geometry || nullptr == appearance )
|
||||
return nullptr;
|
||||
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 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() );
|
||||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_X3D
|
||||
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
|
||||
|
@ -35,30 +36,25 @@
|
|||
#include "wrltypes.h"
|
||||
|
||||
|
||||
/**
|
||||
* X3DSHAPE
|
||||
*/
|
||||
class X3DSHAPE : public X3DNODE
|
||||
{
|
||||
private:
|
||||
X3DNODE* appearance;
|
||||
X3DNODE* geometry;
|
||||
|
||||
public:
|
||||
X3DSHAPE();
|
||||
X3DSHAPE( X3DNODE* aParent );
|
||||
virtual ~X3DSHAPE();
|
||||
|
||||
// functions inherited from X3DNODE
|
||||
bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) override;
|
||||
bool SetParent( X3DNODE* aParent, bool doUnlink = true ) override;
|
||||
bool AddChildNode( X3DNODE* aNode ) override;
|
||||
bool AddRefNode( X3DNODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
// overrides
|
||||
virtual void unlinkChildNode( const X3DNODE* aNode ) override;
|
||||
virtual void unlinkRefNode( const X3DNODE* aNode ) override;
|
||||
|
||||
private:
|
||||
X3DNODE* appearance;
|
||||
X3DNODE* geometry;
|
||||
};
|
||||
|
||||
#endif // X3D_SHAPE_H
|
||||
|
|
|
@ -36,8 +36,6 @@ X3DTRANSFORM::X3DTRANSFORM() : X3DNODE()
|
|||
{
|
||||
m_Type = X3D_TRANSFORM;
|
||||
init();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
X3DTRANSFORM::X3DTRANSFORM( X3DNODE* aParent ) : X3DNODE()
|
||||
|
@ -55,24 +53,15 @@ X3DTRANSFORM::X3DTRANSFORM( X3DNODE* aParent ) : X3DNODE()
|
|||
|
||||
if( nullptr != m_Parent )
|
||||
m_Parent->AddChildNode( this );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
X3DTRANSFORM::~X3DTRANSFORM()
|
||||
{
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 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
|
||||
|
||||
return;
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Destroying Transform with %ul children, %ul references, "
|
||||
"%and ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,8 +85,6 @@ void X3DTRANSFORM::init()
|
|||
|
||||
bboxCenter = center;
|
||||
bboxSize = center;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -270,35 +257,19 @@ bool X3DTRANSFORM::AddRefNode( X3DNODE* aNode )
|
|||
|
||||
SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 )
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << " * [INFO] Translating Transform with " << m_Children.size();
|
||||
ostr << " children, " << m_Refs.size() << " references and ";
|
||||
ostr << m_BackPointers.size() << " backpointers";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( traceVrmlPlugin,
|
||||
wxT( " * [INFO] Translating Transform with %ul children, %ul references, "
|
||||
"%and ul back pointers." ),
|
||||
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
||||
|
||||
if( m_Children.empty() && m_Refs.empty() )
|
||||
return nullptr;
|
||||
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM )
|
||||
{
|
||||
#ifdef DEBUG_X3D
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [BUG] Transform does not have a Transform parent (parent ID: ";
|
||||
ostr << ptype << ")";
|
||||
wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
|
||||
wxString::Format( wxT( "Transform 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
|
||||
|
@ -35,12 +36,23 @@
|
|||
#include "wrltypes.h"
|
||||
|
||||
|
||||
/**
|
||||
* X3DTRANSFORM
|
||||
*/
|
||||
class X3DTRANSFORM : public X3DNODE
|
||||
{
|
||||
public:
|
||||
X3DTRANSFORM();
|
||||
X3DTRANSFORM( X3DNODE* aParent );
|
||||
virtual ~X3DTRANSFORM();
|
||||
|
||||
bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) override;
|
||||
bool SetParent( X3DNODE* aParent, bool doUnlink = true ) override;
|
||||
bool AddChildNode( X3DNODE* aNode ) override;
|
||||
bool AddRefNode( X3DNODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
void readFields( wxXmlNode* aNode );
|
||||
|
||||
WRLVEC3F center;
|
||||
WRLVEC3F scale;
|
||||
WRLVEC3F translation;
|
||||
|
@ -48,21 +60,6 @@ private:
|
|||
WRLROTATION scaleOrientation;
|
||||
WRLVEC3F bboxCenter;
|
||||
WRLVEC3F bboxSize;
|
||||
|
||||
void init();
|
||||
void readFields( wxXmlNode* aNode );
|
||||
|
||||
public:
|
||||
X3DTRANSFORM();
|
||||
X3DTRANSFORM( X3DNODE* aParent );
|
||||
virtual ~X3DTRANSFORM();
|
||||
|
||||
// functions inherited from X3DNODE
|
||||
bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) override;
|
||||
bool SetParent( X3DNODE* aParent, bool doUnlink = true ) override;
|
||||
bool AddChildNode( X3DNODE* aNode ) override;
|
||||
bool AddRefNode( X3DNODE* aNode ) override;
|
||||
SGNODE* TranslateToSG( SGNODE* aParent ) override;
|
||||
};
|
||||
|
||||
#endif // X3D_TRANSFORM_H
|
||||
|
|
|
@ -74,13 +74,10 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
m_error = ostr.str();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] failed on file " << aFullFileName.ToUTF8() << "\n";
|
||||
ostr << " * [INFO] error: " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] failed on file '%s'\n"
|
||||
" * [INFO] error: " ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aFullFileName.ToUTF8(), m_error );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -100,12 +97,11 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
|
||||
if( !m_getNExtensions )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetNExtensions')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetNExtensions')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
|
||||
|
@ -113,20 +109,16 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetModelExtension')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetModelExtension')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'GetModelExtension'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'GetModelExtension'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,20 +126,16 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetNFilters')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetNFilters')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'GetNFilters'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'GetNFilters'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,20 +143,16 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetFileFilter')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetFileFilter')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'GetFileFilter'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'GetFileFilter'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,20 +160,16 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'CanRender')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'CanRender')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'CanRender'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'CanRender'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,19 +177,14 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName )
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'Load')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'Load')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'Load'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'Load'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,10 +212,9 @@ void KICAD_PLUGIN_LDR_3D::Close( void )
|
|||
#ifdef DEBUG
|
||||
if( ok )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] closing plugin";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
" * [INFO] closing plugin" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -292,12 +266,9 @@ int KICAD_PLUGIN_LDR_3D::GetNExtensions( void )
|
|||
{
|
||||
m_error = "[BUG] GetNExtensions is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -322,12 +293,9 @@ char const* KICAD_PLUGIN_LDR_3D::GetModelExtension( int aIndex )
|
|||
{
|
||||
m_error = "[BUG] GetModelExtension is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -352,12 +320,9 @@ int KICAD_PLUGIN_LDR_3D::GetNFilters( void )
|
|||
{
|
||||
m_error = "[BUG] GetNFilters is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -382,12 +347,9 @@ char const* KICAD_PLUGIN_LDR_3D::GetFileFilter( int aIndex )
|
|||
{
|
||||
m_error = "[BUG] GetFileFilter is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -412,12 +374,9 @@ bool KICAD_PLUGIN_LDR_3D::CanRender( void )
|
|||
{
|
||||
m_error = "[BUG] CanRender is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -442,12 +401,9 @@ SCENEGRAPH* KICAD_PLUGIN_LDR_3D::Load( char const* aFileName )
|
|||
{
|
||||
m_error = "[BUG] Load is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 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
|
||||
|
@ -50,30 +51,17 @@ typedef SCENEGRAPH* (*PLUGIN_3D_LOAD) ( char const* aFileName );
|
|||
|
||||
class KICAD_PLUGIN_LDR_3D : public KICAD_PLUGIN_LDR
|
||||
{
|
||||
private:
|
||||
bool ok; // set TRUE if all functions are linked
|
||||
PLUGIN_3D_GET_N_EXTENSIONS m_getNExtensions;
|
||||
PLUGIN_3D_GET_MODEL_EXTENSION m_getModelExtension;
|
||||
PLUGIN_3D_GET_N_FILTERS m_getNFilters;
|
||||
PLUGIN_3D_GET_FILE_FILTER m_getFileFilter;
|
||||
PLUGIN_3D_CAN_RENDER m_canRender;
|
||||
PLUGIN_3D_LOAD m_load;
|
||||
|
||||
public:
|
||||
KICAD_PLUGIN_LDR_3D();
|
||||
virtual ~KICAD_PLUGIN_LDR_3D();
|
||||
|
||||
|
||||
// virtuals inherited from KICAD_PLUGIN_LDR
|
||||
bool Open( const wxString& aFullFileName ) override;
|
||||
|
||||
void Close( void ) override;
|
||||
|
||||
void GetLoaderVersion( unsigned char* Major, unsigned char* Minor,
|
||||
unsigned char* Revision, unsigned char* Patch ) const override;
|
||||
unsigned char* Revision, unsigned char* Patch ) const override;
|
||||
|
||||
|
||||
// these functions are shadows of the 3D Plugin functions from 3d_plugin.h
|
||||
int GetNExtensions( void );
|
||||
|
||||
char const* GetModelExtension( int aIndex );
|
||||
|
@ -85,6 +73,15 @@ public:
|
|||
bool CanRender( void );
|
||||
|
||||
SCENEGRAPH* Load( char const* aFileName );
|
||||
|
||||
private:
|
||||
bool ok; // set TRUE if all functions are linked
|
||||
PLUGIN_3D_GET_N_EXTENSIONS m_getNExtensions;
|
||||
PLUGIN_3D_GET_MODEL_EXTENSION m_getModelExtension;
|
||||
PLUGIN_3D_GET_N_FILTERS m_getNFilters;
|
||||
PLUGIN_3D_GET_FILE_FILTER m_getFileFilter;
|
||||
PLUGIN_3D_CAN_RENDER m_canRender;
|
||||
PLUGIN_3D_LOAD m_load;
|
||||
};
|
||||
|
||||
#endif // PLUGINMGR3D_H
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "pluginldr.h"
|
||||
|
||||
|
||||
const wxChar* const tracePluginLoader = wxT( "KICAD_PLUGIN_LOADER" );
|
||||
|
||||
|
||||
KICAD_PLUGIN_LDR::KICAD_PLUGIN_LDR()
|
||||
{
|
||||
ok = false;
|
||||
|
@ -68,12 +71,9 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
|
||||
if( !m_PluginLoader.IsLoaded() )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * could not open file: '" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( " * could not open file: '%s'" ),
|
||||
aFullFileName.ToUTF8() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,11 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
|
||||
if( !m_getPluginClass )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginClass')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetKicadPluginClass')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
|
||||
|
@ -101,20 +100,15 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetClassVersion')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetClassVersion')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'GetClassVersion'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'GetClassVersion'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,20 +116,16 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'CheckClassVersion')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'CheckClassVersion')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'CheckClassVersion'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'CheckClassVersion'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,20 +133,16 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginName')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetKicadPluginName')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
|
||||
fail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'GetKicadPluginName'";
|
||||
ostr << errmsg.ToUTF8();
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'GetKicadPluginName'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,19 +150,14 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
{
|
||||
if( !fail )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
wxString errmsg = "incompatible plugin (missing function 'GetVersion')";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
ostr << "'" << aFullFileName.ToUTF8() << "'";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
"incompatible plugin (missing function 'GetVersion')" ),
|
||||
__FILE__, __FUNCTION__, __LINE__ );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
wxString errmsg = "missing function 'GetVersion'";
|
||||
ostr << errmsg.ToUTF8() << "\n";
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
wxLogTrace( tracePluginLoader, wxT( "missing function 'GetVersion'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,8 +207,7 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
m_getClassVersion( &pMajor, &pMinor, &pPatch, &pRevno );
|
||||
GetLoaderVersion( &lMajor, &lMinor, &lPatch, &lRevno );
|
||||
|
||||
// major version changes by definition are incompatible and
|
||||
// that is enforced here.
|
||||
// major version changes by definition are incompatible and that is enforced here.
|
||||
if( pMajor != lMajor )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -253,19 +233,10 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC
|
|||
|
||||
m_fileName = aFullFileName;
|
||||
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * [INFO] opened plugin " << m_fileName.ToUTF8();
|
||||
char const* cp = m_getPluginName();
|
||||
|
||||
if( nullptr != cp )
|
||||
ostr << " * [INFO] plugin name: '" << cp << "'\n";
|
||||
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
} while( 0 );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader,
|
||||
wxT( "%s:%s:%d\n"
|
||||
" * [INFO] opened plugin '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_fileName );
|
||||
|
||||
ok = true;
|
||||
|
||||
|
@ -331,12 +302,9 @@ char const* KICAD_PLUGIN_LDR::GetKicadPluginClass( void )
|
|||
{
|
||||
m_error = "[BUG] GetPluginClass is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -379,12 +347,9 @@ bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Min
|
|||
{
|
||||
m_error = "[BUG] CheckClassVersion is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -424,12 +389,9 @@ bool KICAD_PLUGIN_LDR::CheckClassVersion( unsigned char Major, unsigned char Min
|
|||
{
|
||||
m_error = "[BUG] CheckClassVersion is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -454,12 +416,9 @@ const char* KICAD_PLUGIN_LDR::GetKicadPluginName( void )
|
|||
{
|
||||
m_error = "[BUG] GetKicadPluginName is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -485,12 +444,9 @@ bool KICAD_PLUGIN_LDR::GetVersion( unsigned char* Major, unsigned char* Minor,
|
|||
{
|
||||
m_error = "[BUG] GetKicadPluginName is not linked";
|
||||
|
||||
#ifdef DEBUG
|
||||
std::ostringstream ostr;
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
ostr << " * " << m_error;
|
||||
wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() );
|
||||
#endif
|
||||
wxLogTrace( tracePluginLoader, wxT( "%s:%s:%d\n"
|
||||
"%s" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, m_error );;
|
||||
|
||||
return 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
|
||||
|
@ -23,7 +24,7 @@
|
|||
|
||||
/**
|
||||
* @file pluginldr.h
|
||||
* defines the most basic functions which all kicad plugin loaders require.
|
||||
* defines the most basic functions which all KiCad plugin loaders require.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -34,6 +35,9 @@
|
|||
#include <wx/dynlib.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
// Mask for plugin loader tracing.
|
||||
extern const wxChar* const tracePluginLoader;
|
||||
|
||||
#define MASK_PLUGINLDR "PLUGIN_LOADER"
|
||||
|
||||
|
||||
|
@ -58,98 +62,89 @@ typedef void (*GET_VERSION) ( unsigned char*, unsigned char*,
|
|||
|
||||
class KICAD_PLUGIN_LDR
|
||||
{
|
||||
private:
|
||||
bool ok; // set TRUE if all functions are linked
|
||||
GET_PLUGIN_CLASS m_getPluginClass;
|
||||
GET_CLASS_VERSION m_getClassVersion;
|
||||
CHECK_CLASS_VERSION m_checkClassVersion;
|
||||
GET_PLUGIN_NAME m_getPluginName;
|
||||
GET_VERSION m_getVersion;
|
||||
|
||||
wxString m_fileName; // name of last opened Plugin
|
||||
std::string m_pluginInfo; // Name:Version tag for plugin
|
||||
|
||||
protected:
|
||||
std::string m_error; // error message
|
||||
|
||||
/**
|
||||
* Function open
|
||||
* opens a plugin of the specified class and links the extensions
|
||||
* required by kicad_plugin. Returns true on success otherwise
|
||||
* false.
|
||||
*/
|
||||
bool open( const wxString& aFullFileName, const char* aPluginClass );
|
||||
|
||||
/**
|
||||
* Function close
|
||||
* nullifies internal pointers in preparation for closing the plugin
|
||||
*/
|
||||
void close( void );
|
||||
|
||||
/**
|
||||
* Function reopen
|
||||
* reopens a plugin and returns true on success
|
||||
*/
|
||||
bool reopen( void );
|
||||
|
||||
// the plugin loader
|
||||
wxDynamicLibrary m_PluginLoader;
|
||||
|
||||
public:
|
||||
KICAD_PLUGIN_LDR();
|
||||
virtual ~KICAD_PLUGIN_LDR();
|
||||
|
||||
/**
|
||||
* Function GetLoaderVersion
|
||||
* returns the version information of the Plugin Loader
|
||||
* for plugin compatibility checking.
|
||||
* Return the version information of the Plugin Loader for plugin compatibility checking.
|
||||
*/
|
||||
virtual void GetLoaderVersion( unsigned char* Major, unsigned char* Minor,
|
||||
unsigned char* Patch, unsigned char* Revision ) const = 0;
|
||||
unsigned char* Patch, unsigned char* Revision ) const = 0;
|
||||
|
||||
/**
|
||||
* Function Open
|
||||
* opens a plugin of the given class, performs version compatibility checks,
|
||||
* Open a plugin of the given class, performs version compatibility checks,
|
||||
* and links all required functions.
|
||||
*
|
||||
* @return true on success, otherwise false and a message may be accessible
|
||||
* via GetLastError()
|
||||
* @return true on success or false if failure. An error message may be accessible
|
||||
* via GetLastError()
|
||||
*/
|
||||
virtual bool Open( const wxString& aFullFileName ) = 0;
|
||||
|
||||
/**
|
||||
* Function Close
|
||||
* cleans up and closes/unloads the plugin
|
||||
* Clean up and closes/unloads the plugin.
|
||||
*/
|
||||
virtual void Close( void ) = 0;
|
||||
|
||||
/**
|
||||
* Function GetLastError
|
||||
* returns the value of the internal error string
|
||||
* Return the value of the internal error string.
|
||||
*/
|
||||
std::string GetLastError( void ) const;
|
||||
|
||||
// the following functions are the equivalent of those required by kicad_plugin.h
|
||||
|
||||
// returns the Plugin Class or NULL if no plugin loaded
|
||||
// Return the Plugin Class or NULL if no plugin loaded.
|
||||
char const* GetKicadPluginClass( void );
|
||||
|
||||
// returns false if no plugin loaded
|
||||
// Return false if no plugin loaded.
|
||||
bool GetClassVersion( unsigned char* Major, unsigned char* Minor,
|
||||
unsigned char* Patch, unsigned char* Revision );
|
||||
unsigned char* Patch, unsigned char* Revision );
|
||||
|
||||
// returns false if the class version check fails or no plugin is loaded
|
||||
// Return false if the class version check fails or no plugin is loaded.
|
||||
bool CheckClassVersion( unsigned char Major, unsigned char Minor,
|
||||
unsigned char Patch, unsigned char Revision );
|
||||
unsigned char Patch, unsigned char Revision );
|
||||
|
||||
// returns the Plugin Name or NULL if no plugin loaded
|
||||
// Return the Plugin Name or NULL if no plugin loaded.
|
||||
const char* GetKicadPluginName( void );
|
||||
|
||||
// returns false if no plugin is loaded
|
||||
// Return false if no plugin is loaded.
|
||||
bool GetVersion( unsigned char* Major, unsigned char* Minor,
|
||||
unsigned char* Patch, unsigned char* Revision );
|
||||
unsigned char* Patch, unsigned char* Revision );
|
||||
|
||||
void GetPluginInfo( std::string& aPluginInfo );
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Open a plugin of the specified class and links the extensions required by kicad_plugin.
|
||||
*
|
||||
* @return true on success otherwise false.
|
||||
*/
|
||||
bool open( const wxString& aFullFileName, const char* aPluginClass );
|
||||
|
||||
/**
|
||||
* Nullify internal pointers in preparation for closing the plugin.
|
||||
*/
|
||||
void close( void );
|
||||
|
||||
/**
|
||||
* Reopen a plugin.
|
||||
*
|
||||
* @return true on success or false on failure.
|
||||
*/
|
||||
bool reopen( void );
|
||||
|
||||
std::string m_error; // error message
|
||||
|
||||
// the plugin loader
|
||||
wxDynamicLibrary m_PluginLoader;
|
||||
|
||||
private:
|
||||
bool ok; // set TRUE if all functions are linked
|
||||
GET_PLUGIN_CLASS m_getPluginClass;
|
||||
GET_CLASS_VERSION m_getClassVersion;
|
||||
CHECK_CLASS_VERSION m_checkClassVersion;
|
||||
GET_PLUGIN_NAME m_getPluginName;
|
||||
GET_VERSION m_getVersion;
|
||||
wxString m_fileName; // name of last opened Plugin
|
||||
std::string m_pluginInfo; // Name:Version tag for plugin
|
||||
};
|
||||
|
||||
#endif // PLUGINLDR_H
|
||||
|
|
Loading…
Reference in New Issue