KiCad PCB EDA Suite
WRL1NODE Class Referenceabstract

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)
 Return 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)
 Remove 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)
 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. More...
 
void addNodeRef (WRL1NODE *aNode)
 Add a pointer to a node which references, but does not own, this node. More...
 
void delNodeRef (WRL1NODE *aNode)
 Remove 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
 Return the type of this node instance. More...
 
WRL1NODEGetParent (void) const
 Return 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)
 Set 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)
 Search 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
 Produce 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

The base class of all VRML1 nodes.

Definition at line 116 of file vrml1_node.h.

Constructor & Destructor Documentation

◆ WRL1NODE()

WRL1NODE::WRL1NODE ( NAMEREGISTER aDictionary)

Definition at line 91 of file vrml1_node.cpp.

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

References m_dictionary, m_Parent, m_sgNode, m_Type, nodenames, 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 139 of file vrml1_node.cpp.

140 {
141  wxLogTrace( traceVrmlPlugin,
142  wxT( " * [INFO] ^^ Destroying Type %d with %lu children, %lu references, and %lu "
143  "back pointers." ),
144  m_Type, m_Children.size(), m_Refs.size(), m_BackPointers.size() );
145 
146  m_Items.clear();
147 
148  if( m_dictionary && !m_Name.empty() )
149  m_dictionary->DelName( m_Name, this );
150 
151  if( m_Parent )
152  m_Parent->unlinkChildNode( this );
153 
154  std::list< WRL1NODE* >::iterator sBP = m_BackPointers.begin();
155  std::list< WRL1NODE* >::iterator eBP = m_BackPointers.end();
156 
157  while( sBP != eBP )
158  {
159  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d is unlinking ref #%d" ),
160  wxString( ' ', (size_t) std::distance( sBP, m_BackPointers.begin() ) * 2 ),
161  m_Type, std::distance( sBP, m_BackPointers.begin() ) );
162 
163  (*sBP)->unlinkRefNode( this );
164 
165  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d has unlinked ref #%d" ),
166  wxString( ' ', (size_t) std::distance( sBP, m_BackPointers.begin() ) * 2 ),
167  m_Type, std::distance( sBP, m_BackPointers.begin() ) );
168 
169  ++sBP;
170  }
171 
172  m_Refs.clear();
173 
174  std::list< WRL1NODE* >::iterator sC = m_Children.begin();
175  std::list< WRL1NODE* >::iterator eC = m_Children.end();
176 
177  while( sC != eC )
178  {
179  (*sC)->SetParent( nullptr, false );
180 
181  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d has unlinked child #%d" ),
182  wxString( ' ', (size_t) std::distance( sC, m_Children.begin() ) * 2 ),
183  m_Type, std::distance( sC, m_Children.begin() ) );
184 
185  delete *sC;
186 
187  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO]%sType %d has deleted child #%d" ),
188  wxString( ' ', (size_t) std::distance( sC, m_Children.begin() ) * 2 ),
189  m_Type, std::distance( sC, m_Children.begin() ) );
190 
191  ++sC;
192  }
193 
194  m_Children.clear();
195 }
std::string m_Name
Definition: vrml1_node.h:228
std::list< WRL1NODE * > m_BackPointers
Definition: vrml1_node.h:230
bool DelName(const std::string &aName, WRL1NODE *aNode)
Definition: vrml1_node.cpp:55
std::list< WRL1NODE * > m_Refs
Definition: vrml1_node.h:232
virtual void unlinkChildNode(const WRL1NODE *aNode)
Remove references to an owned child; it is invoked by the child upon destruction to ensure that the p...
Definition: vrml1_node.cpp:420
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:246
WRL1NODES m_Type
Definition: vrml1_node.h:227
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:233
WRL1NODE * m_Parent
Definition: vrml1_node.h:226
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:231

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

Member Function Documentation

◆ AddChildNode()

bool WRL1NODE::AddChildNode ( WRL1NODE aNode)
virtual

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

Definition at line 376 of file vrml1_node.cpp.

377 {
378  wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
379  wxCHECK_MSG( aNode->GetNodeType() != WRL1NODES::WRL1_BASE, false,
380  wxT( "Attempting to add a base node to another node." ) );
381 
382  std::list< WRL1NODE* >::iterator sC = m_Children.begin();
383  std::list< WRL1NODE* >::iterator eC = m_Children.end();
384 
385  while( sC != eC )
386  {
387  if( *sC == aNode )
388  return false;
389 
390  ++sC;
391  }
392 
393  m_Children.push_back( aNode );
394  addItem( aNode );
395 
396  if( aNode->GetParent() != this )
397  aNode->SetParent( this );
398 
399  return true;
400 }
WRL1NODE * GetParent(void) const
Return a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
Definition: vrml1_node.cpp:260
virtual bool SetParent(WRL1NODE *aParent, bool doUnlink=true)
Set the parent WRL1NODE of this object.
Definition: vrml1_node.cpp:359
WRL1NODES GetNodeType(void) const
Return the type of this node instance.
Definition: vrml1_node.cpp:254
void addItem(WRL1NODE *aNode)
Definition: vrml1_node.cpp:458
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:231

References addItem(), GetNodeType(), GetParent(), m_Children, 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 458 of file vrml1_node.cpp.

459 {
460  m_Items.push_back( aNode );
461 }
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:233

References m_Items.

Referenced by AddChildNode(), and AddRefNode().

◆ addNodeRef()

void WRL1NODE::addNodeRef ( WRL1NODE aNode)

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

Such back-pointers are required to ensure that invalidated references are removed when a node is deleted

Parameters
aNodeis the node holding a reference to this object.

Definition at line 216 of file vrml1_node.cpp.

217 {
218  // the parent node must never be added as a backpointer
219  if( aNode == m_Parent )
220  return;
221 
222  std::list< WRL1NODE* >::iterator sR = m_BackPointers.begin();
223  std::list< WRL1NODE* >::iterator eR = m_BackPointers.end();
224 
225  while( sR != eR )
226  {
227  if( *sR == aNode )
228  return;
229 
230  ++sR;
231  }
232 
233  m_BackPointers.push_back( aNode );
234 }
std::list< WRL1NODE * > m_BackPointers
Definition: vrml1_node.h:230
WRL1NODE * m_Parent
Definition: vrml1_node.h:226

References m_BackPointers, and m_Parent.

Referenced by AddRefNode().

◆ AddRefNode()

bool WRL1NODE::AddRefNode ( WRL1NODE aNode)
virtual

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

Definition at line 403 of file vrml1_node.cpp.

404 {
405  wxCHECK_MSG( aNode, false, wxT( "Invalid node pointer." ) );
406  wxCHECK_MSG( aNode->GetNodeType() != WRL1NODES::WRL1_BASE, false,
407  wxT( "Attempt to add a base node reference to another base node" ) );
408 
409  // note: the VRML1 spec does not prevent the reuse of a node at
410  // the same level; for example a Coordinate3 node can be recalled
411  // at any time to set the current coordinate set.
412  m_Refs.push_back( aNode );
413  aNode->addNodeRef( this );
414  addItem( aNode );
415 
416  return true;
417 }
void addNodeRef(WRL1NODE *aNode)
Add a pointer to a node which references, but does not own, this node.
Definition: vrml1_node.cpp:216
std::list< WRL1NODE * > m_Refs
Definition: vrml1_node.h:232
WRL1NODES GetNodeType(void) const
Return the type of this node instance.
Definition: vrml1_node.cpp:254
void addItem(WRL1NODE *aNode)
Definition: vrml1_node.cpp:458

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

Referenced by WRL1BASE::implementUse().

◆ cancelDict()

void WRL1NODE::cancelDict ( void  )

Definition at line 198 of file vrml1_node.cpp.

199 {
200  std::list< WRL1NODE* >::iterator sC = m_Children.begin();
201  std::list< WRL1NODE* >::iterator eC = m_Children.end();
202 
203  while( sC != eC )
204  {
205  (*sC)->cancelDict();
206  ++sC;
207  }
208 
209  if( m_Type == WRL1NODES::WRL1_BASE && nullptr != m_dictionary )
210  delete m_dictionary;
211 
212  m_dictionary = nullptr;
213 }
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:246
WRL1NODES m_Type
Definition: vrml1_node.h:227
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:231

References m_Children, m_dictionary, m_Type, and WRL1_BASE.

Referenced by WRL1BASE::~WRL1BASE().

◆ delItem()

void WRL1NODE::delItem ( const WRL1NODE aNode)
private

Definition at line 464 of file vrml1_node.cpp.

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

References m_Items.

Referenced by unlinkChildNode(), and unlinkRefNode().

◆ delNodeRef()

void WRL1NODE::delNodeRef ( WRL1NODE aNode)

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 237 of file vrml1_node.cpp.

238 {
239  std::list< WRL1NODE* >::iterator np = std::find( m_BackPointers.begin(),
240  m_BackPointers.end(), aNode );
241 
242  if( np != m_BackPointers.end() )
243  {
244  m_BackPointers.erase( np );
245  return;
246  }
247 
248  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
249  " * [BUG] delNodeRef() did not find its target." ),
250  __FILE__, __FUNCTION__, __LINE__ );
251 }
std::list< WRL1NODE * > m_BackPointers
Definition: vrml1_node.h:230
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63

References m_BackPointers, and traceVrmlPlugin.

◆ FindNode()

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

Search 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 350 of file vrml1_node.cpp.

351 {
352  if( nullptr == m_dictionary )
353  return nullptr;
354 
355  return m_dictionary->FindName( aNodeName );
356 }
WRL1NODE * FindName(const std::string &aName)
Definition: vrml1_node.cpp:72
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:246

References NAMEREGISTER::FindName(), and m_dictionary.

Referenced by WRL1BASE::implementUse().

◆ GetError()

std::string WRL1NODE::GetError ( void  )

Definition at line 344 of file vrml1_node.cpp.

345 {
346  return m_error;
347 }
std::string m_error
Definition: vrml1_node.h:234

References m_error.

◆ GetName()

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

Reimplemented in WRL1BASE.

Definition at line 266 of file vrml1_node.cpp.

267 {
268  return m_Name;
269 }
std::string m_Name
Definition: vrml1_node.h:228

References m_Name.

◆ GetNItems()

size_t WRL1NODE::GetNItems ( void  ) const

Definition at line 338 of file vrml1_node.cpp.

339 {
340  return m_Items.size();
341 }
std::list< WRL1NODE * > m_Items
Definition: vrml1_node.h:233

References m_Items.

◆ GetNodeType()

WRL1NODES WRL1NODE::GetNodeType ( void  ) const

Return the type of this node instance.

Definition at line 254 of file vrml1_node.cpp.

255 {
256  return m_Type;
257 }
WRL1NODES m_Type
Definition: vrml1_node.h:227

References m_Type.

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

◆ getNodeTypeID()

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

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

Definition at line 327 of file vrml1_node.cpp.

328 {
329  NODEMAP::iterator it = nodenames.find( aNodeName );
330 
331  if( nodenames.end() != it )
332  return it->second;
333 
335 }
static NODEMAP nodenames
Definition: vrml1_node.cpp:88

References nodenames, and WRL1_INVALID.

Referenced by WRL1BASE::ReadNode().

◆ GetNodeTypeName()

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

Definition at line 312 of file vrml1_node.cpp.

313 {
314  if( aNodeType < WRL1NODES::WRL1_BASE || aNodeType >= WRL1NODES::WRL1_END )
315  return "*INVALID_TYPE*";
316 
317  if( aNodeType == WRL1NODES::WRL1_BASE )
318  return "*VIRTUAL_BASE*";
319 
320  NODEMAP::iterator it = nodenames.begin();
321  advance( it, ( static_cast<int>( aNodeType ) - static_cast<int>( WRL1NODES::WRL1_BEGIN ) ) );
322 
323  return it->first.c_str();
324 }
static NODEMAP nodenames
Definition: vrml1_node.cpp:88

References nodenames, WRL1_BASE, WRL1_BEGIN, and WRL1_END.

Referenced by WRL1BASE::implementUse().

◆ GetParent()

WRL1NODE * WRL1NODE::GetParent ( void  ) const

Return a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.

top level transform).

Definition at line 260 of file vrml1_node.cpp.

261 {
262  return m_Parent;
263 }
WRL1NODE * m_Parent
Definition: vrml1_node.h:226

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 272 of file vrml1_node.cpp.

273 {
274  if( aName.empty() )
275  return false;
276 
277  if( isdigit( aName[0] ) )
278  {
279  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
280  " * [INFO] invalid node name '%s' (begins with digit)" ),
281  __FILE__, __FUNCTION__, __LINE__, aName );
282 
283  return false;
284  }
285 
286  // The character '+' is not allowed in names as per the VRML1 specification;
287  // however many parsers accept them and many bad generators use them so the rules
288  // have been relaxed here.
289  #define BAD_CHARS1 "\"\'#,.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
290  #define BAD_CHARS2 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
291 
292  if( std::string::npos != aName.find_first_of( BAD_CHARS1 )
293  || std::string::npos != aName.find_first_of( BAD_CHARS2 ) )
294  {
295  wxLogTrace( traceVrmlPlugin,
296  wxT( "%s:%s:%d\n"
297  " * [INFO] invalid node name '%s' (contains invalid character)" ),
298  __FILE__, __FUNCTION__, __LINE__, aName );
299 
300  return false;
301  }
302 
303  m_Name = aName;
304 
305  if( m_dictionary )
306  m_dictionary->AddName( aName, this );
307 
308  return true;
309 }
std::string m_Name
Definition: vrml1_node.h:228
bool AddName(const std::string &aName, WRL1NODE *aNode)
Definition: vrml1_node.cpp:39
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
NAMEREGISTER * m_dictionary
Definition: vrml1_node.h:246
#define BAD_CHARS2
#define BAD_CHARS1

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

Referenced by WRL1BASE::implementDef().

◆ SetParent()

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

Set 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 359 of file vrml1_node.cpp.

360 {
361  if( aParent == m_Parent )
362  return true;
363 
364  if( nullptr != m_Parent && doUnlink )
365  m_Parent->unlinkChildNode( this );
366 
367  m_Parent = aParent;
368 
369  if( nullptr != m_Parent )
370  m_Parent->AddChildNode( this );
371 
372  return true;
373 }
virtual void unlinkChildNode(const WRL1NODE *aNode)
Remove references to an owned child; it is invoked by the child upon destruction to ensure that the p...
Definition: vrml1_node.cpp:420
virtual bool AddChildNode(WRL1NODE *aNode)
Definition: vrml1_node.cpp:376
WRL1NODE * m_Parent
Definition: vrml1_node.h:226

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

Referenced by AddChildNode().

◆ TranslateToSG()

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

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.

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

◆ unlinkChildNode()

void WRL1NODE::unlinkChildNode ( const WRL1NODE aNode)
virtual

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.

Definition at line 420 of file vrml1_node.cpp.

421 {
422  std::list< WRL1NODE* >::iterator sL = m_Children.begin();
423  std::list< WRL1NODE* >::iterator eL = m_Children.end();
424 
425  while( sL != eL )
426  {
427  if( *sL == aNode )
428  {
429  m_Children.erase( sL );
430  delItem( aNode );
431  return;
432  }
433 
434  ++sL;
435  }
436 }
void delItem(const WRL1NODE *aNode)
Definition: vrml1_node.cpp:464
std::list< WRL1NODE * > m_Children
Definition: vrml1_node.h:231

References delItem(), and m_Children.

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

◆ unlinkRefNode()

void WRL1NODE::unlinkRefNode ( const WRL1NODE aNode)
virtual

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.

Definition at line 439 of file vrml1_node.cpp.

440 {
441  std::list< WRL1NODE* >::iterator sL = m_Refs.begin();
442  std::list< WRL1NODE* >::iterator eL = m_Refs.end();
443 
444  while( sL != eL )
445  {
446  if( *sL == aNode )
447  {
448  m_Refs.erase( sL );
449  delItem( aNode );
450  return;
451  }
452 
453  ++sL;
454  }
455 }
std::list< WRL1NODE * > m_Refs
Definition: vrml1_node.h:232
void delItem(const WRL1NODE *aNode)
Definition: vrml1_node.cpp:464

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 234 of file vrml1_node.h.

Referenced by GetError().

◆ m_Items

◆ m_Name

std::string WRL1NODE::m_Name
protected

Definition at line 228 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 237 of file vrml1_node.h.

Referenced by WRL1NODE().

◆ m_Type


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