KiCad PCB EDA Suite
WRL2BASE Class Reference

The top node of a VRML2 model. More...

#include <vrml2_base.h>

Inheritance diagram for WRL2BASE:
WRL2NODE

Public Member Functions

 WRL2BASE ()
 
virtual ~WRL2BASE ()
 
void SetEnableInline (bool enable)
 
bool GetEnableInline (void)
 
SGNODEGetInlineData (const std::string &aName)
 
bool Read (WRLPROC &proc)
 
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
 Set the parent WRL2NODE of this object. More...
 
SGNODETranslateToSG (SGNODE *aParent) override
 Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg library. More...
 
bool isDangling (void) override
 Determine whether an object should be moved to a different parent during the VRML to SG* translation. More...
 
WRL2NODES GetNodeType (void) const
 
WRL2NODEGetParent (void) const
 
const char * GetNodeTypeName (WRL2NODES aNodeType) const
 
virtual WRL2NODEFindNode (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. More...
 
virtual bool AddChildNode (WRL2NODE *aNode)
 
virtual bool AddRefNode (WRL2NODE *aNode)
 
std::string GetError (void)
 
WRL2NODES getNodeTypeID (const std::string &aNodeName)
 
virtual void unlinkChildNode (const WRL2NODE *aNode)
 Remove references to an owned child. More...
 
virtual void unlinkRefNode (const WRL2NODE *aNode)
 Remove pointers to a referenced node. More...
 
void addNodeRef (WRL2NODE *aNode)
 Add a pointer to a node which references but does not own this node. More...
 
void delNodeRef (WRL2NODE *aNode)
 Remove a pointer to a node which references but does not own this node. More...
 

Protected Attributes

WRL2NODEm_Parent
 
WRL2NODES m_Type
 
std::string m_Name
 
std::list< WRL2NODE * > m_BackPointers
 
std::list< WRL2NODE * > m_Children
 
std::list< WRL2NODE * > m_Refs
 
std::string m_error
 
SGNODEm_sgNode
 

Private Member Functions

bool implementUse (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool implementDef (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readTransform (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readShape (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readAppearance (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readMaterial (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readFaceSet (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readLineSet (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readPointSet (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readCoords (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readNorms (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readColor (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readBox (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readSwitch (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readInline (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 

Private Attributes

bool m_useInline
 
std::string m_dir
 
std::map< std::string, SGNODE * > m_inlineModels
 

Detailed Description

The top node of a VRML2 model.

Definition at line 59 of file vrml2_base.h.

Constructor & Destructor Documentation

◆ WRL2BASE()

WRL2BASE::WRL2BASE ( )

Definition at line 52 of file vrml2_base.cpp.

52  : WRL2NODE()
53 {
54  m_useInline = false;
56 }
WRL2NODES m_Type
Definition: vrml2_node.h:170
bool m_useInline
Definition: vrml2_base.h:106

References WRL2NODE::m_Type, m_useInline, and WRL2_BASE.

◆ ~WRL2BASE()

WRL2BASE::~WRL2BASE ( )
virtual

Definition at line 59 of file vrml2_base.cpp.

60 {
61  std::map< std::string, SGNODE* >::iterator iS = m_inlineModels.begin();
62  std::map< std::string, SGNODE* >::iterator eS = m_inlineModels.end();
63 
64  while( iS != eS )
65  {
66  SGNODE* np = iS->second;
67 
68  // destroy any orphaned Inline{} node data
69  if( np && nullptr == S3D::GetSGNodeParent( np ) )
70  S3D::DestroyNode( np );
71 
72  ++iS;
73  }
74 
75  m_inlineModels.clear();
76 }
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:492
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.
Definition: ifsg_api.cpp:148
std::map< std::string, SGNODE * > m_inlineModels
Definition: vrml2_base.h:108

References S3D::DestroyNode(), S3D::GetSGNodeParent(), and m_inlineModels.

Member Function Documentation

◆ AddChildNode()

bool WRL2NODE::AddChildNode ( WRL2NODE aNode)
virtualinherited

Reimplemented in WRL2COLOR, WRL2COORDS, WRL2FACESET, WRL2LINESET, WRL2NORMS, WRL2POINTSET, WRL2APPEARANCE, WRL2BOX, WRL2INLINE, WRL2MATERIAL, and WRL2SHAPE.

Definition at line 356 of file vrml2_node.cpp.

357 {
358  wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
359  wxCHECK_MSG( aNode->GetNodeType() != WRL2NODES::WRL2_BASE, false,
360  wxT( "Attempting to add a base node to another node." ) );
361 
362 
363  std::list< WRL2NODE* >::iterator sC = m_Children.begin();
364  std::list< WRL2NODE* >::iterator eC = m_Children.end();
365 
366  while( sC != eC )
367  {
368  if( *sC == aNode )
369  return false;
370 
371  ++sC;
372  }
373 
374  m_Children.push_back( aNode );
375 
376  if( aNode->GetParent() != this )
377  aNode->SetParent( this );
378 
379  return true;
380 }
virtual bool SetParent(WRL2NODE *aParent, bool doUnlink=true)
Set the parent WRL2NODE of this object.
Definition: vrml2_node.cpp:339
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204
WRL2NODE * GetParent(void) const
Definition: vrml2_node.cpp:210

References WRL2NODE::GetNodeType(), WRL2NODE::GetParent(), WRL2NODE::m_Children, WRL2NODE::SetParent(), and WRL2_BASE.

Referenced by WRL2APPEARANCE::AddChildNode(), WRL2SHAPE::AddChildNode(), WRL2LINESET::AddChildNode(), WRL2FACESET::AddChildNode(), WRL2POINTSET::AddChildNode(), WRL2SWITCH::AddRefNode(), WRL2TRANSFORM::AddRefNode(), WRL2NODE::SetParent(), WRL2APPEARANCE::WRL2APPEARANCE(), WRL2BOX::WRL2BOX(), WRL2COLOR::WRL2COLOR(), WRL2COORDS::WRL2COORDS(), WRL2FACESET::WRL2FACESET(), WRL2INLINE::WRL2INLINE(), WRL2LINESET::WRL2LINESET(), WRL2MATERIAL::WRL2MATERIAL(), WRL2NORMS::WRL2NORMS(), WRL2POINTSET::WRL2POINTSET(), WRL2SHAPE::WRL2SHAPE(), WRL2SWITCH::WRL2SWITCH(), and WRL2TRANSFORM::WRL2TRANSFORM().

◆ addNodeRef()

void WRL2NODE::addNodeRef ( WRL2NODE aNode)
inherited

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.

Parameters
aNodeis the node holding a reference to this object.

Definition at line 171 of file vrml2_node.cpp.

172 {
173  // the parent node must never be added as a backpointer
174  if( aNode == m_Parent )
175  return;
176 
177  std::list< WRL2NODE* >::iterator np =
178  std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
179 
180  if( np != m_BackPointers.end() )
181  return;
182 
183  m_BackPointers.push_back( aNode );
184 }
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173

References WRL2NODE::m_BackPointers, and WRL2NODE::m_Parent.

Referenced by WRL2NODE::AddRefNode().

◆ AddRefNode()

bool WRL2NODE::AddRefNode ( WRL2NODE aNode)
virtualinherited

Reimplemented in WRL2COLOR, WRL2COORDS, WRL2FACESET, WRL2LINESET, WRL2NORMS, WRL2POINTSET, WRL2SWITCH, WRL2TRANSFORM, WRL2APPEARANCE, WRL2BOX, WRL2INLINE, WRL2MATERIAL, and WRL2SHAPE.

Definition at line 383 of file vrml2_node.cpp.

384 {
385  wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
386  wxCHECK_MSG( aNode->GetNodeType() != WRL2NODES::WRL2_BASE, false,
387  wxT( "Attempt to add a base node reference to another base node" ) );
388 
389  std::list< WRL2NODE* >::iterator sR = m_Refs.begin();
390  std::list< WRL2NODE* >::iterator eR = m_Refs.end();
391 
392  while( sR != eR )
393  {
394  if( *sR == aNode )
395  return true;
396 
397  ++sR;
398  }
399 
400  m_Refs.push_back( aNode );
401  aNode->addNodeRef( this );
402 
403  return true;
404 }
void addNodeRef(WRL2NODE *aNode)
Add a pointer to a node which references but does not own this node.
Definition: vrml2_node.cpp:171
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204

References WRL2NODE::addNodeRef(), WRL2NODE::GetNodeType(), WRL2NODE::m_Refs, and WRL2_BASE.

Referenced by WRL2APPEARANCE::AddRefNode(), WRL2SHAPE::AddRefNode(), WRL2TRANSFORM::AddRefNode(), WRL2SWITCH::AddRefNode(), WRL2POINTSET::AddRefNode(), WRL2LINESET::AddRefNode(), WRL2FACESET::AddRefNode(), and implementUse().

◆ delNodeRef()

void WRL2NODE::delNodeRef ( WRL2NODE aNode)
inherited

Remove a pointer to a node which references but does not own this node.

Parameters
aNodeis the node holding a reference to this object

Definition at line 187 of file vrml2_node.cpp.

188 {
189  std::list< WRL2NODE* >::iterator np =
190  std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
191 
192  if( np != m_BackPointers.end() )
193  {
194  m_BackPointers.erase( np );
195  return;
196  }
197 
198  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
199  " * [BUG] delNodeRef() did not find its target." ),
200  __FILE__, __FUNCTION__, __LINE__ );
201 }
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63

References WRL2NODE::m_BackPointers, and traceVrmlPlugin.

◆ FindNode()

WRL2NODE * WRL2NODE::FindNode ( const std::string &  aNodeName,
const WRL2NODE aCaller 
)
virtualinherited

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().

Parameters
aNodeNameis the name of the node to search for.
aCalleris a pointer to the node invoking this function.
Returns
is a valid node pointer on success or NULL.

Definition at line 305 of file vrml2_node.cpp.

306 {
307  if( aNodeName.empty() )
308  return nullptr;
309 
310  if( !m_Name.compare( aNodeName ) )
311  return this;
312 
313  std::list< WRL2NODE* >::iterator sLA = m_Children.begin();
314  std::list< WRL2NODE* >::iterator eLA = m_Children.end();
315 
316  WRL2NODE* psg = nullptr;
317 
318  while( sLA != eLA )
319  {
320  if( *sLA != aCaller )
321  {
322  psg = (*sLA)->FindNode( aNodeName, this );
323 
324  if( nullptr != psg )
325  return psg;
326 
327  }
328 
329  ++sLA;
330  }
331 
332  if( nullptr != m_Parent && aCaller != m_Parent )
333  return m_Parent->FindNode( aNodeName, this );
334 
335  return nullptr;
336 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
std::string m_Name
Definition: vrml2_node.h:171
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
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.
Definition: vrml2_node.cpp:305

References WRL2NODE::FindNode(), WRL2NODE::m_Children, WRL2NODE::m_Name, and WRL2NODE::m_Parent.

Referenced by WRL2NODE::FindNode(), and implementUse().

◆ GetEnableInline()

bool WRL2BASE::GetEnableInline ( void  )

Definition at line 91 of file vrml2_base.cpp.

92 {
93  return m_useInline;
94 }
bool m_useInline
Definition: vrml2_base.h:106

References m_useInline.

◆ GetError()

std::string WRL2NODE::GetError ( void  )
inherited

Definition at line 299 of file vrml2_node.cpp.

300 {
301  return m_error;
302 }
std::string m_error
Definition: vrml2_node.h:176

References WRL2NODE::m_error.

◆ GetInlineData()

SGNODE * WRL2BASE::GetInlineData ( const std::string &  aName)

Definition at line 97 of file vrml2_base.cpp.

98 {
99  if( aName.empty() )
100  return nullptr;
101 
102  std::map< std::string, SGNODE* >::iterator dp = m_inlineModels.find( aName );
103 
104  if( dp != m_inlineModels.end() )
105  return dp->second;
106 
107  wxString tname;
108 
109  if( aName.compare( 0, 7, "file://" ) == 0 )
110  {
111  if( aName.length() <= 7 )
112  return nullptr;
113 
114  tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() );
115  }
116  else
117  {
118  tname = wxString::FromUTF8Unchecked( aName.c_str() );
119  }
120 
121  wxFileName fn;
122  fn.Assign( tname );
123 
124  if( fn.IsRelative() && !m_dir.empty() )
125  {
126  wxString fname = wxString::FromUTF8Unchecked( m_dir.c_str() );
127  fname.append( tname );
128  fn.Assign( fname );
129  }
130 
131  if( !fn.Normalize() )
132  {
133  m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, nullptr ) );
134  return nullptr;
135  }
136 
137  SCENEGRAPH* sp = LoadVRML( fn.GetFullPath(), false );
138 
139  if( nullptr == sp )
140  {
141  m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, nullptr ) );
142  return nullptr;
143  }
144 
145  m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, (SGNODE*)sp ) );
146 
147  return (SGNODE*)sp;
148 }
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
std::map< std::string, SGNODE * > m_inlineModels
Definition: vrml2_base.h:108
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:44
SCENEGRAPH * LoadVRML(const wxString &aFileName, bool useInline)
Definition: vrml.cpp:170
std::string m_dir
Definition: vrml2_base.h:107

References LoadVRML(), m_dir, and m_inlineModels.

Referenced by WRL2INLINE::TranslateToSG().

◆ GetName()

std::string WRL2BASE::GetName ( void  )
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 151 of file vrml2_base.cpp.

152 {
153  wxCHECK_MSG( false, std::string( "" ), wxT( "Attempt to extract name from base node." ) );
154 }

◆ GetNodeType()

◆ getNodeTypeID()

WRL2NODES WRL2NODE::getNodeTypeID ( const std::string &  aNodeName)
inherited
Returns
The ID based on the given aNodeName or WRL2_INVALID (WRL2_END) if no such node name exists.

Definition at line 288 of file vrml2_node.cpp.

289 {
290  NODEMAP::iterator it = nodenames.find( aNodeName );
291 
292  if( nodenames.end() != it )
293  return it->second;
294 
296 }
static NODEMAP nodenames
Definition: vrml2_node.cpp:43

References nodenames, and WRL2_INVALID.

Referenced by ReadNode().

◆ GetNodeTypeName()

const char * WRL2NODE::GetNodeTypeName ( WRL2NODES  aNodeType) const
inherited

Definition at line 273 of file vrml2_node.cpp.

274 {
275  if( aNodeType < WRL2NODES::WRL2_BASE || aNodeType >= WRL2NODES::WRL2_END )
276  return "*INVALID_TYPE*";
277 
278  if( aNodeType == WRL2NODES::WRL2_BASE )
279  return "*VIRTUAL_BASE*";
280 
281  NODEMAP::iterator it = nodenames.begin();
282  advance( it, (static_cast<int>( aNodeType ) - static_cast<int>( WRL2NODES::WRL2_BEGIN ) ) );
283 
284  return it->first.c_str();
285 }
static NODEMAP nodenames
Definition: vrml2_node.cpp:43

References nodenames, WRL2_BASE, WRL2_BEGIN, and WRL2_END.

Referenced by WRL2APPEARANCE::AddChildNode(), WRL2SHAPE::AddChildNode(), WRL2FACESET::AddChildNode(), WRL2LINESET::AddChildNode(), WRL2POINTSET::AddChildNode(), WRL2APPEARANCE::AddRefNode(), WRL2SHAPE::AddRefNode(), WRL2FACESET::AddRefNode(), WRL2POINTSET::AddRefNode(), and WRL2LINESET::AddRefNode().

◆ GetParent()

WRL2NODE * WRL2NODE::GetParent ( void  ) const
inherited

◆ implementDef()

bool WRL2BASE::implementDef ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 235 of file vrml2_base.cpp.

236 {
237  if( nullptr != aNode )
238  *aNode = nullptr;
239 
240  wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
241 
242  std::string glob;
243  WRL2NODE* lnode = nullptr;
244 
245  if( !proc.ReadName( glob ) )
246  {
247  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
248  "%s" ),
249  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
250 
251  return false;
252  }
253 
254  if( ReadNode( proc, aParent, &lnode ) )
255  {
256  if( nullptr != aNode )
257  *aNode = lnode;
258 
259  if( lnode && !lnode->SetName( glob ) )
260  {
261  wxLogTrace( traceVrmlPlugin,
262  wxT( "%s:%s:%d\n"
263  " * [INFO] bad formatting (invalid name) %s." ),
264  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
265 
266  return false;
267  }
268 
269  return true;
270  }
271 
272  return false;
273 }
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:276
virtual bool SetName(const std::string &aName)
Definition: vrml2_node.cpp:222
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
std::string GetError(void)
Definition: wrlproc.cpp:1960

References WRLPROC::GetError(), WRLPROC::GetFilePosition(), WRLPROC::ReadName(), ReadNode(), WRL2NODE::SetName(), and traceVrmlPlugin.

Referenced by ReadNode().

◆ implementUse()

bool WRL2BASE::implementUse ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 187 of file vrml2_base.cpp.

188 {
189  if( nullptr != aNode )
190  *aNode = nullptr;
191 
192  wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
193 
194  std::string glob;
195 
196  if( !proc.ReadName( glob ) )
197  {
198  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
199  "%s" ),
200  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
201 
202  return false;
203  }
204 
205  WRL2NODE* ref = aParent->FindNode( glob, nullptr );
206 
207  // return 'true' - the file may be defective but it may still be somewhat OK
208  if( nullptr == ref )
209  {
210  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
211  " * [INFO] node '%s' not found." ),
212  __FILE__, __FUNCTION__, __LINE__, glob );
213 
214  return true;
215  }
216 
217  if( !aParent->AddRefNode( ref ) )
218  {
219  wxLogTrace( traceVrmlPlugin,
220  wxT( "%s:%s:%d\n"
221  " * [INFO] failed to add node '%s' (%d) to parent of type %d" ),
222  __FILE__, __FUNCTION__, __LINE__, glob, ref->GetNodeType(),
223  aParent->GetNodeType() );
224 
225  return false;
226  }
227 
228  if( nullptr != aNode )
229  *aNode = ref;
230 
231  return true;
232 }
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
std::string GetError(void)
Definition: wrlproc.cpp:1960
virtual bool AddRefNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:383
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.
Definition: vrml2_node.cpp:305

References WRL2NODE::AddRefNode(), WRL2NODE::FindNode(), WRLPROC::GetError(), WRL2NODE::GetNodeType(), WRLPROC::ReadName(), and traceVrmlPlugin.

Referenced by ReadNode().

◆ isDangling()

bool WRL2BASE::isDangling ( void  )
overridevirtual

Determine whether an object should be moved to a different parent during the VRML to SG* translation.

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.

Implements WRL2NODE.

Definition at line 180 of file vrml2_base.cpp.

181 {
182  // the base node is never dangling
183  return false;
184 }

◆ Read() [1/2]

bool WRL2BASE::Read ( WRLPROC proc)

Definition at line 163 of file vrml2_base.cpp.

164 {
165  wxCHECK_MSG( proc.GetVRMLType() == WRLVERSION::VRML_V2, false,
166  wxT( "No open file or file is not a VRML2 file." ) );
167 
168  WRL2NODE* node = nullptr;
169  m_dir = proc.GetParentDir();
170 
171  while( ReadNode( proc, this, &node ) && !proc.eof() );
172 
173  if( proc.eof() )
174  return true;
175 
176  return false;
177 }
WRLVERSION GetVRMLType(void)
Definition: wrlproc.cpp:230
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:276
const char * GetParentDir(void)
Definition: wrlproc.cpp:236
bool eof(void)
Definition: wrlproc.cpp:1954
std::string m_dir
Definition: vrml2_base.h:107

References WRLPROC::eof(), WRLPROC::GetParentDir(), WRLPROC::GetVRMLType(), m_dir, ReadNode(), and VRML_V2.

Referenced by LoadVRML().

◆ Read() [2/2]

bool WRL2BASE::Read ( WRLPROC proc,
WRL2BASE aTopNode 
)
overridevirtual

Implements WRL2NODE.

Definition at line 632 of file vrml2_base.cpp.

633 {
634  wxCHECK_MSG( false, false, wxT( "This method must never be invoked on a WRL2BASE object." ) );
635 }

◆ readAppearance()

bool WRL2BASE::readAppearance ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 678 of file vrml2_base.cpp.

679 {
680  if( nullptr != aNode )
681  *aNode = nullptr;
682 
683  WRL2APPEARANCE* np = new WRL2APPEARANCE( aParent );
684 
685  if( !np->Read( proc, this ) )
686  {
687  delete np;
688  return false;
689  }
690 
691  if( nullptr != aNode )
692  *aNode = (WRL2NODE*) np;
693 
694  return true;
695 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2APPEARANCE::Read().

Referenced by ReadNode().

◆ readBox()

bool WRL2BASE::readBox ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 838 of file vrml2_base.cpp.

839 {
840  if( nullptr != aNode )
841  *aNode = nullptr;
842 
843  WRL2BOX* np = new WRL2BOX( aParent );
844 
845  if( !np->Read( proc, this ) )
846  {
847  delete np;
848  return false;
849  }
850 
851  if( nullptr != aNode )
852  *aNode = (WRL2NODE*) np;
853 
854  return true;
855 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition: vrml2_box.cpp:74

References WRL2BOX::Read().

Referenced by ReadNode().

◆ readColor()

bool WRL2BASE::readColor ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 818 of file vrml2_base.cpp.

819 {
820  if( nullptr != aNode )
821  *aNode = nullptr;
822 
823  WRL2COLOR* np = new WRL2COLOR( aParent );
824 
825  if( !np->Read( proc, this ) )
826  {
827  delete np;
828  return false;
829  }
830 
831  if( nullptr != aNode )
832  *aNode = (WRL2NODE*) np;
833 
834  return true;
835 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition: vrml2_color.cpp:80

References WRL2COLOR::Read().

Referenced by ReadNode().

◆ readCoords()

bool WRL2BASE::readCoords ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 778 of file vrml2_base.cpp.

779 {
780  if( nullptr != aNode )
781  *aNode = nullptr;
782 
783  WRL2COORDS* np = new WRL2COORDS( aParent );
784 
785  if( !np->Read( proc, this ) )
786  {
787  delete np;
788  return false;
789  }
790 
791  if( nullptr != aNode )
792  *aNode = (WRL2NODE*) np;
793 
794  return true;
795 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2COORDS::Read().

Referenced by ReadNode().

◆ readFaceSet()

bool WRL2BASE::readFaceSet ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 718 of file vrml2_base.cpp.

719 {
720  if( nullptr != aNode )
721  *aNode = nullptr;
722 
723  WRL2FACESET* np = new WRL2FACESET( aParent );
724 
725  if( !np->Read( proc, this ) )
726  {
727  delete np;
728  return false;
729  }
730 
731  if( nullptr != aNode )
732  *aNode = (WRL2NODE*) np;
733 
734  return true;
735 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2FACESET::Read().

Referenced by ReadNode().

◆ readInline()

bool WRL2BASE::readInline ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 878 of file vrml2_base.cpp.

879 {
880  if( nullptr != aNode )
881  *aNode = nullptr;
882 
883  if( !m_useInline )
884  {
885  if( !proc.DiscardNode() )
886  {
887  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard in line node %s." ),
888  proc.GetFilePosition() );
889 
890  return false;
891  }
892 
893  return true;
894  }
895 
896  WRL2INLINE* np = new WRL2INLINE( aParent );
897 
898  if( !np->Read( proc, this ) )
899  {
900  delete np;
901  return false;
902  }
903 
904  if( nullptr != aNode )
905  *aNode = (WRL2NODE*) np;
906 
907  return true;
908 }
bool DiscardNode(void)
Definition: wrlproc.cpp:368
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
bool m_useInline
Definition: vrml2_base.h:106
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRLPROC::DiscardNode(), WRLPROC::GetFilePosition(), m_useInline, WRL2INLINE::Read(), and traceVrmlPlugin.

Referenced by ReadNode().

◆ readLineSet()

bool WRL2BASE::readLineSet ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 738 of file vrml2_base.cpp.

739 {
740  if( nullptr != aNode )
741  *aNode = nullptr;
742 
743  WRL2LINESET* np = new WRL2LINESET( aParent );
744 
745  if( !np->Read( proc, this ) )
746  {
747  delete np;
748  return false;
749  }
750 
751  if( nullptr != aNode )
752  *aNode = (WRL2NODE*) np;
753 
754  return true;
755 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2LINESET::Read().

Referenced by ReadNode().

◆ readMaterial()

bool WRL2BASE::readMaterial ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 698 of file vrml2_base.cpp.

699 {
700  if( nullptr != aNode )
701  *aNode = nullptr;
702 
703  WRL2MATERIAL* np = new WRL2MATERIAL( aParent );
704 
705  if( !np->Read( proc, this ) )
706  {
707  delete np;
708  return false;
709  }
710 
711  if( nullptr != aNode )
712  *aNode = (WRL2NODE*) np;
713 
714  return true;
715 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2MATERIAL::Read().

Referenced by ReadNode().

◆ ReadNode()

bool WRL2BASE::ReadNode ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)

Definition at line 276 of file vrml2_base.cpp.

277 {
278  // This function reads a node and stores a pointer to it in aNode.
279  // A value 'true' is returned if a node is successfully read or,
280  // if the node is not supported, successfully discarded. Callers
281  // must always check the value of aNode when the function returns
282  // 'true' since it will be NULL if the node type is not supported.
283 
284  if( nullptr != aNode )
285  *aNode = nullptr;
286 
287  wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
288 
289  std::string glob;
290  WRL2NODES ntype;
291 
292  if( !proc.ReadName( glob ) )
293  {
294  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
295  "%s" ),
296  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
297 
298  return false;
299  }
300 
301  // Process node name:
302  // the names encountered at this point should be one of the
303  // built-in node names or one of:
304  // DEF, USE
305  // PROTO, EXTERNPROTO
306  // ROUTE
307  // any PROTO or EXTERNPROTO defined name
308  // since we do not support PROTO or EXTERNPROTO, any unmatched names are
309  // assumed to be defined via PROTO/EXTERNPROTO and deleted according to
310  // a typical pattern.
311 
312  if( !glob.compare( "USE" ) )
313  {
314  if( !implementUse( proc, aParent, aNode ) )
315  {
316  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
317  "%s" ),
318  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
319 
320  return false;
321  }
322 
323  return true;
324  }
325 
326  if( !glob.compare( "DEF" ) )
327  {
328  if( !implementDef( proc, aParent, aNode ) )
329  {
330  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
331  "%s" ),
332  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
333 
334  return false;
335  }
336 
337  return true;
338  }
339 
340  // pattern to skip: PROTO name list
341  if( !glob.compare( "PROTO" ) )
342  {
343  if( !proc.ReadName( glob ) || !proc.DiscardList() )
344  {
345  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
346  "%s" ),
347  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
348 
349  return false;
350  }
351 
352  return true;
353  }
354 
355  // pattern to skip: EXTERNPROTO name1 name2 list
356  if( !glob.compare( "EXTERNPROTO" ) )
357  {
358  if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() )
359  {
360  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
361  "%s" ),
362  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
363 
364  return false;
365  }
366 
367  return true;
368  }
369 
370  // pattern to skip: ROUTE glob1 glob2 glob3
371  if( !glob.compare( "ROUTE" ) )
372  {
373  if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) )
374  {
375  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
376  "%s" ),
377  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
378 
379  return false;
380  }
381 
382  return true;
383  }
384 
385  ntype = getNodeTypeID( glob );
386 
387  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Processing node '%s' ID: %d" ), glob, ntype );
388 
389  switch( ntype )
390  {
391  //
392  // items to be implemented:
393  //
395 
396  if( !readAppearance( proc, aParent, aNode ) )
397  return false;
398 
399  break;
400 
401  case WRL2NODES::WRL2_BOX:
402 
403  if( !readBox( proc, aParent, aNode ) )
404  return false;
405 
406  break;
407 
409 
410  if( !readColor( proc, aParent, aNode ) )
411  return false;
412 
413  break;
414 
416  // XXX - IMPLEMENT
417  if( !proc.DiscardNode() )
418  {
419  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
420  glob, proc.GetFilePosition() );
421 
422  return false;
423  }
424  else
425  {
426  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
427  glob, proc.GetFilePosition() );
428  }
429 
430  break;
431 
433 
434  if( !readCoords( proc, aParent, aNode ) )
435  return false;
436 
437  break;
438 
440  // XXX - IMPLEMENT
441  if( !proc.DiscardNode() )
442  {
443  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
444  glob, proc.GetFilePosition() );
445 
446  return false;
447  }
448  else
449  {
450  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
451  glob, proc.GetFilePosition() );
452  }
453 
454  break;
455 
457  // XXX - IMPLEMENT
458  if( !proc.DiscardNode() )
459  {
460  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
461  glob, proc.GetFilePosition() );
462 
463  return false;
464  }
465  else
466  {
467  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
468  glob, proc.GetFilePosition() );
469  }
470 
471  break;
472 
474  // XXX - IMPLEMENT
475  if( !proc.DiscardNode() )
476  {
477  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
478  glob, proc.GetFilePosition() );
479 
480  return false;
481  }
482  else
483  {
484  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
485  glob, proc.GetFilePosition() );
486  }
487 
488  break;
489 
491 
492  if( !readFaceSet( proc, aParent, aNode ) )
493  return false;
494 
495  break;
496 
498 
499  if( !readLineSet( proc, aParent, aNode ) )
500  return false;
501 
502  break;
503 
505 
506  if( !readPointSet( proc, aParent, aNode ) )
507  return false;
508 
509  break;
510 
512 
513  if( !readMaterial( proc, aParent, aNode ) )
514  return false;
515 
516  break;
517 
519 
520  if( !readNorms( proc, aParent, aNode ) )
521  return false;
522 
523  break;
524 
526 
527  if( !readShape( proc, aParent, aNode ) )
528  return false;
529 
530  break;
531 
533  // XXX - IMPLEMENT
534  if( !proc.DiscardNode() )
535  {
536  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
537  glob, proc.GetFilePosition() );
538 
539  return false;
540  }
541  else
542  {
543  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
544  glob, proc.GetFilePosition() );
545  }
546 
547  break;
548 
550 
551  if( !readSwitch( proc, aParent, aNode ) )
552  return false;
553 
554  break;
555 
558 
559  if( !readTransform( proc, aParent, aNode ) )
560  return false;
561 
562  break;
563 
565 
566  if( !readInline( proc, aParent, aNode ) )
567  return false;
568 
569  break;
570 
571  //
572  // items not implemented or for optional future implementation:
573  //
583  case WRL2NODES::WRL2_FOG:
586  case WRL2NODES::WRL2_LOD:
610  default:
611 
612  if( !proc.DiscardNode() )
613  {
614  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
615  glob, proc.GetFilePosition() );
616 
617  return false;
618  }
619  else
620  {
621  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
622  glob, proc.GetFilePosition() );
623  }
624 
625  break;
626  }
627 
628  return true;
629 }
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:235
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:658
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:698
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:738
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:778
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:678
WRL2NODES getNodeTypeID(const std::string &aNodeName)
Definition: vrml2_node.cpp:288
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:245
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:818
bool DiscardNode(void)
Definition: wrlproc.cpp:368
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:718
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:638
WRL2NODES
Definition: wrltypes.h:124
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:858
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:798
std::string GetError(void)
Definition: wrlproc.cpp:1960
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:838
bool DiscardList(void)
Definition: wrlproc.cpp:491
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:758
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:878
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:187

References WRLPROC::DiscardList(), WRLPROC::DiscardNode(), WRLPROC::GetError(), WRLPROC::GetFilePosition(), WRL2NODE::getNodeTypeID(), implementDef(), implementUse(), readAppearance(), readBox(), readColor(), readCoords(), readFaceSet(), WRLPROC::ReadGlob(), readInline(), readLineSet(), readMaterial(), WRLPROC::ReadName(), readNorms(), readPointSet(), readShape(), readSwitch(), readTransform(), traceVrmlPlugin, WRL2_ANCHOR, WRL2_APPEARANCE, WRL2_AUDIOCLIP, WRL2_BACKGROUND, WRL2_BILLBOARD, WRL2_BOX, WRL2_COLLISION, WRL2_COLOR, WRL2_COLORINTERPOLATOR, WRL2_CONE, WRL2_COORDINATE, WRL2_COORDINATEINTERPOLATOR, WRL2_CYLINDER, WRL2_CYLINDERSENSOR, WRL2_DIRECTIONALLIGHT, WRL2_ELEVATIONGRID, WRL2_EXTRUSION, WRL2_FOG, WRL2_FONTSTYLE, WRL2_GROUP, WRL2_IMAGETEXTURE, WRL2_INDEXEDFACESET, WRL2_INDEXEDLINESET, WRL2_INLINE, WRL2_INVALID, WRL2_LOD, WRL2_MATERIAL, WRL2_MOVIETEXTURE, WRL2_NAVIGATIONINFO, WRL2_NORMAL, WRL2_NORMALINTERPOLATOR, WRL2_ORIENTATIONINTERPOLATOR, WRL2_PIXELTEXTURE, WRL2_PLANESENSOR, WRL2_POINTLIGHT, WRL2_POINTSET, WRL2_POSITIONINTERPOLATOR, WRL2_PROXIMITYSENSOR, WRL2_SCALARINTERPOLATOR, WRL2_SCRIPT, WRL2_SHAPE, WRL2_SOUND, WRL2_SPHERE, WRL2_SPHERESENSOR, WRL2_SPOTLIGHT, WRL2_SWITCH, WRL2_TEXT, WRL2_TEXTURECOORDINATE, WRL2_TEXTURETRANSFORM, WRL2_TIMESENSOR, WRL2_TOUCHSENSOR, WRL2_TRANSFORM, WRL2_VIEWPOINT, WRL2_VISIBILITYSENSOR, and WRL2_WORLDINFO.

Referenced by implementDef(), WRL2APPEARANCE::Read(), WRL2SHAPE::Read(), WRL2FACESET::Read(), WRL2LINESET::Read(), WRL2POINTSET::Read(), Read(), WRL2TRANSFORM::readChildren(), and WRL2SWITCH::readChildren().

◆ readNorms()

bool WRL2BASE::readNorms ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 798 of file vrml2_base.cpp.

799 {
800  if( nullptr != aNode )
801  *aNode = nullptr;
802 
803  WRL2NORMS* np = new WRL2NORMS( aParent );
804 
805  if( !np->Read( proc, this ) )
806  {
807  delete np;
808  return false;
809  }
810 
811  if( nullptr != aNode )
812  *aNode = (WRL2NODE*) np;
813 
814  return true;
815 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition: vrml2_norms.cpp:81

References WRL2NORMS::Read().

Referenced by ReadNode().

◆ readPointSet()

bool WRL2BASE::readPointSet ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 758 of file vrml2_base.cpp.

759 {
760  if( nullptr != aNode )
761  *aNode = nullptr;
762 
763  WRL2POINTSET* np = new WRL2POINTSET( aParent );
764 
765  if( !np->Read( proc, this ) )
766  {
767  delete np;
768  return false;
769  }
770 
771  if( nullptr != aNode )
772  *aNode = (WRL2NODE*) np;
773 
774  return true;
775 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2POINTSET::Read().

Referenced by ReadNode().

◆ readShape()

bool WRL2BASE::readShape ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 658 of file vrml2_base.cpp.

659 {
660  if( nullptr != aNode )
661  *aNode = nullptr;
662 
663  WRL2SHAPE* np = new WRL2SHAPE( aParent );
664 
665  if( !np->Read( proc, this ) )
666  {
667  delete np;
668  return false;
669  }
670 
671  if( nullptr != aNode )
672  *aNode = (WRL2NODE*) np;
673 
674  return true;
675 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2SHAPE::Read().

Referenced by ReadNode().

◆ readSwitch()

bool WRL2BASE::readSwitch ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 858 of file vrml2_base.cpp.

859 {
860  if( nullptr != aNode )
861  *aNode = nullptr;
862 
863  WRL2SWITCH* np = new WRL2SWITCH( aParent );
864 
865  if( !np->Read( proc, this ) )
866  {
867  delete np;
868  return false;
869  }
870 
871  if( nullptr != aNode )
872  *aNode = (WRL2NODE*) np;
873 
874  return true;
875 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2SWITCH::Read().

Referenced by ReadNode().

◆ readTransform()

bool WRL2BASE::readTransform ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 638 of file vrml2_base.cpp.

639 {
640  if( nullptr != aNode )
641  *aNode = nullptr;
642 
643  WRL2TRANSFORM* np = new WRL2TRANSFORM( aParent );
644 
645  if( !np->Read( proc, this ) )
646  {
647  delete np;
648  return false;
649  }
650 
651  if( nullptr != aNode )
652  *aNode = (WRL2NODE*) np;
653 
654  return true;
655 }
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2TRANSFORM::Read().

Referenced by ReadNode().

◆ SetEnableInline()

void WRL2BASE::SetEnableInline ( bool  enable)

Definition at line 85 of file vrml2_base.cpp.

86 {
87  m_useInline = enable;
88 }
bool m_useInline
Definition: vrml2_base.h:106

References m_useInline.

Referenced by LoadVRML().

◆ SetName()

bool WRL2BASE::SetName ( const std::string &  aName)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 157 of file vrml2_base.cpp.

158 {
159  wxCHECK_MSG( false, false, wxT( "Attempt to set name of base node." ) );
160 }

◆ SetParent()

bool WRL2BASE::SetParent ( WRL2NODE aParent,
bool  doUnlink = true 
)
overridevirtual

Set the parent WRL2NODE of this object.

Parameters
aParent[in] is the desired parent node.
doUnlinkindicates that the child must be unlinked from the parent
Returns
true if the operation succeeds of false if the given node is not allowed to be a parent to the derived object.

Reimplemented from WRL2NODE.

Definition at line 79 of file vrml2_base.cpp.

80 {
81  wxCHECK_MSG( false, false, wxT( "Attempt to set parent on WRL2BASE node." ) );
82 }

◆ TranslateToSG()

SGNODE * WRL2BASE::TranslateToSG ( SGNODE aParent)
overridevirtual

Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg library.

Parameters
aParentis a pointer to the parent SG node.
Returns
is non-NULL on success.

Implements WRL2NODE.

Definition at line 911 of file vrml2_base.cpp.

912 {
913  if( m_Children.empty() )
914  return nullptr;
915 
916  if( m_sgNode )
917  {
918  if( nullptr != aParent )
919  {
920  if( nullptr == S3D::GetSGNodeParent( m_sgNode )
921  && !S3D::AddSGNodeChild( aParent, m_sgNode ) )
922  {
923  return nullptr;
924  }
925  else if( aParent != S3D::GetSGNodeParent( m_sgNode )
926  && !S3D::AddSGNodeRef( aParent, m_sgNode ) )
927  {
928  return nullptr;
929  }
930  }
931 
932  return m_sgNode;
933  }
934 
935  IFSG_TRANSFORM topNode( aParent );
936 
937  std::list< WRL2NODE* >::iterator sC = m_Children.begin();
938  std::list< WRL2NODE* >::iterator eC = m_Children.end();
939  WRL2NODES type;
940 
941  // Include only Shape and Transform nodes in the top node
942  bool test = false; // set to true if there are any subnodes for display
943 
944  while( sC != eC )
945  {
946  type = (*sC)->GetNodeType();
947 
948  switch( type )
949  {
951  // wrap the shape in a transform
952  do
953  {
954  IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
955  SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
956 
957  if( nullptr != pshape )
958  test = true;
959  else
960  wrapper.Destroy();
961 
962  } while( 0 );
963 
964  break;
965 
969 
970  if( nullptr != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
971  test = true;
972 
973  break;
974 
975  default:
976  break;
977  }
978 
979  ++ sC;
980  }
981 
982  if( false == test )
983  {
984  topNode.Destroy();
985  return nullptr;
986  }
987 
988  m_sgNode = topNode.GetRawPtr();
989 
990  return m_sgNode;
991 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:492
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:501
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:510
SGNODE * m_sgNode
Definition: vrml2_node.h:178
IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH.
WRL2NODES
Definition: wrltypes.h:124

References S3D::AddSGNodeChild(), S3D::AddSGNodeRef(), IFSG_NODE::Destroy(), IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), WRL2NODE::m_Children, WRL2NODE::m_sgNode, WRL2_INLINE, WRL2_SHAPE, WRL2_SWITCH, and WRL2_TRANSFORM.

Referenced by LoadVRML().

◆ unlinkChildNode()

void WRL2NODE::unlinkChildNode ( const WRL2NODE aNode)
virtualinherited

Remove references to an owned child.

It is invoked by the child upon destruction to ensure that the parent has no invalid references.

Parameters
aNodeis the child which is being deleted.

Reimplemented in WRL2FACESET, WRL2LINESET, WRL2POINTSET, WRL2APPEARANCE, and WRL2SHAPE.

Definition at line 407 of file vrml2_node.cpp.

408 {
409  std::list< WRL2NODE* >::iterator sL = m_Children.begin();
410  std::list< WRL2NODE* >::iterator eL = m_Children.end();
411 
412  while( sL != eL )
413  {
414  if( *sL == aNode )
415  {
416  m_Children.erase( sL );
417  return;
418  }
419 
420  ++sL;
421  }
422 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174

References WRL2NODE::m_Children.

Referenced by WRL2NODE::SetParent(), WRL2APPEARANCE::unlinkChildNode(), WRL2SHAPE::unlinkChildNode(), WRL2FACESET::unlinkChildNode(), WRL2LINESET::unlinkChildNode(), WRL2POINTSET::unlinkChildNode(), and WRL2NODE::~WRL2NODE().

◆ unlinkRefNode()

void WRL2NODE::unlinkRefNode ( const WRL2NODE aNode)
virtualinherited

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.

Parameters
aNodeis the node which is being deleted.

Reimplemented in WRL2FACESET, WRL2LINESET, WRL2POINTSET, WRL2APPEARANCE, and WRL2SHAPE.

Definition at line 425 of file vrml2_node.cpp.

426 {
427  std::list< WRL2NODE* >::iterator sL = m_Refs.begin();
428  std::list< WRL2NODE* >::iterator eL = m_Refs.end();
429 
430  while( sL != eL )
431  {
432  if( *sL == aNode )
433  {
434  m_Refs.erase( sL );
435  return;
436  }
437 
438  ++sL;
439  }
440 }
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175

References WRL2NODE::m_Refs.

Referenced by WRL2APPEARANCE::unlinkRefNode(), WRL2SHAPE::unlinkRefNode(), WRL2POINTSET::unlinkRefNode(), WRL2LINESET::unlinkRefNode(), and WRL2FACESET::unlinkRefNode().

Member Data Documentation

◆ m_BackPointers

◆ m_Children

◆ m_dir

std::string WRL2BASE::m_dir
private

Definition at line 107 of file vrml2_base.h.

Referenced by GetInlineData(), and Read().

◆ m_error

std::string WRL2NODE::m_error
protectedinherited

Definition at line 176 of file vrml2_node.h.

Referenced by WRL2NODE::GetError().

◆ m_inlineModels

std::map< std::string, SGNODE* > WRL2BASE::m_inlineModels
private

Definition at line 108 of file vrml2_base.h.

Referenced by GetInlineData(), and ~WRL2BASE().

◆ m_Name

std::string WRL2NODE::m_Name
protectedinherited

Definition at line 171 of file vrml2_node.h.

Referenced by WRL2NODE::FindNode(), WRL2NODE::GetName(), and WRL2NODE::SetName().

◆ m_Parent

◆ m_Refs

◆ m_sgNode

◆ m_Type

◆ m_useInline

bool WRL2BASE::m_useInline
private

Definition at line 106 of file vrml2_base.h.

Referenced by GetEnableInline(), readInline(), SetEnableInline(), and WRL2BASE().


The documentation for this class was generated from the following files: