KiCad PCB EDA Suite
WRL2NODE Class Referenceabstract

WRL2NODE represents the base class of all VRML2 nodes. More...

#include <vrml2_node.h>

Inheritance diagram for WRL2NODE:
WRL2APPEARANCE WRL2BASE WRL2BOX WRL2COLOR WRL2COORDS WRL2FACESET WRL2INLINE WRL2LINESET WRL2MATERIAL WRL2NORMS WRL2POINTSET WRL2SHAPE WRL2SWITCH WRL2TRANSFORM

Public Member Functions

WRL2NODES getNodeTypeID (const std::string &aNodeName)
 Function getNodeTypeID returns the ID based on the given aNodeName or WRL2_INVALID (WRL2_END) if no such node name exists. More...
 
virtual void unlinkChildNode (const WRL2NODE *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 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. More...
 
void addNodeRef (WRL2NODE *aNode)
 Function addNodeRef adds a pointer to a node which references, but does not own, this node. More...
 
void delNodeRef (WRL2NODE *aNode)
 Function delNodeRef removes a pointer to a node which references, but does not own, this node. More...
 
virtual bool isDangling (void)=0
 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. More...
 
 WRL2NODE ()
 
virtual ~WRL2NODE ()
 
virtual bool Read (WRLPROC &proc, WRL2BASE *aTopNode)=0
 
WRL2NODES GetNodeType (void) const
 Function GetNodeType returns the type of this node instance. More...
 
WRL2NODEGetParent (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 (WRL2NODE *aParent, bool doUnlink=true)
 Function SetParent sets the parent WRL2NODE of this object. More...
 
virtual std::string GetName (void)
 
virtual bool SetName (const std::string &aName)
 
const char * GetNodeTypeName (WRL2NODES aNodeType) const
 
virtual WRL2NODEFindNode (const std::string &aNodeName, const WRL2NODE *aCaller)
 Function FindNode searches 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)
 
virtual SGNODETranslateToSG (SGNODE *aParent)=0
 Function TranslateToSG produces a representation of the data using the intermediate scenegraph structures of the kicad_3dsg library. 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
 

Detailed Description

WRL2NODE represents the base class of all VRML2 nodes.

Definition at line 58 of file vrml2_node.h.

Constructor & Destructor Documentation

◆ WRL2NODE()

WRL2NODE::WRL2NODE ( )

Definition at line 45 of file vrml2_node.cpp.

46 {
47  m_sgNode = NULL;
48  m_Parent = NULL;
49  m_Type = WRL2_END;
50 
51  if( badNames.empty() )
52  {
53  badNames.insert( "DEF" );
54  badNames.insert( "EXTERNPROTO" );
55  badNames.insert( "FALSE" );
56  badNames.insert( "IS" );
57  badNames.insert( "NULL" );
58  badNames.insert( "PROTO" );
59  badNames.insert( "ROUTE" );
60  badNames.insert( "TO" );
61  badNames.insert( "TRUE" );
62  badNames.insert( "USE" );
63  badNames.insert( "eventIn" );
64  badNames.insert( "eventOut" );
65  badNames.insert( "exposedField" );
66  badNames.insert( "field" );
67  }
68 
69  if( nodenames.empty() )
70  {
71  nodenames.insert( NODEITEM( "Anchor", WRL2_ANCHOR ) );
72  nodenames.insert( NODEITEM( "Appearance", WRL2_APPEARANCE ) );
73  nodenames.insert( NODEITEM( "Audioclip", WRL2_AUDIOCLIP ) );
74  nodenames.insert( NODEITEM( "Background", WRL2_BACKGROUND ) );
75  nodenames.insert( NODEITEM( "Billboard", WRL2_BILLBOARD ) );
76  nodenames.insert( NODEITEM( "Box", WRL2_BOX ) );
77  nodenames.insert( NODEITEM( "Collision", WRL2_COLLISION ) );
78  nodenames.insert( NODEITEM( "Color", WRL2_COLOR ) );
79  nodenames.insert( NODEITEM( "ColorInterpolator", WRL2_COLORINTERPOLATOR ) );
80  nodenames.insert( NODEITEM( "Cone", WRL2_CONE ) );
81  nodenames.insert( NODEITEM( "Coordinate", WRL2_COORDINATE ) );
82  nodenames.insert( NODEITEM( "CoordinateInterpolator", WRL2_COORDINATEINTERPOLATOR ) );
83  nodenames.insert( NODEITEM( "Cylinder", WRL2_CYLINDER ) );
84  nodenames.insert( NODEITEM( "CylinderSensor", WRL2_CYLINDERSENSOR ) );
85  nodenames.insert( NODEITEM( "DirectionalLight", WRL2_DIRECTIONALLIGHT ) );
86  nodenames.insert( NODEITEM( "ElevationGrid", WRL2_ELEVATIONGRID ) );
87  nodenames.insert( NODEITEM( "Extrusion", WRL2_EXTRUSION ) );
88  nodenames.insert( NODEITEM( "Fog", WRL2_FOG ) );
89  nodenames.insert( NODEITEM( "FontStyle", WRL2_FONTSTYLE ) );
90  nodenames.insert( NODEITEM( "Group", WRL2_GROUP ) );
91  nodenames.insert( NODEITEM( "ImageTexture", WRL2_IMAGETEXTURE ) );
92  nodenames.insert( NODEITEM( "IndexedFaceSet", WRL2_INDEXEDFACESET ) );
93  nodenames.insert( NODEITEM( "IndexedLineSet", WRL2_INDEXEDLINESET ) );
94  nodenames.insert( NODEITEM( "Inline", WRL2_INLINE ) );
95  nodenames.insert( NODEITEM( "LOD", WRL2_LOD ) );
96  nodenames.insert( NODEITEM( "Material", WRL2_MATERIAL ) );
97  nodenames.insert( NODEITEM( "MovieTexture", WRL2_MOVIETEXTURE ) );
98  nodenames.insert( NODEITEM( "NavigationInfo", WRL2_NAVIGATIONINFO ) );
99  nodenames.insert( NODEITEM( "Normal", WRL2_NORMAL ) );
100  nodenames.insert( NODEITEM( "NormalInterpolator", WRL2_NORMALINTERPOLATOR ) );
101  nodenames.insert( NODEITEM( "OrientationInterpolator", WRL2_ORIENTATIONINTERPOLATOR ) );
102  nodenames.insert( NODEITEM( "PixelTexture", WRL2_PIXELTEXTURE ) );
103  nodenames.insert( NODEITEM( "PlaneSensor", WRL2_PLANESENSOR ) );
104  nodenames.insert( NODEITEM( "PointLight", WRL2_POINTLIGHT ) );
105  nodenames.insert( NODEITEM( "PointSet", WRL2_POINTSET ) );
106  nodenames.insert( NODEITEM( "PositionInterpolator", WRL2_POSITIONINTERPOLATOR ) );
107  nodenames.insert( NODEITEM( "ProximitySensor", WRL2_PROXIMITYSENSOR ) );
108  nodenames.insert( NODEITEM( "ScalarInterpolator", WRL2_SCALARINTERPOLATOR ) );
109  nodenames.insert( NODEITEM( "Script", WRL2_SCRIPT ) );
110  nodenames.insert( NODEITEM( "Shape", WRL2_SHAPE ) );
111  nodenames.insert( NODEITEM( "Sound", WRL2_SOUND ) );
112  nodenames.insert( NODEITEM( "Sphere", WRL2_SPHERE ) );
113  nodenames.insert( NODEITEM( "SphereSensor", WRL2_SPHERESENSOR ) );
114  nodenames.insert( NODEITEM( "SpotLight", WRL2_SPOTLIGHT ) );
115  nodenames.insert( NODEITEM( "Switch", WRL2_SWITCH ) );
116  nodenames.insert( NODEITEM( "Text", WRL2_TEXT ) );
117  nodenames.insert( NODEITEM( "TextureCoordinate", WRL2_TEXTURECOORDINATE ) );
118  nodenames.insert( NODEITEM( "TextureTransform", WRL2_TEXTURETRANSFORM ) );
119  nodenames.insert( NODEITEM( "TimeSensor", WRL2_TIMESENSOR ) );
120  nodenames.insert( NODEITEM( "TouchSensor", WRL2_TOUCHSENSOR ) );
121  nodenames.insert( NODEITEM( "Transform", WRL2_TRANSFORM ) );
122  nodenames.insert( NODEITEM( "ViewPoint", WRL2_VIEWPOINT ) );
123  nodenames.insert( NODEITEM( "VisibilitySensor", WRL2_VISIBILITYSENSOR ) );
124  nodenames.insert( NODEITEM( "WorldInfo", WRL2_WORLDINFO ) );
125  }
126 
127  return;
128 }
std::pair< std::string, WRL2NODES > NODEITEM
Definition: vrml2_node.cpp:40
WRL2NODES m_Type
Definition: vrml2_node.h:62
#define NULL
WRL2NODE * m_Parent
Definition: vrml2_node.h:61
static NODEMAP nodenames
Definition: vrml2_node.cpp:42
SGNODE * m_sgNode
Definition: vrml2_node.h:70
static std::set< std::string > badNames
Definition: vrml2_node.cpp:38

References badNames, m_Parent, m_sgNode, m_Type, nodenames, NULL, 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_END, WRL2_EXTRUSION, WRL2_FOG, WRL2_FONTSTYLE, WRL2_GROUP, WRL2_IMAGETEXTURE, WRL2_INDEXEDFACESET, WRL2_INDEXEDLINESET, WRL2_INLINE, 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.

◆ ~WRL2NODE()

WRL2NODE::~WRL2NODE ( )
virtual

Definition at line 131 of file vrml2_node.cpp.

132 {
133  if( m_Parent )
134  m_Parent->unlinkChildNode( this );
135 
136  std::list< WRL2NODE* >::iterator sBP = m_BackPointers.begin();
137  std::list< WRL2NODE* >::iterator eBP = m_BackPointers.end();
138 
139  while( sBP != eBP )
140  {
141  (*sBP)->unlinkRefNode( this );
142  ++sBP;
143  }
144 
145  std::list< WRL2NODE* >::iterator sC = m_Refs.begin();
146  std::list< WRL2NODE* >::iterator eC = m_Refs.end();
147 
148  while( sC != eC )
149  {
150  (*sC)->delNodeRef( this );
151  ++sC;
152  }
153 
154  m_Refs.clear();
155  sC = m_Children.begin();
156  eC = m_Children.end();
157 
158  while( sC != eC )
159  {
160  (*sC)->SetParent( NULL, false );
161  delete *sC;
162  ++sC;
163  }
164 
165  m_Children.clear();
166  return;
167 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:66
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:67
#define NULL
WRL2NODE * m_Parent
Definition: vrml2_node.h:61
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:65
virtual void unlinkChildNode(const WRL2NODE *aNode)
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: vrml2_node.cpp:464

References m_BackPointers, m_Children, m_Parent, m_Refs, NULL, and unlinkChildNode().

Member Function Documentation

◆ AddChildNode()

bool WRL2NODE::AddChildNode ( WRL2NODE aNode)
virtual

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

Definition at line 377 of file vrml2_node.cpp.

378 {
379  if( aNode == NULL )
380  return false;
381 
382  if( aNode->GetNodeType() == WRL2_BASE )
383  {
384  #ifdef DEBUG_VRML2
385  do {
386  std::ostringstream ostr;
387  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
388  ostr << " * [BUG] attempting to add a base node to another node";
389  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
390  } while( 0 );
391  #endif
392 
393  return false;
394  }
395 
396  std::list< WRL2NODE* >::iterator sC = m_Children.begin();
397  std::list< WRL2NODE* >::iterator eC = m_Children.end();
398 
399  while( sC != eC )
400  {
401  if( *sC == aNode )
402  return false;
403 
404  ++sC;
405  }
406 
407  m_Children.push_back( aNode );
408 
409  if( aNode->GetParent() != this )
410  aNode->SetParent( this );
411 
412  return true;
413 }
virtual bool SetParent(WRL2NODE *aParent, bool doUnlink=true)
Function SetParent sets the parent WRL2NODE of this object.
Definition: vrml2_node.cpp:360
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:66
#define MASK_VRML
Definition: wrltypes.h:37
#define NULL
WRL2NODES GetNodeType(void) const
Function GetNodeType returns the type of this node instance.
Definition: vrml2_node.cpp:212
WRL2NODE * GetParent(void) const
Function GetParent returns a pointer to the parent SGNODE of this object or NULL if the object has no...
Definition: vrml2_node.cpp:218

References GetNodeType(), GetParent(), m_Children, MASK_VRML, NULL, SetParent(), and WRL2_BASE.

Referenced by WRL2SHAPE::AddChildNode(), WRL2APPEARANCE::AddChildNode(), WRL2POINTSET::AddChildNode(), WRL2LINESET::AddChildNode(), WRL2FACESET::AddChildNode(), WRL2SWITCH::AddRefNode(), WRL2TRANSFORM::AddRefNode(), 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)

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 170 of file vrml2_node.cpp.

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

References m_BackPointers, and m_Parent.

Referenced by AddRefNode().

◆ AddRefNode()

bool WRL2NODE::AddRefNode ( WRL2NODE aNode)
virtual

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

Definition at line 416 of file vrml2_node.cpp.

417 {
418  if( NULL == aNode )
419  {
420  #ifdef DEBUG_VRML2
421  do {
422  std::ostringstream ostr;
423  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
424  ostr << " * [BUG] NULL passed as node pointer";
425  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
426  } while( 0 );
427  #endif
428 
429  return false;
430  }
431 
432  if( aNode->GetNodeType() == WRL2_BASE )
433  {
434  #ifdef DEBUG_VRML2
435  do {
436  std::ostringstream ostr;
437  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
438  ostr << " * [BUG] attempting to add a base node ref to another base node";
439  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
440  } while( 0 );
441  #endif
442 
443  return false;
444  }
445 
446  std::list< WRL2NODE* >::iterator sR = m_Refs.begin();
447  std::list< WRL2NODE* >::iterator eR = m_Refs.end();
448 
449  while( sR != eR )
450  {
451  if( *sR == aNode )
452  return true;
453 
454  ++sR;
455  }
456 
457  m_Refs.push_back( aNode );
458  aNode->addNodeRef( this );
459 
460  return true;
461 }
void addNodeRef(WRL2NODE *aNode)
Function addNodeRef adds a pointer to a node which references, but does not own, this node.
Definition: vrml2_node.cpp:170
#define MASK_VRML
Definition: wrltypes.h:37
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:67
#define NULL
WRL2NODES GetNodeType(void) const
Function GetNodeType returns the type of this node instance.
Definition: vrml2_node.cpp:212

References addNodeRef(), GetNodeType(), m_Refs, MASK_VRML, NULL, and WRL2_BASE.

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

◆ delNodeRef()

void WRL2NODE::delNodeRef ( WRL2NODE 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 188 of file vrml2_node.cpp.

189 {
190  std::list< WRL2NODE* >::iterator np =
191  std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
192 
193  if( np != m_BackPointers.end() )
194  {
195  m_BackPointers.erase( np );
196  return;
197  }
198 
199  #ifdef DEBUG_VRML2
200  do {
201  std::ostringstream ostr;
202  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
203  ostr << " * [BUG] delNodeRef() did not find its target";
204  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
205  } while( 0 );
206  #endif
207 
208  return;
209 }
#define MASK_VRML
Definition: wrltypes.h:37
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:65

References m_BackPointers, and MASK_VRML.

◆ FindNode()

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

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

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, otherwise NULL

Definition at line 327 of file vrml2_node.cpp.

328 {
329  if( aNodeName.empty() )
330  return NULL;
331 
332  if( !m_Name.compare( aNodeName ) )
333  return this;
334 
335  std::list< WRL2NODE* >::iterator sLA = m_Children.begin();
336  std::list< WRL2NODE* >::iterator eLA = m_Children.end();
337 
338  WRL2NODE* psg = NULL;
339 
340  while( sLA != eLA )
341  {
342  if( *sLA != aCaller )
343  {
344  psg = (*sLA)->FindNode( aNodeName, this );
345 
346  if( NULL != psg)
347  return psg;
348 
349  }
350  ++sLA;
351  }
352 
353  if( NULL != m_Parent && aCaller != m_Parent )
354  return m_Parent->FindNode( aNodeName, this );
355 
356  return NULL;
357 }
WRL2NODE represents the base class of all VRML2 nodes.
Definition: vrml2_node.h:58
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:66
std::string m_Name
Definition: vrml2_node.h:63
#define NULL
WRL2NODE * m_Parent
Definition: vrml2_node.h:61
virtual WRL2NODE * FindNode(const std::string &aNodeName, const WRL2NODE *aCaller)
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
Definition: vrml2_node.cpp:327

References FindNode(), m_Children, m_Name, m_Parent, and NULL.

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

◆ GetError()

std::string WRL2NODE::GetError ( void  )

Definition at line 321 of file vrml2_node.cpp.

322 {
323  return m_error;
324 }
std::string m_error
Definition: vrml2_node.h:68

References m_error.

◆ GetName()

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

Reimplemented in WRL2BASE.

Definition at line 224 of file vrml2_node.cpp.

225 {
226  return m_Name;
227 }
std::string m_Name
Definition: vrml2_node.h:63

References m_Name.

◆ GetNodeType()

◆ getNodeTypeID()

WRL2NODES WRL2NODE::getNodeTypeID ( const std::string &  aNodeName)

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

Definition at line 310 of file vrml2_node.cpp.

311 {
312  NODEMAP::iterator it = nodenames.find( aNodeName );
313 
314  if( nodenames.end() != it )
315  return it->second;
316 
317  return WRL2_INVALID;
318 }
static NODEMAP nodenames
Definition: vrml2_node.cpp:42

References nodenames, and WRL2_INVALID.

Referenced by WRL2BASE::ReadNode().

◆ GetNodeTypeName()

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

Definition at line 295 of file vrml2_node.cpp.

296 {
297  if( aNodeType < WRL2_BASE || aNodeType >= WRL2_END )
298  return "*INVALID_TYPE*";
299 
300  if( aNodeType == WRL2_BASE )
301  return "*VIRTUAL_BASE*";
302 
303  NODEMAP::iterator it = nodenames.begin();
304  advance( it, (aNodeType - WRL2_BEGIN) );
305 
306  return it->first.c_str();
307 }
static NODEMAP nodenames
Definition: vrml2_node.cpp:42

References nodenames, WRL2_BASE, WRL2_BEGIN, and WRL2_END.

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

◆ GetParent()

WRL2NODE * WRL2NODE::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 218 of file vrml2_node.cpp.

219 {
220  return m_Parent;
221 }
WRL2NODE * m_Parent
Definition: vrml2_node.h:61

References m_Parent.

Referenced by AddChildNode(), WRL2SWITCH::AddRefNode(), WRL2TRANSFORM::AddRefNode(), WRL2APPEARANCE::unlinkChildNode(), WRL2POINTSET::unlinkChildNode(), WRL2LINESET::unlinkChildNode(), WRL2FACESET::unlinkChildNode(), WRL2APPEARANCE::unlinkRefNode(), WRL2POINTSET::unlinkRefNode(), WRL2LINESET::unlinkRefNode(), and WRL2FACESET::unlinkRefNode().

◆ isDangling()

virtual bool WRL2NODE::isDangling ( void  )
pure virtual

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.

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

Referenced by WRL2SWITCH::AddRefNode(), and WRL2TRANSFORM::AddRefNode().

◆ Read()

virtual bool WRL2NODE::Read ( WRLPROC proc,
WRL2BASE aTopNode 
)
pure virtual

◆ SetName()

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

Reimplemented in WRL2BASE.

Definition at line 230 of file vrml2_node.cpp.

231 {
232  if( aName.empty() )
233  return false;
234 
235  std::set< std::string >::iterator item = badNames.find( aName );
236 
237  if( item != badNames.end() )
238  {
239  #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
240  do {
241  std::ostringstream ostr;
242  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
243  ostr << " * [INFO] invalid node name '" << *item << "' (matches restricted word)";
244  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
245  } while( 0 );
246  #endif
247 
248  return false;
249  }
250 
251 
252  if( isdigit( aName[0] ) )
253  {
254  #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
255  do {
256  std::ostringstream ostr;
257  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
258  ostr << " * [INFO] invalid node name '" << *item << "' (begins with digit)";
259  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
260  } while( 0 );
261  #endif
262 
263  return false;
264  }
265 
266  // The characters '+' and '-' are not allowed in names as per the VRML2 specification;
267  // however many parsers accept them and many bad generators use them so the rules
268  // have been relaxed here.
269  // #define BAD_CHARS1 "\"\'#+,-.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
270  #define BAD_CHARS1 "\"\'#,.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
271  #define BAD_CHARS2 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
272 
273  if( std::string::npos != aName.find_first_of( BAD_CHARS1 )
274  || std::string::npos != aName.find_first_of( BAD_CHARS2 ) )
275  {
276  #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
277  do {
278  std::ostringstream ostr;
279  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
280  ostr << " * [INFO] invalid node name '" << aName;
281  ostr << "' (contains invalid character)";
282  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
283  } while( 0 );
284  #endif
285 
286  return false;
287  }
288 
289  m_Name = aName;
290 
291  return true;
292 }
#define BAD_CHARS1
#define BAD_CHARS2
std::string m_Name
Definition: vrml2_node.h:63
#define MASK_VRML
Definition: wrltypes.h:37
static std::set< std::string > badNames
Definition: vrml2_node.cpp:38

References BAD_CHARS1, BAD_CHARS2, badNames, m_Name, and MASK_VRML.

Referenced by WRL2BASE::implementDef().

◆ SetParent()

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

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

Reimplemented in WRL2BASE.

Definition at line 360 of file vrml2_node.cpp.

361 {
362  if( aParent == m_Parent )
363  return true;
364 
365  if( NULL != m_Parent && doUnlink )
366  m_Parent->unlinkChildNode( this );
367 
368  m_Parent = aParent;
369 
370  if( NULL != m_Parent )
371  m_Parent->AddChildNode( this );
372 
373  return true;
374 }
#define NULL
WRL2NODE * m_Parent
Definition: vrml2_node.h:61
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:377
virtual void unlinkChildNode(const WRL2NODE *aNode)
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: vrml2_node.cpp:464

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

Referenced by AddChildNode(), WRL2SWITCH::AddRefNode(), and WRL2TRANSFORM::AddRefNode().

◆ TranslateToSG()

virtual SGNODE* WRL2NODE::TranslateToSG ( SGNODE aParent)
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 WRL2BASE, WRL2FACESET, WRL2LINESET, WRL2POINTSET, WRL2APPEARANCE, WRL2SHAPE, WRL2MATERIAL, WRL2TRANSFORM, WRL2INLINE, WRL2COLOR, WRL2COORDS, WRL2NORMS, WRL2SWITCH, and WRL2BOX.

Referenced by WRL2SHAPE::TranslateToSG(), and WRL2APPEARANCE::TranslateToSG().

◆ unlinkChildNode()

void WRL2NODE::unlinkChildNode ( const WRL2NODE 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

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

Definition at line 464 of file vrml2_node.cpp.

465 {
466  std::list< WRL2NODE* >::iterator sL = m_Children.begin();
467  std::list< WRL2NODE* >::iterator eL = m_Children.end();
468 
469  while( sL != eL )
470  {
471  if( *sL == aNode )
472  {
473  m_Children.erase( sL );
474  return;
475  }
476 
477  ++sL;
478  }
479 
480  return;
481 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:66

References m_Children.

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

◆ unlinkRefNode()

void WRL2NODE::unlinkRefNode ( const WRL2NODE 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

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

Definition at line 484 of file vrml2_node.cpp.

485 {
486  std::list< WRL2NODE* >::iterator sL = m_Refs.begin();
487  std::list< WRL2NODE* >::iterator eL = m_Refs.end();
488 
489  while( sL != eL )
490  {
491  if( *sL == aNode )
492  {
493  m_Refs.erase( sL );
494  return;
495  }
496 
497  ++sL;
498  }
499 
500  return;
501 }
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:67

References m_Refs.

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

Member Data Documentation

◆ m_BackPointers

◆ m_Children

◆ m_error

std::string WRL2NODE::m_error
protected

Definition at line 68 of file vrml2_node.h.

Referenced by GetError().

◆ m_Name

std::string WRL2NODE::m_Name
protected

Definition at line 63 of file vrml2_node.h.

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

◆ m_Parent

◆ m_Refs

◆ m_sgNode

◆ m_Type


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