28 #include <wx/string.h> 29 #include <wx/filename.h> 61 std::map< std::string, SGNODE* >::iterator iS =
m_inlineModels.begin();
62 std::map< std::string, SGNODE* >::iterator eS =
m_inlineModels.end();
81 wxCHECK_MSG(
false,
false, wxT(
"Attempt to set parent on WRL2BASE node." ) );
102 std::map< std::string, SGNODE* >::iterator dp =
m_inlineModels.find( aName );
109 if( aName.compare( 0, 7,
"file://" ) == 0 )
111 if( aName.length() <= 7 )
114 tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() );
118 tname = wxString::FromUTF8Unchecked( aName.c_str() );
124 if( fn.IsRelative() && !
m_dir.empty() )
126 wxString fname = wxString::FromUTF8Unchecked(
m_dir.c_str() );
127 fname.append( tname );
131 if( !fn.Normalize() )
133 m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName,
nullptr ) );
141 m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName,
nullptr ) );
153 wxCHECK_MSG(
false, std::string(
"" ), wxT(
"Attempt to extract name from base node." ) );
159 wxCHECK_MSG(
false,
false, wxT(
"Attempt to set name of base node." ) );
166 wxT(
"No open file or file is not a VRML2 file." ) );
171 while(
ReadNode( proc,
this, &node ) && !proc.
eof() );
189 if(
nullptr != aNode )
192 wxCHECK_MSG( aParent,
false, wxT(
"Invalid parent." ) );
200 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
211 " * [INFO] node '%s' not found." ),
212 __FILE__, __FUNCTION__, __LINE__, glob );
221 " * [INFO] failed to add node '%s' (%d) to parent of type %d" ),
222 __FILE__, __FUNCTION__, __LINE__, glob, ref->
GetNodeType(),
228 if(
nullptr != aNode )
237 if(
nullptr != aNode )
240 wxCHECK_MSG( aParent,
false, wxT(
"Invalid parent." ) );
249 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
254 if(
ReadNode( proc, aParent, &lnode ) )
256 if(
nullptr != aNode )
259 if( lnode && !lnode->
SetName( glob ) )
263 " * [INFO] bad formatting (invalid name) %s." ),
284 if(
nullptr != aNode )
287 wxCHECK_MSG( aParent,
false, wxT(
"Invalid parent." ) );
296 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
312 if( !glob.compare(
"USE" ) )
318 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
326 if( !glob.compare(
"DEF" ) )
332 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
341 if( !glob.compare(
"PROTO" ) )
347 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
356 if( !glob.compare(
"EXTERNPROTO" ) )
362 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
371 if( !glob.compare(
"ROUTE" ) )
377 __FILE__, __FUNCTION__, __LINE__ , proc.
GetError() );
387 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] Processing node '%s' ID: %d" ), glob, ntype );
403 if( !
readBox( proc, aParent, aNode ) )
419 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard %s node %s." ),
443 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard %s node %s." ),
460 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard %s node %s." ),
477 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard %s node %s." ),
536 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard %s node %s." ),
614 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard %s node %s." ),
634 wxCHECK_MSG(
false,
false, wxT(
"This method must never be invoked on a WRL2BASE object." ) );
640 if(
nullptr != aNode )
645 if( !np->
Read( proc,
this ) )
651 if(
nullptr != aNode )
660 if(
nullptr != aNode )
665 if( !np->
Read( proc,
this ) )
671 if(
nullptr != aNode )
680 if(
nullptr != aNode )
685 if( !np->
Read( proc,
this ) )
691 if(
nullptr != aNode )
700 if(
nullptr != aNode )
705 if( !np->
Read( proc,
this ) )
711 if(
nullptr != aNode )
720 if(
nullptr != aNode )
725 if( !np->
Read( proc,
this ) )
731 if(
nullptr != aNode )
740 if(
nullptr != aNode )
745 if( !np->
Read( proc,
this ) )
751 if(
nullptr != aNode )
760 if(
nullptr != aNode )
765 if( !np->
Read( proc,
this ) )
771 if(
nullptr != aNode )
780 if(
nullptr != aNode )
785 if( !np->
Read( proc,
this ) )
791 if(
nullptr != aNode )
800 if(
nullptr != aNode )
805 if( !np->
Read( proc,
this ) )
811 if(
nullptr != aNode )
820 if(
nullptr != aNode )
825 if( !np->
Read( proc,
this ) )
831 if(
nullptr != aNode )
840 if(
nullptr != aNode )
845 if( !np->
Read( proc,
this ) )
851 if(
nullptr != aNode )
860 if(
nullptr != aNode )
865 if( !np->
Read( proc,
this ) )
871 if(
nullptr != aNode )
880 if(
nullptr != aNode )
887 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] failed to discard in line node %s." ),
898 if( !np->
Read( proc,
this ) )
904 if(
nullptr != aNode )
918 if(
nullptr != aParent )
937 std::list< WRL2NODE* >::iterator sC =
m_Children.begin();
938 std::list< WRL2NODE* >::iterator eC =
m_Children.end();
946 type = (*sC)->GetNodeType();
955 SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
957 if(
nullptr != pshape )
970 if(
nullptr != (*sC)->TranslateToSG( topNode.
GetRawPtr() ) )
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
std::list< WRL2NODE * > m_Children
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
WRLVERSION GetVRMLType(void)
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
The base class of all Scene Graph nodes.
collects header files for all SG* wrappers and the API
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
SGNODE * GetRawPtr(void) noexcept
Function GetRawPtr() returns the raw internal SGNODE pointer.
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
virtual bool SetName(const std::string &aName)
WRL2NODES getNodeTypeID(const std::string &aNodeName)
SGNODE * GetInlineData(const std::string &aName)
bool isDangling(void) override
Determine whether an object should be moved to a different parent during the VRML to SG* translation.
bool ReadGlob(std::string &aGlob)
void SetEnableInline(bool enable)
bool GetEnableInline(void)
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
std::string GetFilePosition() const
std::map< std::string, SGNODE * > m_inlineModels
WRL2NODES GetNodeType(void) const
const char * GetParentDir(void)
The top node of a VRML2 model.
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
virtual bool SetName(const std::string &aName) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool ReadName(std::string &aName)
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
virtual std::string GetName(void) override
bool SetParent(WRL2NODE *aParent, bool doUnlink=true) override
Set the parent WRL2NODE of this object.
Define the basic data set required to represent a 3D model.
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
SCENEGRAPH * LoadVRML(const wxString &aFileName, bool useInline)
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
std::string GetError(void)
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
void Destroy(void)
Function Destroy deletes the object held by this wrapper.
virtual bool AddRefNode(WRL2NODE *aNode)
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
virtual WRL2NODE * FindNode(const std::string &aNodeName, const WRL2NODE *aCaller)
Search the tree of linked nodes and returns a reference to the first node found with the given name.
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
SGNODE * TranslateToSG(SGNODE *aParent) override
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)