KiCad PCB EDA Suite
WRL1NODE Class Referenceabstract

WRL1NODE represents the base class of all VRML1 nodes. More...

#include <vrml1_node.h>

Inheritance diagram for WRL1NODE:
WRL1BASE WRL1COORDS WRL1FACESET WRL1GROUP WRL1MATBINDING WRL1MATERIAL WRL1SEPARATOR WRL1SHAPEHINTS WRL1SWITCH WRL1TRANSFORM

Public Member Functions

void cancelDict (void)
 
WRL1NODES getNodeTypeID (const std::string &aNodeName)
 Function getNodeTypeID returns the ID based on the given aNodeName or WRL1_INVALID (WRL1_END) if no such node name exists. More...
 
virtual void unlinkChildNode (const WRL1NODE *aNode)
 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. More...
 
virtual void unlinkRefNode (const WRL1NODE *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. More...
 
void addNodeRef (WRL1NODE *aNode)
 Function addNodeRef adds a pointer to a node which references, but does not own, this node. More...
 
void delNodeRef (WRL1NODE *aNode)
 Function delNodeRef removes a pointer to a node which references, but does not own, this node. More...
 
 WRL1NODE (NAMEREGISTER *aDictionary)
 
virtual ~WRL1NODE ()
 
virtual bool Read (WRLPROC &proc, WRL1BASE *aTopNode)=0
 
WRL1NODES GetNodeType (void) const
 Function GetNodeType returns the type of this node instance. More...
 
WRL1NODEGetParent (void) const
 Function GetParent returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie. More...
 
virtual bool SetParent (WRL1NODE *aParent, bool doUnlink=true)
 Function SetParent sets the parent WRL1NODE of this object. More...
 
virtual std::string GetName (void)
 
virtual bool SetName (const std::string &aName)
 
const char * GetNodeTypeName (WRL1NODES aNodeType) const
 
size_t GetNItems (void) const
 
virtual WRL1NODEFindNode (const std::string &aNodeName)
 Function FindNode searches the tree of linked nodes and returns a reference to the current node with the given name. More...
 
virtual bool AddChildNode (WRL1NODE *aNode)
 
virtual bool AddRefNode (WRL1NODE *aNode)
 
std::string GetError (void)
 
virtual SGNODETranslateToSG (SGNODE *aParent, WRL1STATUS *sp)=0
 Function TranslateToSG produces a representation of the data using the intermediate scenegraph structures of the kicad_3dsg library. More...
 

Protected Attributes

WRL1NODEm_Parent
 
WRL1NODES m_Type
 
std::string m_Name
 
std::list< WRL1NODE * > m_BackPointers
 
std::list< WRL1NODE * > m_Children
 
std::list< WRL1NODE * > m_Refs
 
std::list< WRL1NODE * > m_Items
 
std::string m_error
 
WRL1STATUS m_current
 
SGNODEm_sgNode
 
NAMEREGISTERm_dictionary
 

Private Member Functions

void addItem (WRL1NODE *aNode)
 
void delItem (const WRL1NODE *aNode)
 

Detailed Description

WRL1NODE represents the base class of all VRML1 nodes.

Definition at line 111 of file vrml1_node.h.

Constructor & Destructor Documentation

◆ WRL1NODE()

WRL1NODE::WRL1NODE ( NAMEREGISTER aDictionary)

Definition at line 93 of file vrml1_node.cpp.

94 {
95  m_sgNode = NULL;
96  m_Parent = NULL;
97  m_Type = WRL1_END;
98  m_dictionary = aDictionary;
99 
100  if( nodenames.empty() )
101  {
102  nodenames.insert( NODEITEM( "AsciiText", WRL1_ASCIITEXT ) );
103  nodenames.insert( NODEITEM( "Cone", WRL1_CONE ) );
104  nodenames.insert( NODEITEM( "Coordinate3", WRL1_COORDINATE3 ) );
105  nodenames.insert( NODEITEM( "Cube", WRL1_CUBE ) );
106  nodenames.insert( NODEITEM( "Cylinder", WRL1_CYLINDER ) );
107  nodenames.insert( NODEITEM( "DirectionalLight", WRL1_DIRECTIONALLIGHT ) );
108  nodenames.insert( NODEITEM( "FontStyle", WRL1_FONTSTYLE ) );
109  nodenames.insert( NODEITEM( "Group", WRL1_GROUP ) );
110  nodenames.insert( NODEITEM( "IndexedFaceSet", WRL1_INDEXEDFACESET ) );
111  nodenames.insert( NODEITEM( "IndexedLineSet", WRL1_INDEXEDLINESET ) );
112  nodenames.insert( NODEITEM( "Info", WRL1_INFO ) );
113  nodenames.insert( NODEITEM( "LOD", WRL1_LOD ) );
114  nodenames.insert( NODEITEM( "Material", WRL1_MATERIAL ) );
115  nodenames.insert( NODEITEM( "MaterialBinding", WRL1_MATERIALBINDING ) );
116  nodenames.insert( NODEITEM( "MatrixTransform", WRL1_MATRIXTRANSFORM ) );
117  nodenames.insert( NODEITEM( "Normal", WRL1_NORMAL ) );
118  nodenames.insert( NODEITEM( "NormalBinding", WRL1_NORMALBINDING ) );
119  nodenames.insert( NODEITEM( "OrthographicCamera", WRL1_ORTHOCAMERA ) );
120  nodenames.insert( NODEITEM( "PerspectiveCamera", WRL1_PERSPECTIVECAMERA ) );
121  nodenames.insert( NODEITEM( "PointLight", WRL1_POINTLIGHT ) );
122  nodenames.insert( NODEITEM( "PointSet", WRL1_POINTSET ) );
123  nodenames.insert( NODEITEM( "Rotation", WRL1_ROTATION ) );
124  nodenames.insert( NODEITEM( "Scale", WRL1_SCALE ) );
125  nodenames.insert( NODEITEM( "Separator", WRL1_SEPARATOR ) );
126  nodenames.insert( NODEITEM( "ShapeHints", WRL1_SHAPEHINTS ) );
127  nodenames.insert( NODEITEM( "Sphere", WRL1_SPHERE ) );
128  nodenames.insert( NODEITEM( "SpotLight", WRL1_SPOTLIGHT ) );
129  nodenames.insert( NODEITEM( "Switch", WRL1_SWITCH ) );
130  nodenames.insert( NODEITEM( "Texture2", WRL1_TEXTURE2 ) );
131  nodenames.insert( NODEITEM( "Testure2Transform", WRL1_TEXTURE2TRANSFORM ) );
132  nodenames.insert( NODEITEM( "TextureCoordinate2", WRL1_TEXTURECOORDINATE2 ) );
133  nodenames.insert( NODEITEM( "Transform", WRL1_TRANSFORM ) );
134  nodenames.insert( NODEITEM( "Translation", WRL1_TRANSLATION ) );
135  nodenames.insert( NODEITEM( "WWWAnchor", WRL1_WWWANCHOR ) );
136  nodenames.insert( NODEITEM( "WWWInline", WRL1_WWWINLINE ) );
137  }
138 
139  return;
140 }
#define NULL
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:138
static NODEMAP nodenames
Definition: vrml1_node.cpp:87
WRL1NODES m_Type
Definition: vrml1_node.h:119
std::pair< std::string, WRL1NODES > NODEITEM
Definition: vrml1_node.cpp:85
WRL1NODE * m_Parent
Definition: vrml1_node.h:118
SGNODE * m_sgNode
Definition: vrml1_node.h:129

References m_dictionary, m_Parent, m_sgNode, m_Type, nodenames, NULL, WRL1_ASCIITEXT, WRL1_CONE, WRL1_COORDINATE3, WRL1_CUBE, WRL1_CYLINDER, WRL1_DIRECTIONALLIGHT, WRL1_END, WRL1_FONTSTYLE, WRL1_GROUP, WRL1_INDEXEDFACESET, WRL1_INDEXEDLINESET, WRL1_INFO, WRL1_LOD, WRL1_MATERIAL, WRL1_MATERIALBINDING, WRL1_MATRIXTRANSFORM, WRL1_NORMAL, WRL1_NORMALBINDING, WRL1_ORTHOCAMERA, WRL1_PERSPECTIVECAMERA, WRL1_POINTLIGHT, WRL1_POINTSET, WRL1_ROTATION, WRL1_SCALE, WRL1_SEPARATOR, WRL1_SHAPEHINTS, WRL1_SPHERE, WRL1_SPOTLIGHT, WRL1_SWITCH, WRL1_TEXTURE2, WRL1_TEXTURE2TRANSFORM, WRL1_TEXTURECOORDINATE2, WRL1_TRANSFORM, WRL1_TRANSLATION, WRL1_WWWANCHOR, and WRL1_WWWINLINE.

◆ ~WRL1NODE()

WRL1NODE::~WRL1NODE ( )
virtual

Definition at line 143 of file vrml1_node.cpp.

144 {
145  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
146  do {
147  std::ostringstream ostr;
148  ostr << " * [INFO] ^^ Destroying Type " << m_Type << " with " << m_Children.size();
149  ostr << " children, " << m_Refs.size() << " references and ";
150  ostr << m_BackPointers.size() << " backpointers";
151  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
152  } while( 0 );
153  #endif
154 
155  m_Items.clear();
156 
157  if( m_dictionary && !m_Name.empty() )
158  m_dictionary->DelName( m_Name, this );
159 
160  if( m_Parent )
161  m_Parent->unlinkChildNode( this );
162 
163  std::list< WRL1NODE* >::iterator sBP = m_BackPointers.begin();
164  std::list< WRL1NODE* >::iterator eBP = m_BackPointers.end();
165 
166  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
167  int acc = 0;
168  #endif
169 
170  while( sBP != eBP )
171  {
172  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
173  ++acc;
174  do {
175  std::ostringstream ostr;
176  ostr << " * [INFO] " << tabs << "Type " << m_Type << " is Unlinking ref #";
177  ostr << acc;
178  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
179  } while( 0 );
180  #endif
181  (*sBP)->unlinkRefNode( this );
182  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
183  do {
184  std::ostringstream ostr;
185  ostr << " * [INFO] " << tabs << "Type " << m_Type << " has unlinked ref #";
186  ostr << acc;
187  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
188  } while( 0 );
189  #endif
190  ++sBP;
191  }
192 
193  m_Refs.clear();
194 
195  std::list< WRL1NODE* >::iterator sC = m_Children.begin();
196  std::list< WRL1NODE* >::iterator eC = m_Children.end();
197 
198  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
199  std::string otabs = tabs;
200  tabs.append( " " );
201  #endif
202 
203  while( sC != eC )
204  {
205  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
206  ++acc;
207  do {
208  std::ostringstream ostr;
209  ostr << " * [INFO] " << otabs << "Type " << m_Type << " is Deleting child #";
210  ostr << acc;
211  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
212  } while( 0 );
213  #endif
214  (*sC)->SetParent( NULL, false );
215  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
216  do {
217  std::ostringstream ostr;
218  ostr << " * [INFO] " << otabs << "Type " << m_Type << " has unlinked child #";
219  ostr << acc;
220  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
221  } while( 0 );
222  #endif
223  delete *sC;
224  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
225  do {
226  std::ostringstream ostr;
227  ostr << " * [INFO] " << otabs << "Type " << m_Type << " has deleted child #";
228  ostr << acc;
229  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
230  } while( 0 );
231  #endif
232  ++sC;
233  }
234 
235  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 )
236  tabs = otabs;
237  #endif
238 
239  m_Children.clear();
240  return;
241 }
#define MASK_VRML
Definition: wrltypes.h:37
std::string m_Name
Definition: vrml1_node.h:120
std::list< WRL1NODE * > m_BackPointers
Definition: vrml1_node.h:122
bool DelName(const std::string &aName, WRL1NODE *aNode)
Definition: vrml1_node.cpp:54
#define NULL
std::list< WRL1NODE * > m_Refs
Definition: vrml1_node.h:124
virtual void unlinkChildNode(const WRL1NODE *aNode)
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: vrml1_node.cpp:520
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:138
WRL1NODES m_Type
Definition: vrml1_node.h:119
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:125
WRL1NODE * m_Parent
Definition: vrml1_node.h:118
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:123

References NAMEREGISTER::DelName(), m_BackPointers, m_Children, m_dictionary, m_Items, m_Name, m_Parent, m_Refs, m_Type, MASK_VRML, NULL, and unlinkChildNode().

Member Function Documentation

◆ AddChildNode()

bool WRL1NODE::AddChildNode ( WRL1NODE aNode)
virtual

Reimplemented in WRL1MATERIAL, WRL1FACESET, WRL1TRANSFORM, WRL1COORDS, WRL1SHAPEHINTS, and WRL1MATBINDING.

Definition at line 442 of file vrml1_node.cpp.

443 {
444  if( aNode->GetNodeType() == WRL1_BASE )
445  {
446  #ifdef DEBUG_VRML1
447  do {
448  std::ostringstream ostr;
449  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
450  ostr << " * [BUG] attempting to add a base node to another node";
451  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
452  } while( 0 );
453  #endif
454 
455  return false;
456  }
457 
458  std::list< WRL1NODE* >::iterator sC = m_Children.begin();
459  std::list< WRL1NODE* >::iterator eC = m_Children.end();
460 
461  while( sC != eC )
462  {
463  if( *sC == aNode )
464  return false;
465 
466  ++sC;
467  }
468 
469  m_Children.push_back( aNode );
470  addItem( aNode );
471 
472  if( aNode->GetParent() != this )
473  aNode->SetParent( this );
474 
475  return true;
476 }
#define MASK_VRML
Definition: wrltypes.h:37
WRL1NODE * GetParent(void) const
Function GetParent returns a pointer to the parent SGNODE of this object or NULL if the object has no...
Definition: vrml1_node.cpp:316
virtual bool SetParent(WRL1NODE *aParent, bool doUnlink=true)
Function SetParent sets the parent WRL1NODE of this object.
Definition: vrml1_node.cpp:425
WRL1NODES GetNodeType(void) const
Function GetNodeType returns the type of this node instance.
Definition: vrml1_node.cpp:310
void addItem(WRL1NODE *aNode)
Definition: vrml1_node.cpp:562
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:123

References addItem(), GetNodeType(), GetParent(), m_Children, MASK_VRML, SetParent(), and WRL1_BASE.

Referenced by SetParent(), WRL1COORDS::WRL1COORDS(), WRL1FACESET::WRL1FACESET(), WRL1GROUP::WRL1GROUP(), WRL1MATBINDING::WRL1MATBINDING(), WRL1MATERIAL::WRL1MATERIAL(), WRL1SEPARATOR::WRL1SEPARATOR(), WRL1SHAPEHINTS::WRL1SHAPEHINTS(), WRL1SWITCH::WRL1SWITCH(), and WRL1TRANSFORM::WRL1TRANSFORM().

◆ addItem()

void WRL1NODE::addItem ( WRL1NODE aNode)
private

Definition at line 562 of file vrml1_node.cpp.

563 {
564  m_Items.push_back( aNode );
565  return;
566 }
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:125

References m_Items.

Referenced by AddChildNode(), and AddRefNode().

◆ addNodeRef()

void WRL1NODE::addNodeRef ( WRL1NODE 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

Parameters
aNodeis the node holding a reference to this object

Definition at line 263 of file vrml1_node.cpp.

264 {
265  // the parent node must never be added as a backpointer
266  if( aNode == m_Parent )
267  return;
268 
269  std::list< WRL1NODE* >::iterator sR = m_BackPointers.begin();
270  std::list< WRL1NODE* >::iterator eR = m_BackPointers.end();
271 
272  while( sR != eR )
273  {
274  if( *sR == aNode )
275  return;
276 
277  ++sR;
278  }
279 
280  m_BackPointers.push_back( aNode );
281 
282  return;
283 }
std::list< WRL1NODE * > m_BackPointers
Definition: vrml1_node.h:122
WRL1NODE * m_Parent
Definition: vrml1_node.h:118

References m_BackPointers, and m_Parent.

Referenced by AddRefNode().

◆ AddRefNode()

bool WRL1NODE::AddRefNode ( WRL1NODE aNode)
virtual

Reimplemented in WRL1MATERIAL, WRL1FACESET, WRL1TRANSFORM, WRL1COORDS, WRL1SHAPEHINTS, and WRL1MATBINDING.

Definition at line 479 of file vrml1_node.cpp.

480 {
481  if( NULL == aNode )
482  {
483  #ifdef DEBUG_VRML1
484  do {
485  std::ostringstream ostr;
486  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
487  ostr << " * [BUG] NULL passed as node pointer";
488  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
489  } while( 0 );
490  #endif
491 
492  return false;
493  }
494 
495  if( aNode->GetNodeType() == WRL1_BASE )
496  {
497  #ifdef DEBUG_VRML1
498  do {
499  std::ostringstream ostr;
500  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
501  ostr << " * [BUG] attempting to add a base node ref to another base node";
502  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
503  } while( 0 );
504  #endif
505 
506  return false;
507  }
508 
509  // note: the VRML1 spec does not prevent the reuse of a node at
510  // the same level; for example a Coordinate3 node can be recalled
511  // at any time to set the current coordinate set.
512  m_Refs.push_back( aNode );
513  aNode->addNodeRef( this );
514  addItem( aNode );
515 
516  return true;
517 }
void addNodeRef(WRL1NODE *aNode)
Function addNodeRef adds a pointer to a node which references, but does not own, this node.
Definition: vrml1_node.cpp:263
#define MASK_VRML
Definition: wrltypes.h:37
#define NULL
std::list< WRL1NODE * > m_Refs
Definition: vrml1_node.h:124
WRL1NODES GetNodeType(void) const
Function GetNodeType returns the type of this node instance.
Definition: vrml1_node.cpp:310
void addItem(WRL1NODE *aNode)
Definition: vrml1_node.cpp:562

References addItem(), addNodeRef(), GetNodeType(), m_Refs, MASK_VRML, NULL, and WRL1_BASE.

Referenced by WRL1BASE::implementUse().

◆ cancelDict()

void WRL1NODE::cancelDict ( void  )

Definition at line 244 of file vrml1_node.cpp.

245 {
246  std::list< WRL1NODE* >::iterator sC = m_Children.begin();
247  std::list< WRL1NODE* >::iterator eC = m_Children.end();
248 
249  while( sC != eC )
250  {
251  (*sC)->cancelDict();
252  ++sC;
253  }
254 
255  if( m_Type == WRL1_BASE && NULL != m_dictionary )
256  delete m_dictionary;
257 
258  m_dictionary = NULL;
259  return;
260 }
#define NULL
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:138
WRL1NODES m_Type
Definition: vrml1_node.h:119
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:123

References m_Children, m_dictionary, m_Type, NULL, and WRL1_BASE.

Referenced by WRL1BASE::~WRL1BASE().

◆ delItem()

void WRL1NODE::delItem ( const WRL1NODE aNode)
private

Definition at line 569 of file vrml1_node.cpp.

570 {
571  std::list< WRL1NODE* >::iterator sL = m_Items.begin();
572  std::list< WRL1NODE* >::iterator eL = m_Items.end();
573 
574  while( sL != eL )
575  {
576  if( *sL == aNode )
577  {
578  m_Items.erase( sL );
579  return;
580  }
581 
582  ++sL;
583  }
584 
585  return;
586 }
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:125

References m_Items.

Referenced by unlinkChildNode(), and unlinkRefNode().

◆ delNodeRef()

void WRL1NODE::delNodeRef ( WRL1NODE aNode)

Function delNodeRef removes 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 286 of file vrml1_node.cpp.

287 {
288  std::list< WRL1NODE* >::iterator np =
289  std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
290 
291  if( np != m_BackPointers.end() )
292  {
293  m_BackPointers.erase( np );
294  return;
295  }
296 
297  #ifdef DEBUG_VRML1
298  do {
299  std::ostringstream ostr;
300  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
301  ostr << " * [BUG] delNodeRef() did not find its target";
302  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
303  } while( 0 );
304  #endif
305 
306  return;
307 }
#define MASK_VRML
Definition: wrltypes.h:37
std::list< WRL1NODE * > m_BackPointers
Definition: vrml1_node.h:122

References m_BackPointers, and MASK_VRML.

◆ FindNode()

WRL1NODE * WRL1NODE::FindNode ( const std::string &  aNodeName)
virtual

Function FindNode searches the tree of linked nodes and returns a reference to the current node 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
Returns
is a valid node pointer on success, otherwise NULL

Definition at line 416 of file vrml1_node.cpp.

417 {
418  if( NULL == m_dictionary )
419  return NULL;
420 
421  return m_dictionary->FindName( aNodeName );
422 }
#define NULL
WRL1NODE * FindName(const std::string &aName)
Definition: vrml1_node.cpp:71
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:138

References NAMEREGISTER::FindName(), m_dictionary, and NULL.

Referenced by WRL1BASE::implementUse().

◆ GetError()

std::string WRL1NODE::GetError ( void  )

Definition at line 410 of file vrml1_node.cpp.

411 {
412  return m_error;
413 }
std::string m_error
Definition: vrml1_node.h:126

References m_error.

◆ GetName()

std::string WRL1NODE::GetName ( void  )
virtual

Reimplemented in WRL1BASE.

Definition at line 322 of file vrml1_node.cpp.

323 {
324  return m_Name;
325 }
std::string m_Name
Definition: vrml1_node.h:120

References m_Name.

◆ GetNItems()

size_t WRL1NODE::GetNItems ( void  ) const

Definition at line 404 of file vrml1_node.cpp.

405 {
406  return m_Items.size();
407 }
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:125

References m_Items.

◆ GetNodeType()

WRL1NODES WRL1NODE::GetNodeType ( void  ) const

Function GetNodeType returns the type of this node instance.

Definition at line 310 of file vrml1_node.cpp.

311 {
312  return m_Type;
313 }
WRL1NODES m_Type
Definition: vrml1_node.h:119

References m_Type.

Referenced by AddChildNode(), AddRefNode(), WRL1BASE::implementUse(), WRL1GROUP::TranslateToSG(), and WRL1TRANSFORM::TranslateToSG().

◆ getNodeTypeID()

WRL1NODES WRL1NODE::getNodeTypeID ( const std::string &  aNodeName)

Function getNodeTypeID returns the ID based on the given aNodeName or WRL1_INVALID (WRL1_END) if no such node name exists.

Definition at line 393 of file vrml1_node.cpp.

394 {
395  NODEMAP::iterator it = nodenames.find( aNodeName );
396 
397  if( nodenames.end() != it )
398  return it->second;
399 
400  return WRL1_INVALID;
401 }
static NODEMAP nodenames
Definition: vrml1_node.cpp:87

References nodenames, and WRL1_INVALID.

Referenced by WRL1BASE::ReadNode().

◆ GetNodeTypeName()

const char * WRL1NODE::GetNodeTypeName ( WRL1NODES  aNodeType) const

Definition at line 378 of file vrml1_node.cpp.

379 {
380  if( aNodeType < WRL1_BASE || aNodeType >= WRL1_END )
381  return "*INVALID_TYPE*";
382 
383  if( aNodeType == WRL1_BASE )
384  return "*VIRTUAL_BASE*";
385 
386  NODEMAP::iterator it = nodenames.begin();
387  advance( it, (aNodeType - WRL1_BEGIN) );
388 
389  return it->first.c_str();
390 }
static NODEMAP nodenames
Definition: vrml1_node.cpp:87

References nodenames, WRL1_BASE, WRL1_BEGIN, and WRL1_END.

Referenced by WRL1BASE::implementUse().

◆ GetParent()

WRL1NODE * WRL1NODE::GetParent ( 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)

Definition at line 316 of file vrml1_node.cpp.

317 {
318  return m_Parent;
319 }
WRL1NODE * m_Parent
Definition: vrml1_node.h:118

References m_Parent.

Referenced by AddChildNode().

◆ Read()

virtual bool WRL1NODE::Read ( WRLPROC proc,
WRL1BASE aTopNode 
)
pure virtual

◆ SetName()

bool WRL1NODE::SetName ( const std::string &  aName)
virtual

Reimplemented in WRL1BASE.

Definition at line 328 of file vrml1_node.cpp.

329 {
330  if( aName.empty() )
331  return false;
332 
333  if( isdigit( aName[0] ) )
334  {
335  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
336  do {
337  std::ostringstream ostr;
338  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
339  ostr << " * [INFO] invalid node name '" << aName << "' (begins with digit)";
340  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
341  } while( 0 );
342  #endif
343 
344  return false;
345  }
346 
347  // The character '+' is not allowed in names as per the VRML1 specification;
348  // however many parsers accept them and many bad generators use them so the rules
349  // have been relaxed here.
350  #define BAD_CHARS1 "\"\'#,.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
351  #define BAD_CHARS2 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
352 
353  if( std::string::npos != aName.find_first_of( BAD_CHARS1 )
354  || std::string::npos != aName.find_first_of( BAD_CHARS2 ) )
355  {
356  #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 )
357  do {
358  std::ostringstream ostr;
359  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
360  ostr << " * [INFO] invalid node name '" << aName;
361  ostr << "' (contains invalid character)";
362  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
363  } while( 0 );
364  #endif
365 
366  return false;
367  }
368 
369  m_Name = aName;
370 
371  if( m_dictionary )
372  m_dictionary->AddName( aName, this );
373 
374  return true;
375 }
#define MASK_VRML
Definition: wrltypes.h:37
std::string m_Name
Definition: vrml1_node.h:120
bool AddName(const std::string &aName, WRL1NODE *aNode)
Definition: vrml1_node.cpp:38
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:138
#define BAD_CHARS2
#define BAD_CHARS1

References NAMEREGISTER::AddName(), BAD_CHARS1, BAD_CHARS2, m_dictionary, m_Name, and MASK_VRML.

Referenced by WRL1BASE::implementDef().

◆ SetParent()

bool WRL1NODE::SetParent ( WRL1NODE aParent,
bool  doUnlink = true 
)
virtual

Function SetParent sets the parent WRL1NODE 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; false if the given node is not allowed to be a parent to the derived object.

Reimplemented in WRL1BASE.

Definition at line 425 of file vrml1_node.cpp.

426 {
427  if( aParent == m_Parent )
428  return true;
429 
430  if( NULL != m_Parent && doUnlink )
431  m_Parent->unlinkChildNode( this );
432 
433  m_Parent = aParent;
434 
435  if( NULL != m_Parent )
436  m_Parent->AddChildNode( this );
437 
438  return true;
439 }
#define NULL
virtual void unlinkChildNode(const WRL1NODE *aNode)
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: vrml1_node.cpp:520
virtual bool AddChildNode(WRL1NODE *aNode)
Definition: vrml1_node.cpp:442
WRL1NODE * m_Parent
Definition: vrml1_node.h:118

References AddChildNode(), m_Parent, NULL, and unlinkChildNode().

Referenced by AddChildNode().

◆ TranslateToSG()

virtual SGNODE* WRL1NODE::TranslateToSG ( SGNODE aParent,
WRL1STATUS sp 
)
pure virtual

Function TranslateToSG produces 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

Implemented in WRL1BASE, WRL1MATERIAL, WRL1FACESET, WRL1TRANSFORM, WRL1COORDS, WRL1SHAPEHINTS, WRL1MATBINDING, WRL1SWITCH, WRL1GROUP, and WRL1SEPARATOR.

◆ unlinkChildNode()

void WRL1NODE::unlinkChildNode ( const WRL1NODE aNode)
virtual

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.

Parameters
aNodeis the child which is being deleted

Definition at line 520 of file vrml1_node.cpp.

521 {
522  std::list< WRL1NODE* >::iterator sL = m_Children.begin();
523  std::list< WRL1NODE* >::iterator eL = m_Children.end();
524 
525  while( sL != eL )
526  {
527  if( *sL == aNode )
528  {
529  m_Children.erase( sL );
530  delItem( aNode );
531  return;
532  }
533 
534  ++sL;
535  }
536 
537  return;
538 }
void delItem(const WRL1NODE *aNode)
Definition: vrml1_node.cpp:569
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:123

References delItem(), and m_Children.

Referenced by SetParent(), and ~WRL1NODE().

◆ unlinkRefNode()

void WRL1NODE::unlinkRefNode ( const WRL1NODE aNode)
virtual

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.

Parameters
aNodeis the node which is being deleted

Definition at line 541 of file vrml1_node.cpp.

542 {
543  std::list< WRL1NODE* >::iterator sL = m_Refs.begin();
544  std::list< WRL1NODE* >::iterator eL = m_Refs.end();
545 
546  while( sL != eL )
547  {
548  if( *sL == aNode )
549  {
550  m_Refs.erase( sL );
551  delItem( aNode );
552  return;
553  }
554 
555  ++sL;
556  }
557 
558  return;
559 }
std::list< WRL1NODE * > m_Refs
Definition: vrml1_node.h:124
void delItem(const WRL1NODE *aNode)
Definition: vrml1_node.cpp:569

References delItem(), and m_Refs.

Member Data Documentation

◆ m_BackPointers

◆ m_Children

◆ m_current

◆ m_dictionary

◆ m_error

std::string WRL1NODE::m_error
protected

Definition at line 126 of file vrml1_node.h.

Referenced by GetError().

◆ m_Items

◆ m_Name

std::string WRL1NODE::m_Name
protected

Definition at line 120 of file vrml1_node.h.

Referenced by GetName(), SetName(), and ~WRL1NODE().

◆ m_Parent

◆ m_Refs

◆ m_sgNode

SGNODE* WRL1NODE::m_sgNode
protected

Definition at line 129 of file vrml1_node.h.

Referenced by WRL1NODE().

◆ m_Type


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