KiCad PCB EDA Suite
X3DNODE Class Referenceabstract

X3DNODE represents the base class of all X3D nodes. More...

#include <x3d_base.h>

Inheritance diagram for X3DNODE:
X3DAPP X3DCOORDS X3DIFACESET X3DSHAPE X3DTRANSFORM

Public Member Functions

virtual void unlinkChildNode (const X3DNODE *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 X3DNODE *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 (X3DNODE *aNode)
 Function addNodeRef adds a pointer to a node which references, but does not own, this node. More...
 
void delNodeRef (X3DNODE *aNode)
 Function delNodeRef removes a pointer to a node which references, but does not own, this node. More...
 
 X3DNODE ()
 
virtual ~X3DNODE ()
 
virtual bool Read (wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
 
X3DNODES GetNodeType (void) const
 Function GetNodeType returns the type of this node instance. More...
 
X3DNODEGetParent (void) const
 Function GetParent returns a pointer to the parent node of this object or NULL if the object has no parent (ie. More...
 
wxString GetName (void) const
 Function GetName returns the name of this object. More...
 
virtual bool SetParent (X3DNODE *aParent, bool doUnlink=true)=0
 Function SetParent sets the parent X3DNODE of this object. More...
 
virtual bool AddChildNode (X3DNODE *aNode)=0
 
virtual bool AddRefNode (X3DNODE *aNode)=0
 
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

X3DNODEm_Parent
 
X3DNODES m_Type
 
X3D_DICTm_Dict
 
std::list< X3DNODE * > m_BackPointers
 
std::list< X3DNODE * > m_Children
 
std::list< X3DNODE * > m_Refs
 
std::string m_error
 
wxString m_Name
 
SGNODEm_sgNode
 

Detailed Description

X3DNODE represents the base class of all X3D nodes.

Definition at line 75 of file x3d_base.h.

Constructor & Destructor Documentation

◆ X3DNODE()

X3DNODE::X3DNODE ( )

Definition at line 81 of file x3d_base.cpp.

82 {
84  m_Parent = NULL;
85  m_sgNode = NULL;
86  m_Dict = NULL;
87 
88  return;
89 }
X3DNODES m_Type
Definition: x3d_base.h:79
#define NULL
SGNODE * m_sgNode
Definition: x3d_base.h:88
X3DNODE * m_Parent
Definition: x3d_base.h:78
X3D_DICT * m_Dict
Definition: x3d_base.h:80

References m_Dict, m_Parent, m_sgNode, m_Type, NULL, and X3D_INVALID.

◆ ~X3DNODE()

X3DNODE::~X3DNODE ( )
virtual

Definition at line 92 of file x3d_base.cpp.

93 {
94  if( !m_Name.empty() && NULL != m_Dict )
95  m_Dict->DelName( m_Name, this );
96 
97  return;
98 }
bool DelName(const wxString &aName, X3DNODE *aNode)
Definition: x3d_base.cpp:50
wxString m_Name
Definition: x3d_base.h:87
#define NULL
X3D_DICT * m_Dict
Definition: x3d_base.h:80

References X3D_DICT::DelName(), m_Dict, m_Name, and NULL.

Member Function Documentation

◆ AddChildNode()

◆ addNodeRef()

void X3DNODE::addNodeRef ( X3DNODE 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 141 of file x3d_base.cpp.

142 {
143  // the parent node must never be added as a backpointer
144  if( aNode == m_Parent )
145  return;
146 
147  std::list< X3DNODE* >::iterator sR = m_BackPointers.begin();
148  std::list< X3DNODE* >::iterator eR = m_BackPointers.end();
149 
150  while( sR != eR )
151  {
152  if( *sR == aNode )
153  return;
154 
155  ++sR;
156  }
157 
158  m_BackPointers.push_back( aNode );
159 
160  return;
161 }
std::list< X3DNODE * > m_BackPointers
Definition: x3d_base.h:82
X3DNODE * m_Parent
Definition: x3d_base.h:78

References m_BackPointers, and m_Parent.

Referenced by X3DSHAPE::AddRefNode(), X3DIFACESET::AddRefNode(), and X3DTRANSFORM::AddRefNode().

◆ AddRefNode()

virtual bool X3DNODE::AddRefNode ( X3DNODE aNode)
pure virtual

◆ delNodeRef()

void X3DNODE::delNodeRef ( X3DNODE 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 164 of file x3d_base.cpp.

165 {
166  std::list< X3DNODE* >::iterator np =
167  std::find( m_BackPointers.begin(), m_BackPointers.end(), aNode );
168 
169  if( np != m_BackPointers.end() )
170  {
171  m_BackPointers.erase( np );
172  return;
173  }
174 
175  #ifdef DEBUG_X3D
176  std::ostringstream ostr;
177  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
178  ostr << " * [BUG] delNodeRef() did not find its target";
179  wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() );
180  #endif
181 
182  return;
183 }
std::list< X3DNODE * > m_BackPointers
Definition: x3d_base.h:82
#define MASK_VRML
Definition: wrltypes.h:37

References m_BackPointers, and MASK_VRML.

◆ GetError()

std::string X3DNODE::GetError ( void  )

Definition at line 204 of file x3d_base.cpp.

205 {
206  return m_error;
207 }
std::string m_error
Definition: x3d_base.h:85

References m_error.

◆ GetName()

wxString X3DNODE::GetName ( void  ) const

Function GetName returns the name of this object.

Definition at line 198 of file x3d_base.cpp.

199 {
200  return m_Name;
201 }
wxString m_Name
Definition: x3d_base.h:87

References m_Name.

◆ GetNodeType()

◆ GetParent()

X3DNODE * X3DNODE::GetParent ( void  ) const

Function GetParent returns a pointer to the parent node of this object or NULL if the object has no parent (ie.

top level transform)

Definition at line 192 of file x3d_base.cpp.

193 {
194  return m_Parent;
195 }
X3DNODE * m_Parent
Definition: x3d_base.h:78

References m_Parent.

Referenced by X3DSHAPE::AddChildNode(), X3DIFACESET::AddChildNode(), and X3DTRANSFORM::AddChildNode().

◆ Read()

virtual bool X3DNODE::Read ( wxXmlNode *  aNode,
X3DNODE aTopNode,
X3D_DICT aDict 
)
pure virtual

◆ SetParent()

virtual bool X3DNODE::SetParent ( X3DNODE aParent,
bool  doUnlink = true 
)
pure virtual

Function SetParent sets the parent X3DNODE 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.

Implemented in X3DAPP, X3DTRANSFORM, X3DIFACESET, X3DSHAPE, and X3DCOORDS.

Referenced by X3DSHAPE::AddChildNode(), X3DIFACESET::AddChildNode(), and X3DTRANSFORM::AddChildNode().

◆ TranslateToSG()

virtual SGNODE* X3DNODE::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 X3DAPP, X3DTRANSFORM, X3DIFACESET, X3DSHAPE, and X3DCOORDS.

Referenced by X3DPARSER::Load(), and X3DSHAPE::TranslateToSG().

◆ unlinkChildNode()

void X3DNODE::unlinkChildNode ( const X3DNODE 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 X3DSHAPE.

Definition at line 101 of file x3d_base.cpp.

102 {
103  std::list< X3DNODE* >::iterator sL = m_Children.begin();
104  std::list< X3DNODE* >::iterator eL = m_Children.end();
105 
106  while( sL != eL )
107  {
108  if( *sL == aNode )
109  {
110  m_Children.erase( sL );
111  return;
112  }
113 
114  ++sL;
115  }
116 
117  return;
118 }
std::list< X3DNODE * > m_Children
Definition: x3d_base.h:83

References m_Children.

Referenced by X3DCOORDS::SetParent(), X3DSHAPE::SetParent(), X3DIFACESET::SetParent(), X3DTRANSFORM::SetParent(), X3DAPP::SetParent(), and X3DSHAPE::unlinkChildNode().

◆ unlinkRefNode()

void X3DNODE::unlinkRefNode ( const X3DNODE 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 X3DSHAPE.

Definition at line 121 of file x3d_base.cpp.

122 {
123  std::list< X3DNODE* >::iterator sL = m_Refs.begin();
124  std::list< X3DNODE* >::iterator eL = m_Refs.end();
125 
126  while( sL != eL )
127  {
128  if( *sL == aNode )
129  {
130  m_Refs.erase( sL );
131  return;
132  }
133 
134  ++sL;
135  }
136 
137  return;
138 }
std::list< X3DNODE * > m_Refs
Definition: x3d_base.h:84

References m_Refs.

Referenced by X3DSHAPE::unlinkRefNode().

Member Data Documentation

◆ m_BackPointers

◆ m_Children

◆ m_Dict

◆ m_error

std::string X3DNODE::m_error
protected

Definition at line 85 of file x3d_base.h.

Referenced by GetError().

◆ m_Name

wxString X3DNODE::m_Name
protected

◆ m_Parent

◆ m_Refs

◆ m_sgNode

SGNODE* X3DNODE::m_sgNode
protected

◆ m_Type


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