KiCad PCB EDA Suite
WRL2SWITCH Class Reference

#include <vrml2_switch.h>

Inheritance diagram for WRL2SWITCH:
WRL2NODE

Public Member Functions

 WRL2SWITCH ()
 
 WRL2SWITCH (WRL2NODE *aNode)
 
virtual ~WRL2SWITCH ()
 
bool Read (WRLPROC &proc, WRL2BASE *aTopNode) override
 
bool AddRefNode (WRL2NODE *aNode) override
 
SGNODETranslateToSG (SGNODE *aParent) override
 Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg library. More...
 
bool isDangling (void) override
 Determine whether an object should be moved to a different parent during the VRML to SG* translation. More...
 
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)
 
std::string GetError (void)
 
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...
 

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
 

Private Member Functions

bool readChildren (WRLPROC &proc, WRL2BASE *aTopNode)
 

Private Attributes

int whichChoice
 
std::vector< WRL2NODE * > choices
 

Detailed Description

Definition at line 39 of file vrml2_switch.h.

Constructor & Destructor Documentation

◆ WRL2SWITCH() [1/2]

WRL2SWITCH::WRL2SWITCH ( )

Definition at line 34 of file vrml2_switch.cpp.

34 : WRL2NODE()
35{
37 whichChoice = -1;
38}
WRL2NODES m_Type
Definition: vrml2_node.h:170
int whichChoice
Definition: vrml2_switch.h:53

References WRL2NODE::m_Type, whichChoice, and WRL2_SWITCH.

◆ WRL2SWITCH() [2/2]

WRL2SWITCH::WRL2SWITCH ( WRL2NODE aNode)

Definition at line 41 of file vrml2_switch.cpp.

41 : WRL2NODE()
42{
44 m_Parent = aParent;
45 whichChoice = -1;
46
47 if( nullptr != m_Parent )
48 m_Parent->AddChildNode( this );
49}
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:356

References WRL2NODE::AddChildNode(), WRL2NODE::m_Parent, WRL2NODE::m_Type, whichChoice, and WRL2_SWITCH.

◆ ~WRL2SWITCH()

WRL2SWITCH::~WRL2SWITCH ( )
virtual

Definition at line 52 of file vrml2_switch.cpp.

53{
54 wxLogTrace( traceVrmlPlugin,
55 wxT( " * [INFO] Destroying Switch node with %zu children, %zu"
56 "references, and %zu back pointers." ),
57 m_Children.size(), m_Refs.size(), m_BackPointers.size() );
58}
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63

References WRL2NODE::m_BackPointers, WRL2NODE::m_Children, WRL2NODE::m_Refs, and traceVrmlPlugin.

Member Function Documentation

◆ AddChildNode()

bool WRL2NODE::AddChildNode ( WRL2NODE aNode)
virtualinherited

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 WRL2NODE::GetNodeType(), WRL2NODE::GetParent(), WRL2NODE::m_Children, WRL2NODE::SetParent(), and WRL2_BASE.

Referenced by WRL2APPEARANCE::AddChildNode(), WRL2FACESET::AddChildNode(), WRL2LINESET::AddChildNode(), WRL2POINTSET::AddChildNode(), WRL2SHAPE::AddChildNode(), AddRefNode(), WRL2TRANSFORM::AddRefNode(), WRL2NODE::SetParent(), WRL2APPEARANCE::WRL2APPEARANCE(), WRL2BOX::WRL2BOX(), WRL2COLOR::WRL2COLOR(), WRL2COORDS::WRL2COORDS(), WRL2FACESET::WRL2FACESET(), WRL2INLINE::WRL2INLINE(), WRL2LINESET::WRL2LINESET(), WRL2MATERIAL::WRL2MATERIAL(), WRL2NORMS::WRL2NORMS(), WRL2POINTSET::WRL2POINTSET(), WRL2SHAPE::WRL2SHAPE(), WRL2SWITCH(), and WRL2TRANSFORM::WRL2TRANSFORM().

◆ addNodeRef()

void WRL2NODE::addNodeRef ( WRL2NODE aNode)
inherited

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 WRL2NODE::m_BackPointers, and WRL2NODE::m_Parent.

Referenced by WRL2NODE::AddRefNode().

◆ AddRefNode()

bool WRL2SWITCH::AddRefNode ( WRL2NODE aNode)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 161 of file vrml2_switch.cpp.

162{
163 wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
164
165 // take possession if the node is dangling WRL2_SHAPE
166 if( WRL2NODES::WRL2_SHAPE == aNode->GetNodeType() && aNode->isDangling() )
167 {
168 WRL2NODE* np = aNode->GetParent();
169
170 if( nullptr != np )
171 aNode->SetParent( this );
172
173 if( !WRL2NODE::AddChildNode( aNode ) )
174 {
175 aNode->SetParent( nullptr );
176 return false;
177 }
178 }
179
180 if( !WRL2NODE::AddRefNode( aNode ) )
181 return false;
182
183 return true;
184}
virtual bool isDangling(void)=0
Determine whether an object should be moved to a different parent during the VRML to SG* translation.
virtual bool AddRefNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:383

References WRL2NODE::AddChildNode(), WRL2NODE::AddRefNode(), WRL2NODE::GetNodeType(), WRL2NODE::GetParent(), WRL2NODE::isDangling(), WRL2NODE::SetParent(), and WRL2_SHAPE.

◆ delNodeRef()

void WRL2NODE::delNodeRef ( WRL2NODE aNode)
inherited

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}

References WRL2NODE::m_BackPointers, and traceVrmlPlugin.

◆ FindNode()

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

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 WRL2NODE::FindNode(), WRL2NODE::m_Children, WRL2NODE::m_Name, and WRL2NODE::m_Parent.

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

◆ GetError()

std::string WRL2NODE::GetError ( void  )
inherited

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

◆ GetName()

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

Reimplemented in WRL2BASE.

Definition at line 216 of file vrml2_node.cpp.

217{
218 return m_Name;
219}

References WRL2NODE::m_Name.

◆ GetNodeType()

◆ getNodeTypeID()

WRL2NODES WRL2NODE::getNodeTypeID ( const std::string &  aNodeName)
inherited
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}
static NODEMAP nodenames
Definition: vrml2_node.cpp:43

References nodenames, and WRL2_INVALID.

Referenced by WRL2BASE::ReadNode().

◆ GetNodeTypeName()

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

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
inherited

◆ isDangling()

bool WRL2SWITCH::isDangling ( void  )
overridevirtual

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.

Implements WRL2NODE.

Definition at line 61 of file vrml2_switch.cpp.

62{
63 // a Switch node is never dangling
64 return false;
65}

◆ Read()

bool WRL2SWITCH::Read ( WRLPROC proc,
WRL2BASE aTopNode 
)
overridevirtual

Implements WRL2NODE.

Definition at line 68 of file vrml2_switch.cpp.

69{
70 /*
71 * Structure of a Switch node (p.113):
72 *
73 * Switch {
74 * exposedField MFNode choice []
75 * exposedField SFInt32 whichChoice -1
76 * }
77 */
78
79 wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
80
81 char tok = proc.Peek();
82
83 if( proc.eof() )
84 {
85 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
86 " * [INFO] bad file format; unexpected eof %s." ),
87 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
88
89 return false;
90 }
91
92 if( '{' != tok )
93 {
94 wxLogTrace( traceVrmlPlugin,
95 wxT( "%s:%s:%d\n"
96 " * [INFO] bad file format; expecting '{' but got '%s' %s." ),
97 __FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
98
99 return false;
100 }
101
102 proc.Pop();
103 std::string glob;
104
105 while( true )
106 {
107 if( proc.Peek() == '}' )
108 {
109 proc.Pop();
110 break;
111 }
112
113 if( !proc.ReadName( glob ) )
114 {
115 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
116 "%s" ),
117 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
118
119 return false;
120 }
121
122 // expecting one of:
123 // choice
124 // whichChoice
125 if( !glob.compare( "whichChoice" ) )
126 {
127 if( !proc.ReadSFInt( whichChoice ) )
128 {
129 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
130 " * [INFO] invalid whichChoice %s\n"
131 " * [INFO] file: '%s'\n"
132 "%s" ),
133 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
134 proc.GetFileName(), proc.GetError() );
135
136 return false;
137 }
138 }
139 else if( !glob.compare( "choice" ) )
140 {
141 if( !readChildren( proc, aTopNode ) )
142 return false;
143 }
144 else
145 {
146 wxLogTrace( traceVrmlPlugin,
147 wxT( "%s:%s:%d\n"
148 " * [INFO] invalid Switch %s.\n"
149 " * [INFO] file: '%s'\n" ),
150 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
151 proc.GetFileName() );
152
153 return false;
154 }
155 } // while( true ) -- reading contents of Switch{}
156
157 return true;
158}
bool readChildren(WRLPROC &proc, WRL2BASE *aTopNode)
bool ReadSFInt(int &aSFInt32)
Definition: wrlproc.cpp:867
void Pop(void)
Definition: wrlproc.cpp:2035
char Peek(void)
Definition: wrlproc.cpp:2007
std::string GetFileName(void)
Definition: wrlproc.cpp:1995
std::string GetError(void)
Definition: wrlproc.cpp:1960
bool eof(void)
Definition: wrlproc.cpp:1954
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982

References WRLPROC::eof(), WRLPROC::GetError(), WRLPROC::GetFileName(), WRLPROC::GetFilePosition(), WRLPROC::Peek(), WRLPROC::Pop(), readChildren(), WRLPROC::ReadName(), WRLPROC::ReadSFInt(), traceVrmlPlugin, and whichChoice.

Referenced by WRL2BASE::readSwitch().

◆ readChildren()

bool WRL2SWITCH::readChildren ( WRLPROC proc,
WRL2BASE aTopNode 
)
private

Definition at line 187 of file vrml2_switch.cpp.

188{
189 char tok = proc.Peek();
190
191 if( proc.eof() )
192 {
193 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
194 " * [INFO] bad file format; unexpected eof %s." ),
195 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
196
197 return false;
198 }
199
200 WRL2NODE* child = nullptr;
201
202 if( '[' != tok )
203 {
204 // since there are no delimiters we expect a single child
205 if( !aTopNode->ReadNode( proc, this, &child ) )
206 return false;
207
208 if( nullptr != child )
209 choices.push_back( child );
210
211 if( proc.Peek() == ',' )
212 proc.Pop();
213
214 return true;
215 }
216
217 proc.Pop();
218
219 while( true )
220 {
221 if( proc.Peek() == ']' )
222 {
223 proc.Pop();
224 break;
225 }
226
227 if( !aTopNode->ReadNode( proc, this, &child ) )
228 return false;
229
230 if( nullptr != child )
231 choices.push_back( child );
232
233 if( proc.Peek() == ',' )
234 proc.Pop();
235
236 }
237
238 return true;
239}
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:277
std::vector< WRL2NODE * > choices
Definition: vrml2_switch.h:54

References choices, WRLPROC::eof(), WRLPROC::GetFilePosition(), WRLPROC::Peek(), WRLPROC::Pop(), WRL2BASE::ReadNode(), and traceVrmlPlugin.

Referenced by Read().

◆ SetName()

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

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
static std::set< std::string > badNames
Definition: vrml2_node.cpp:39

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

Referenced by WRL2BASE::implementDef().

◆ SetParent()

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

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 void unlinkChildNode(const WRL2NODE *aNode)
Remove references to an owned child.
Definition: vrml2_node.cpp:407

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

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

◆ TranslateToSG()

SGNODE * WRL2SWITCH::TranslateToSG ( SGNODE aParent)
overridevirtual

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.

Implements WRL2NODE.

Definition at line 242 of file vrml2_switch.cpp.

243{
244 wxLogTrace( traceVrmlPlugin,
245 wxT( " * [INFO] Translating Switch with %zu children, %zu references, and"
246 "%zu back pointers." ),
247 m_Children.size(), m_Refs.size(), m_BackPointers.size() );
248
249 if( choices.empty() )
250 {
251 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Switch translation: no choices." ) );
252
253 return nullptr;
254 }
255
256 S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
257
258 wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_TRANSFORM ), nullptr,
259 wxString::Format( wxT( "Switch does not have a Transform parent (parent "
260 "ID: %d)." ), ptype ) );
261
262 if( whichChoice < 0 || whichChoice >= (int)choices.size() )
263 {
264 wxLogTrace( traceVrmlPlugin,
265 wxT( " * [INFO] Switch translation: no choice (choices = %zu), "
266 "whichChoice = %d." ), choices.size(), whichChoice );
267
268 return nullptr;
269 }
270
271 WRL2NODES type = choices[whichChoice]->GetNodeType();
272
273 switch( type )
274 {
279 break;
280
281 default:
282 return nullptr;
283 }
284
285 return choices[whichChoice]->TranslateToSG( aParent );
286}
SGLIB_API S3D::SGTYPES GetSGNodeType(SGNODE *aNode)
Definition: ifsg_api.cpp:485
SGTYPES
Definition: sg_types.h:35
@ SGTYPE_TRANSFORM
Definition: sg_types.h:36
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
WRL2NODES
Definition: wrltypes.h:125

References choices, Format(), S3D::GetSGNodeType(), WRL2NODE::m_BackPointers, WRL2NODE::m_Children, WRL2NODE::m_Refs, S3D::SGTYPE_TRANSFORM, traceVrmlPlugin, whichChoice, WRL2_INLINE, WRL2_SHAPE, WRL2_SWITCH, and WRL2_TRANSFORM.

◆ unlinkChildNode()

void WRL2NODE::unlinkChildNode ( const WRL2NODE aNode)
virtualinherited

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 WRL2NODE::m_Children.

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

◆ unlinkRefNode()

void WRL2NODE::unlinkRefNode ( const WRL2NODE aNode)
virtualinherited

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 WRL2NODE::m_Refs.

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

Member Data Documentation

◆ choices

std::vector< WRL2NODE* > WRL2SWITCH::choices
private

Definition at line 54 of file vrml2_switch.h.

Referenced by readChildren(), and TranslateToSG().

◆ m_BackPointers

◆ m_Children

◆ m_error

std::string WRL2NODE::m_error
protectedinherited

Definition at line 176 of file vrml2_node.h.

Referenced by WRL2NODE::GetError().

◆ m_Name

std::string WRL2NODE::m_Name
protectedinherited

Definition at line 171 of file vrml2_node.h.

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

◆ m_Parent

◆ m_Refs

◆ m_sgNode

◆ m_Type

◆ whichChoice

int WRL2SWITCH::whichChoice
private

Definition at line 53 of file vrml2_switch.h.

Referenced by Read(), TranslateToSG(), and WRL2SWITCH().


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