KiCad PCB EDA Suite
WRL2LINESET Class Reference

#include <vrml2_lineset.h>

Inheritance diagram for WRL2LINESET:
WRL2NODE

Public Member Functions

 WRL2LINESET ()
 
 WRL2LINESET (WRL2NODE *aParent)
 
virtual ~WRL2LINESET ()
 
bool Read (WRLPROC &proc, WRL2BASE *aTopNode) override
 
bool AddRefNode (WRL2NODE *aNode) override
 
bool AddChildNode (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 HasColors (void)
 
bool isDangling (void) override
 Determine whether an object should be moved to a different parent during the VRML to SG* translation. More...
 
void unlinkChildNode (const WRL2NODE *aNode) override
 Remove references to an owned child. More...
 
void unlinkRefNode (const WRL2NODE *aNode) override
 Remove pointers to a referenced node. 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...
 
std::string GetError (void)
 
WRL2NODES getNodeTypeID (const std::string &aNodeName)
 
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 checkNodeType (WRL2NODES aType)
 
void setDefaults (void)
 

Private Attributes

WRL2NODEcolor
 
WRL2NODEcoord
 
bool colorPerVertex
 
std::vector< int > colorIndex
 
std::vector< int > coordIndex
 

Detailed Description

Definition at line 40 of file vrml2_lineset.h.

Constructor & Destructor Documentation

◆ WRL2LINESET() [1/2]

WRL2LINESET::WRL2LINESET ( )

Definition at line 37 of file vrml2_lineset.cpp.

References WRL2NODE::m_Type, setDefaults(), and WRL2_INDEXEDLINESET.

◆ WRL2LINESET() [2/2]

WRL2LINESET::WRL2LINESET ( WRL2NODE aParent)

Definition at line 44 of file vrml2_lineset.cpp.

44  : WRL2NODE()
45 {
46  setDefaults();
48  m_Parent = aParent;
49 
50  if( nullptr != m_Parent )
51  m_Parent->AddChildNode( this );
52 }
WRL2NODES m_Type
Definition: vrml2_node.h:170
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
void setDefaults(void)
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:356

References WRL2NODE::AddChildNode(), WRL2NODE::m_Parent, WRL2NODE::m_Type, setDefaults(), and WRL2_INDEXEDLINESET.

◆ ~WRL2LINESET()

WRL2LINESET::~WRL2LINESET ( )
virtual

Definition at line 55 of file vrml2_lineset.cpp.

56 {
57  wxLogTrace( traceVrmlPlugin,
58  wxT( " * [INFO] Destroying IndexedLineSet node with %zu children, %zu"
59  "references, and %zu back pointers." ),
60  m_Children.size(), m_Refs.size(), m_BackPointers.size() );
61 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
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 WRL2LINESET::AddChildNode ( WRL2NODE aNode)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 156 of file vrml2_lineset.cpp.

157 {
158  wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
159 
160  WRL2NODES type = aNode->GetNodeType();
161 
162  if( !checkNodeType( type ) )
163  {
164  wxLogTrace( traceVrmlPlugin,
165  wxT( "%s:%s:%d\n"
166  " * [INFO] bad file format; unexpected child node '%s'." ),
167  __FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
168 
169  return false;
170  }
171 
172  if( WRL2NODES::WRL2_COLOR == type )
173  {
174  if( nullptr != color )
175  {
176  wxLogTrace( traceVrmlPlugin,
177  wxT( "%s:%s:%d\n"
178  " * [INFO] bad file format; multiple color nodes." ),
179  __FILE__, __FUNCTION__, __LINE__ );
180 
181  return false;
182  }
183 
184  color = aNode;
185  return WRL2NODE::AddChildNode( aNode );
186  }
187 
188  if( WRL2NODES::WRL2_COORDINATE == type )
189  {
190  if( nullptr != coord )
191  {
192  wxLogTrace( traceVrmlPlugin,
193  wxT( "%s:%s:%d\n"
194  " * [INFO] bad file format; multiple coord nodes." ),
195  __FILE__, __FUNCTION__, __LINE__ );
196 
197  return false;
198  }
199 
200  coord = aNode;
201  return WRL2NODE::AddChildNode( aNode );
202  }
203 
204  return WRL2NODE::AddChildNode( aNode );
205 }
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
const char * GetNodeTypeName(WRL2NODES aNodeType) const
Definition: vrml2_node.cpp:273
WRL2NODE * coord
Definition: vrml2_lineset.h:71
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:356
WRL2NODES
Definition: wrltypes.h:124
WRL2NODE * color
Definition: vrml2_lineset.h:70
bool checkNodeType(WRL2NODES aType)

References WRL2NODE::AddChildNode(), checkNodeType(), color, coord, WRL2NODE::GetNodeType(), WRL2NODE::GetNodeTypeName(), traceVrmlPlugin, WRL2_COLOR, and WRL2_COORDINATE.

◆ 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 }
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173

References WRL2NODE::m_BackPointers, and WRL2NODE::m_Parent.

Referenced by WRL2NODE::AddRefNode().

◆ AddRefNode()

bool WRL2LINESET::AddRefNode ( WRL2NODE aNode)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 104 of file vrml2_lineset.cpp.

105 {
106  wxCHECK_MSG( aNode, false, wxT( "Invalid node." ) );
107 
108  WRL2NODES type = aNode->GetNodeType();
109 
110  if( !checkNodeType( type ) )
111  {
112  wxLogTrace( traceVrmlPlugin,
113  wxT( "%s:%s:%d\n"
114  " * [INFO] bad file format; unexpected child node '%s'." ),
115  __FILE__, __FUNCTION__, __LINE__, aNode->GetNodeTypeName( type ) );
116 
117  return false;
118  }
119 
120  if( WRL2NODES::WRL2_COLOR == type )
121  {
122  if( nullptr != color )
123  {
124  wxLogTrace( traceVrmlPlugin,
125  wxT( "%s:%s:%d\n"
126  " * [INFO] bad file format; multiple color nodes." ),
127  __FILE__, __FUNCTION__, __LINE__ );
128 
129  return false;
130  }
131 
132  color = aNode;
133  return WRL2NODE::AddRefNode( aNode );
134  }
135 
136  if( WRL2NODES::WRL2_COORDINATE == type )
137  {
138  if( nullptr != coord )
139  {
140  wxLogTrace( traceVrmlPlugin,
141  wxT( "%s:%s:%d\n"
142  " * [INFO] bad file format; multiple coord nodes." ),
143  __FILE__, __FUNCTION__, __LINE__ );
144 
145  return false;
146  }
147 
148  coord = aNode;
149  return WRL2NODE::AddRefNode( aNode );
150  }
151 
152  return WRL2NODE::AddRefNode( aNode );
153 }
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
const char * GetNodeTypeName(WRL2NODES aNodeType) const
Definition: vrml2_node.cpp:273
WRL2NODE * coord
Definition: vrml2_lineset.h:71
WRL2NODES
Definition: wrltypes.h:124
virtual bool AddRefNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:383
WRL2NODE * color
Definition: vrml2_lineset.h:70
bool checkNodeType(WRL2NODES aType)

References WRL2NODE::AddRefNode(), checkNodeType(), color, coord, WRL2NODE::GetNodeType(), WRL2NODE::GetNodeTypeName(), traceVrmlPlugin, WRL2_COLOR, and WRL2_COORDINATE.

◆ checkNodeType()

bool WRL2LINESET::checkNodeType ( WRL2NODES  aType)
private
Returns
true if the node type is a valid subnode of LineSet.

Definition at line 72 of file vrml2_lineset.cpp.

73 {
74  // nodes must be one of:
75  // Color
76  // Coordinate
77 
78  switch( aType )
79  {
82  break;
83 
84  default:
85  return false;
86  break;
87  }
88 
89  return true;
90 }

References WRL2_COLOR, and WRL2_COORDINATE.

Referenced by AddChildNode(), and AddRefNode().

◆ 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 }
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63

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::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
std::string m_Name
Definition: vrml2_node.h:171
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
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 }
std::string m_Name
Definition: vrml2_node.h:171

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 }
static NODEMAP nodenames
Definition: vrml2_node.cpp:43

References nodenames, WRL2_BASE, WRL2_BEGIN, and WRL2_END.

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

◆ GetParent()

WRL2NODE * WRL2NODE::GetParent ( void  ) const
inherited
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 210 of file vrml2_node.cpp.

211 {
212  return m_Parent;
213 }
WRL2NODE * m_Parent
Definition: vrml2_node.h:169

References WRL2NODE::m_Parent.

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

◆ HasColors()

bool WRL2LINESET::HasColors ( void  )
Returns
true if the line set has a color node.

Definition at line 386 of file vrml2_lineset.cpp.

387 {
388  if( nullptr == color )
389  return false;
390 
391  return ((WRL2COLOR*) color)->HasColors();
392 }
WRL2NODE * color
Definition: vrml2_lineset.h:70

References color.

◆ isDangling()

bool WRL2LINESET::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 93 of file vrml2_lineset.cpp.

94 {
95  // this node is dangling unless it has a parent of type WRL2_SHAPE
96 
97  if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE )
98  return true;
99 
100  return false;
101 }
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204

References WRL2NODE::GetNodeType(), WRL2NODE::m_Parent, and WRL2_SHAPE.

◆ Read()

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

Implements WRL2NODE.

Definition at line 209 of file vrml2_lineset.cpp.

210 {
211  char tok = proc.Peek();
212 
213  if( proc.eof() )
214  {
215  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
216  " * [INFO] bad file format; unexpected eof %s." ),
217  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
218 
219  return false;
220  }
221 
222  if( '{' != tok )
223  {
224  wxLogTrace( traceVrmlPlugin,
225  wxT( "%s:%s:%d\n"
226  " * [INFO] bad file format; expecting '{' but got '%s' %s." ),
227  __FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
228 
229  return false;
230  }
231 
232  proc.Pop();
233  std::string glob;
234 
235  while( true )
236  {
237  if( proc.Peek() == '}' )
238  {
239  proc.Pop();
240  break;
241  }
242 
243  if( !proc.ReadName( glob ) )
244  {
245  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
246  "%s" ),
247  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
248 
249  return false;
250  }
251 
252  // expecting one of:
253  // [node]
254  // color
255  // coord
256  // [bool]
257  // colorPerVertex
258  // [ vector<int> ]
259  // colorIndex
260  // coordIndex
261 
262  if( !glob.compare( "colorPerVertex" ) )
263  {
264  if( !proc.ReadSFBool( colorPerVertex ) )
265  {
266  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
267  " * [INFO] invalid colorPerVertex %s\n"
268  " * [INFO] file: '%s'\n"
269  "%s" ),
270  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
271  proc.GetFileName(), proc.GetError() );
272 
273  return false;
274  }
275  }
276  else if( !glob.compare( "colorIndex" ) )
277  {
278  if( !proc.ReadMFInt( colorIndex ) )
279  {
280  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
281  " * [INFO] invalid colorIndex %s\n"
282  " * [INFO] file: '%s'\n"
283  "%s" ),
284  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
285  proc.GetFileName(), proc.GetError() );
286 
287  return false;
288  }
289  }
290  else if( !glob.compare( "coordIndex" ) )
291  {
292  if( !proc.ReadMFInt( coordIndex ) )
293  {
294  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
295  " * [INFO] invalid coordIndex %s\n"
296  " * [INFO] file: '%s'\n"
297  "%s" ),
298  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
299  proc.GetFileName(), proc.GetError() );
300 
301  return false;
302  }
303  }
304  else if( !glob.compare( "color" ) )
305  {
306  if( !aTopNode->ReadNode( proc, this, nullptr ) )
307  {
308  wxLogTrace( traceVrmlPlugin,
309  wxT( "%s:%s:%d\n"
310  " * [INFO] could not read color node information." ),
311  __FILE__, __FUNCTION__, __LINE__ );
312 
313  return false;
314  }
315  }
316  else if( !glob.compare( "coord" ) )
317  {
318  if( !aTopNode->ReadNode( proc, this, nullptr ) )
319  {
320  wxLogTrace( traceVrmlPlugin,
321  wxT( "%s:%s:%d\n"
322  " * [INFO] could not read coord node information." ),
323  __FILE__, __FUNCTION__, __LINE__ );
324 
325  return false;
326  }
327  }
328  else
329  {
330  wxLogTrace( traceVrmlPlugin,
331  wxT( "%s:%s:%d\n"
332  " * [INFO] invalid IndexedFaceSet %s\n"
333  " * [INFO] file: '%s'\n" ),
334  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
335  proc.GetFileName() );
336 
337  return false;
338  }
339  } // while( true ) -- reading contents of IndexedLineSet{}
340 
341  return true;
342 }
bool colorPerVertex
Definition: vrml2_lineset.h:73
void Pop(void)
Definition: wrlproc.cpp:2035
std::vector< int > colorIndex
Definition: vrml2_lineset.h:75
bool ReadMFInt(std::vector< int > &aMFInt32)
Definition: wrlproc.cpp:1504
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:276
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982
std::vector< int > coordIndex
Definition: vrml2_lineset.h:76
bool ReadSFBool(bool &aSFBool)
Definition: wrlproc.cpp:729
char Peek(void)
Definition: wrlproc.cpp:2007
std::string GetFileName(void)
Definition: wrlproc.cpp:1995
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
std::string GetError(void)
Definition: wrlproc.cpp:1960
bool eof(void)
Definition: wrlproc.cpp:1954

References colorIndex, colorPerVertex, coordIndex, WRLPROC::eof(), WRLPROC::GetError(), WRLPROC::GetFileName(), WRLPROC::GetFilePosition(), WRLPROC::Peek(), WRLPROC::Pop(), WRLPROC::ReadMFInt(), WRLPROC::ReadName(), WRL2BASE::ReadNode(), WRLPROC::ReadSFBool(), and traceVrmlPlugin.

Referenced by WRL2BASE::readLineSet().

◆ setDefaults()

void WRL2LINESET::setDefaults ( void  )
private

Definition at line 64 of file vrml2_lineset.cpp.

65 {
66  color = nullptr;
67  coord = nullptr;
68  colorPerVertex = true;
69 }
bool colorPerVertex
Definition: vrml2_lineset.h:73
WRL2NODE * coord
Definition: vrml2_lineset.h:71
WRL2NODE * color
Definition: vrml2_lineset.h:70

References color, colorPerVertex, and coord.

Referenced by WRL2LINESET().

◆ 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_CHARS1
#define BAD_CHARS2
std::string m_Name
Definition: vrml2_node.h:171
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63
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 }
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:356
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(), WRL2TRANSFORM::AddRefNode(), and WRL2SWITCH::AddRefNode().

◆ TranslateToSG()

SGNODE * WRL2LINESET::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 345 of file vrml2_lineset.cpp.

346 {
347  // note: there are no plans to support drawing of lines
348  return nullptr;
349 }

◆ unlinkChildNode()

void WRL2LINESET::unlinkChildNode ( const WRL2NODE aNode)
overridevirtual

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 from WRL2NODE.

Definition at line 352 of file vrml2_lineset.cpp.

353 {
354  if( nullptr == aNode )
355  return;
356 
357  if( aNode->GetParent() == this )
358  {
359  if( aNode == color )
360  color = nullptr;
361  else if( aNode == coord )
362  coord = nullptr;
363  }
364 
365  WRL2NODE::unlinkChildNode( aNode );
366 }
WRL2NODE * coord
Definition: vrml2_lineset.h:71
WRL2NODE * GetParent(void) const
Definition: vrml2_node.cpp:210
virtual void unlinkChildNode(const WRL2NODE *aNode)
Remove references to an owned child.
Definition: vrml2_node.cpp:407
WRL2NODE * color
Definition: vrml2_lineset.h:70

References color, coord, WRL2NODE::GetParent(), and WRL2NODE::unlinkChildNode().

◆ unlinkRefNode()

void WRL2LINESET::unlinkRefNode ( const WRL2NODE aNode)
overridevirtual

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 from WRL2NODE.

Definition at line 369 of file vrml2_lineset.cpp.

370 {
371  if( nullptr == aNode )
372  return;
373 
374  if( aNode->GetParent() != this )
375  {
376  if( aNode == color )
377  color = nullptr;
378  else if( aNode == coord )
379  coord = nullptr;
380  }
381 
382  WRL2NODE::unlinkRefNode( aNode );
383 }
WRL2NODE * coord
Definition: vrml2_lineset.h:71
virtual void unlinkRefNode(const WRL2NODE *aNode)
Remove pointers to a referenced node.
Definition: vrml2_node.cpp:425
WRL2NODE * GetParent(void) const
Definition: vrml2_node.cpp:210
WRL2NODE * color
Definition: vrml2_lineset.h:70

References color, coord, WRL2NODE::GetParent(), and WRL2NODE::unlinkRefNode().

Member Data Documentation

◆ color

WRL2NODE* WRL2LINESET::color
private

◆ colorIndex

std::vector< int > WRL2LINESET::colorIndex
private

Definition at line 75 of file vrml2_lineset.h.

Referenced by Read().

◆ colorPerVertex

bool WRL2LINESET::colorPerVertex
private

Definition at line 73 of file vrml2_lineset.h.

Referenced by Read(), and setDefaults().

◆ coord

WRL2NODE* WRL2LINESET::coord
private

Definition at line 71 of file vrml2_lineset.h.

Referenced by AddChildNode(), AddRefNode(), setDefaults(), unlinkChildNode(), and unlinkRefNode().

◆ coordIndex

std::vector< int > WRL2LINESET::coordIndex
private

Definition at line 76 of file vrml2_lineset.h.

Referenced by Read().

◆ 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


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