KiCad PCB EDA Suite
WRL2NODE Class Referenceabstract

#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

 WRL2NODE ()
 
virtual ~WRL2NODE ()
 
virtual bool Read (WRLPROC &proc, WRL2BASE *aTopNode)=0
 
WRL2NODES GetNodeType (void) const
 
WRL2NODEGetParent (void) const
 
virtual bool SetParent (WRL2NODE *aParent, bool doUnlink=true)
 Set 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)
 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)
 
virtual SGNODETranslateToSG (SGNODE *aParent)=0
 Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg library. More...
 
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...
 
virtual bool isDangling (void)=0
 Determine whether an object should be moved to a different parent during the VRML to SG* translation. 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

Definition at line 55 of file vrml2_node.h.

Constructor & Destructor Documentation

◆ WRL2NODE()

WRL2NODE::WRL2NODE ( )

Definition at line 46 of file vrml2_node.cpp.

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

References badNames, m_Parent, m_sgNode, m_Type, nodenames, 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 133 of file vrml2_node.cpp.

134{
135 if( m_Parent )
136 m_Parent->unlinkChildNode( this );
137
138 std::list< WRL2NODE* >::iterator sBP = m_BackPointers.begin();
139 std::list< WRL2NODE* >::iterator eBP = m_BackPointers.end();
140
141 while( sBP != eBP )
142 {
143 (*sBP)->unlinkRefNode( this );
144 ++sBP;
145 }
146
147 std::list< WRL2NODE* >::iterator sC = m_Refs.begin();
148 std::list< WRL2NODE* >::iterator eC = m_Refs.end();
149
150 while( sC != eC )
151 {
152 (*sC)->delNodeRef( this );
153 ++sC;
154 }
155
156 m_Refs.clear();
157 sC = m_Children.begin();
158 eC = m_Children.end();
159
160 while( sC != eC )
161 {
162 (*sC)->SetParent( nullptr, false );
163 delete *sC;
164 ++sC;
165 }
166
167 m_Children.clear();
168}
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
virtual void unlinkChildNode(const WRL2NODE *aNode)
Remove references to an owned child.
Definition: vrml2_node.cpp:407
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175

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

Member Function Documentation

◆ AddChildNode()

bool WRL2NODE::AddChildNode ( WRL2NODE aNode)
virtual

Reimplemented in WRL2APPEARANCE, WRL2BOX, WRL2COLOR, WRL2COORDS, WRL2FACESET, WRL2INLINE, WRL2LINESET, WRL2MATERIAL, WRL2NORMS, WRL2POINTSET, 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}
WRL2NODE * GetParent(void) const
Definition: vrml2_node.cpp:210
virtual bool SetParent(WRL2NODE *aParent, bool doUnlink=true)
Set the parent WRL2NODE of this object.
Definition: vrml2_node.cpp:339
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204

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

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

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}

References m_BackPointers, and m_Parent.

Referenced by AddRefNode().

◆ AddRefNode()

bool WRL2NODE::AddRefNode ( WRL2NODE aNode)
virtual

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

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

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

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

◆ delNodeRef()

void WRL2NODE::delNodeRef ( WRL2NODE 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 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}
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63

References m_BackPointers, and traceVrmlPlugin.

◆ FindNode()

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

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::string m_Name
Definition: vrml2_node.h:171
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 FindNode(), m_Children, m_Name, and m_Parent.

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

◆ GetError()

std::string WRL2NODE::GetError ( void  )

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 m_error.

◆ GetName()

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

Reimplemented in WRL2BASE.

Definition at line 216 of file vrml2_node.cpp.

217{
218 return m_Name;
219}

References m_Name.

◆ GetNodeType()

◆ getNodeTypeID()

WRL2NODES WRL2NODE::getNodeTypeID ( const std::string &  aNodeName)
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}

References nodenames, and WRL2_INVALID.

Referenced by WRL2BASE::ReadNode().

◆ GetNodeTypeName()

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

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}

References nodenames, WRL2_BASE, WRL2_BEGIN, and WRL2_END.

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

◆ GetParent()

WRL2NODE * WRL2NODE::GetParent ( void  ) const

◆ isDangling()

virtual bool WRL2NODE::isDangling ( void  )
pure virtual

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.

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

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

223{
224 if( aName.empty() )
225 return false;
226
227 std::set< std::string >::iterator item = badNames.find( aName );
228
229 if( item != badNames.end() )
230 {
231 wxLogTrace( traceVrmlPlugin,
232 wxT( "%s:%s:%d\n"
233 " * [INFO] invalid node name '%s' (matches restricted word)" ),
234 __FILE__, __FUNCTION__, __LINE__, *item );
235
236 return false;
237 }
238
239
240 if( isdigit( aName[0] ) )
241 {
242 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
243 " * [INFO] invalid node name '%s' (begins with digit)" ),
244 __FILE__, __FUNCTION__, __LINE__, aName );
245
246 return false;
247 }
248
249 // The characters '+' and '-' are not allowed in names as per the VRML2 specification;
250 // however many parsers accept them and many bad generators use them so the rules
251 // have been relaxed here.
252 // #define BAD_CHARS1 "\"\'#+,-.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
253 #define BAD_CHARS1 "\"\'#,.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
254 #define BAD_CHARS2 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
255
256 if( std::string::npos != aName.find_first_of( BAD_CHARS1 )
257 || std::string::npos != aName.find_first_of( BAD_CHARS2 ) )
258 {
259 wxLogTrace( traceVrmlPlugin,
260 wxT( "%s:%s:%d\n"
261 " * [INFO] invalid node name '%s' (contains invalid character)" ),
262 __FILE__, __FUNCTION__, __LINE__, aName );
263
264 return false;
265 }
266
267 m_Name = aName;
268
269 return true;
270}
#define BAD_CHARS2
#define BAD_CHARS1

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

Referenced by WRL2BASE::implementDef().

◆ SetParent()

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

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 in WRL2BASE.

Definition at line 339 of file vrml2_node.cpp.

340{
341 if( aParent == m_Parent )
342 return true;
343
344 if( nullptr != m_Parent && doUnlink )
345 m_Parent->unlinkChildNode( this );
346
347 m_Parent = aParent;
348
349 if( nullptr != m_Parent )
350 m_Parent->AddChildNode( this );
351
352 return true;
353}
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:356

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

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

◆ TranslateToSG()

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

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

◆ unlinkChildNode()

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

Reimplemented in WRL2APPEARANCE, WRL2FACESET, WRL2LINESET, WRL2POINTSET, 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}

References m_Children.

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

◆ unlinkRefNode()

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

Reimplemented in WRL2APPEARANCE, WRL2FACESET, WRL2LINESET, WRL2POINTSET, 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}

References m_Refs.

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

Member Data Documentation

◆ m_BackPointers

◆ m_Children

◆ m_error

std::string WRL2NODE::m_error
protected

Definition at line 176 of file vrml2_node.h.

Referenced by GetError().

◆ m_Name

std::string WRL2NODE::m_Name
protected

Definition at line 171 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: