KiCad PCB EDA Suite
X3D Namespace Reference

Functions

bool ReadTransform (wxXmlNode *aNode, X3DNODE *aParent, X3D_DICT &aDict)
 
bool ReadSwitch (wxXmlNode *aNode, X3DNODE *aParent, X3D_DICT &aDict)
 
bool ReadShape (wxXmlNode *aNode, X3DNODE *aParent, X3D_DICT &aDict)
 
bool ReadAppearance (wxXmlNode *aNode, X3DNODE *aParent, X3D_DICT &aDict)
 
bool ReadIndexedFaceSet (wxXmlNode *aNode, X3DNODE *aParent, X3D_DICT &aDict)
 
bool ReadCoordinates (wxXmlNode *aNode, X3DNODE *aParent, X3D_DICT &aDict)
 
bool ParseSFBool (const wxString &aSource, bool &aResult)
 
bool ParseSFFloat (const wxString &aSource, float &aResult)
 
bool ParseSFVec3 (const wxString &aSource, WRLVEC3F &aResult)
 
bool ParseSFRotation (const wxString &aSource, WRLROTATION &aResult)
 

Function Documentation

◆ ParseSFBool()

bool X3D::ParseSFBool ( const wxString &  aSource,
bool &  aResult 
)

Definition at line 231 of file x3d_ops.cpp.

232 {
233  wxStringTokenizer tokens( aSource );
234  wxString val = tokens.GetNextToken();
235 
236  if( val == "TRUE" || val == "1" )
237  {
238  aResult = true;
239  return true;
240  }
241 
242  if( val == "FALSE" || val == "0" )
243  {
244  aResult = false;
245  return true;
246  }
247 
248  return false;
249 }

Referenced by X3DIFACESET::readFields().

◆ ParseSFFloat()

bool X3D::ParseSFFloat ( const wxString &  aSource,
float &  aResult 
)

Definition at line 252 of file x3d_ops.cpp.

253 {
254  wxStringTokenizer tokens( aSource );
255 
256  double x = 0;
257  bool ret = tokens.GetNextToken().ToCDouble( &x );
258 
259  aResult = x;
260  return ret;
261 }

Referenced by X3DAPP::readFields(), and X3DIFACESET::readFields().

◆ ParseSFRotation()

bool X3D::ParseSFRotation ( const wxString &  aSource,
WRLROTATION aResult 
)

Definition at line 284 of file x3d_ops.cpp.

285 {
286  wxStringTokenizer tokens( aSource );
287 
288  double x = 0;
289  double y = 0;
290  double z = 0;
291  double w = 0;
292 
293  bool ret = tokens.GetNextToken().ToCDouble( &x )
294  && tokens.GetNextToken().ToCDouble( &y )
295  && tokens.GetNextToken().ToCDouble( &z )
296  && tokens.GetNextToken().ToCDouble( &w );
297 
298  aResult.x = x;
299  aResult.y = y;
300  aResult.z = z;
301  aResult.w = w;
302 
303  return ret;
304 }

Referenced by X3DTRANSFORM::readFields().

◆ ParseSFVec3()

bool X3D::ParseSFVec3 ( const wxString &  aSource,
WRLVEC3F aResult 
)

Definition at line 264 of file x3d_ops.cpp.

265 {
266  wxStringTokenizer tokens( aSource );
267 
268  double x = 0;
269  double y = 0;
270  double z = 0;
271 
272  bool ret = tokens.GetNextToken().ToCDouble( &x )
273  && tokens.GetNextToken().ToCDouble( &y )
274  && tokens.GetNextToken().ToCDouble( &z );
275 
276  aResult.x = x;
277  aResult.y = y;
278  aResult.z = z;
279 
280  return ret;
281 }

Referenced by X3DTRANSFORM::readFields(), and X3DAPP::readFields().

◆ ReadAppearance()

bool X3D::ReadAppearance ( wxXmlNode *  aNode,
X3DNODE aParent,
X3D_DICT aDict 
)

Definition at line 117 of file x3d_ops.cpp.

118 {
119  // note: we must have a parent or else we will have a memory leak
120  if( nullptr == aParent || nullptr == aNode )
121  return false;
122 
123  wxXmlAttribute* prop;
124 
125  for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() )
126  {
127  const wxString& pname = prop->GetName();
128 
129  if( pname == "USE" )
130  {
131  X3DNODE* np = aDict.FindName( prop->GetValue() );
132 
133  if( nullptr == np )
134  return false;
135 
136  if( !aParent->AddRefNode( np ) )
137  return false;
138 
139  return true;
140  }
141  }
142 
143  X3DNODE* node = new X3DAPP;
144 
145  if( !node->Read( aNode, aParent, aDict ) )
146  {
147  delete node;
148  return false;
149  }
150 
151  return true;
152 }
X3DNODE * FindName(const wxString &aName)
Definition: x3d_base.cpp:68
The base class of all X3D nodes.
Definition: x3d_base.h:74
virtual bool Read(wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
virtual bool AddRefNode(X3DNODE *aNode)=0

References X3DNODE::AddRefNode(), X3D_DICT::FindName(), and X3DNODE::Read().

Referenced by X3DSHAPE::Read().

◆ ReadCoordinates()

bool X3D::ReadCoordinates ( wxXmlNode *  aNode,
X3DNODE aParent,
X3D_DICT aDict 
)

Definition at line 193 of file x3d_ops.cpp.

194 {
195  // note: we must have a parent or else we will have a memory leak
196  if( nullptr == aParent || nullptr == aNode )
197  return false;
198 
199  wxXmlAttribute* prop;
200 
201  for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() )
202  {
203  const wxString& pname = prop->GetName();
204 
205  if( pname == "USE" )
206  {
207  X3DNODE* np = aDict.FindName( prop->GetValue() );
208 
209  if( nullptr == np )
210  return false;
211 
212  if( !aParent->AddRefNode( np ) )
213  return false;
214 
215  return true;
216  }
217  }
218 
219  X3DNODE* node = new X3DCOORDS;
220 
221  if( !node->Read( aNode, aParent, aDict ) )
222  {
223  delete node;
224  return false;
225  }
226 
227  return true;
228 }
X3DNODE * FindName(const wxString &aName)
Definition: x3d_base.cpp:68
The base class of all X3D nodes.
Definition: x3d_base.h:74
virtual bool Read(wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
virtual bool AddRefNode(X3DNODE *aNode)=0

References X3DNODE::AddRefNode(), X3D_DICT::FindName(), and X3DNODE::Read().

Referenced by X3DIFACESET::Read().

◆ ReadIndexedFaceSet()

bool X3D::ReadIndexedFaceSet ( wxXmlNode *  aNode,
X3DNODE aParent,
X3D_DICT aDict 
)

Definition at line 155 of file x3d_ops.cpp.

156 {
157  // note: we must have a parent or else we will have a memory leak
158  if( nullptr == aParent || nullptr == aNode )
159  return false;
160 
161  wxXmlAttribute* prop;
162 
163  for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() )
164  {
165  const wxString& pname = prop->GetName();
166 
167  if( pname == "USE" )
168  {
169  X3DNODE* np = aDict.FindName( prop->GetValue() );
170 
171  if( nullptr == np )
172  return false;
173 
174  if( !aParent->AddRefNode( np ) )
175  return false;
176 
177  return true;
178  }
179  }
180 
181  X3DNODE* node = new X3DIFACESET;
182 
183  if( !node->Read( aNode, aParent, aDict ) )
184  {
185  delete node;
186  return false;
187  }
188 
189  return true;
190 }
X3DNODE * FindName(const wxString &aName)
Definition: x3d_base.cpp:68
The base class of all X3D nodes.
Definition: x3d_base.h:74
virtual bool Read(wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
virtual bool AddRefNode(X3DNODE *aNode)=0

References X3DNODE::AddRefNode(), X3D_DICT::FindName(), and X3DNODE::Read().

Referenced by X3DSHAPE::Read().

◆ ReadShape()

bool X3D::ReadShape ( wxXmlNode *  aNode,
X3DNODE aParent,
X3D_DICT aDict 
)

Definition at line 79 of file x3d_ops.cpp.

80 {
81  // note: we must have a parent or else we will have a memory leak
82  if( nullptr == aParent || nullptr == aNode )
83  return false;
84 
85  wxXmlAttribute* prop;
86 
87  for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() )
88  {
89  const wxString& pname = prop->GetName();
90 
91  if( pname == "USE" )
92  {
93  X3DNODE* np = aDict.FindName( prop->GetValue() );
94 
95  if( nullptr == np )
96  return false;
97 
98  if( !aParent->AddRefNode( np ) )
99  return false;
100 
101  return true;
102  }
103  }
104 
105  X3DNODE* node = new X3DSHAPE;
106 
107  if( !node->Read( aNode, aParent, aDict ) )
108  {
109  delete node;
110  return false;
111  }
112 
113  return true;
114 }
X3DNODE * FindName(const wxString &aName)
Definition: x3d_base.cpp:68
The base class of all X3D nodes.
Definition: x3d_base.h:74
virtual bool Read(wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
virtual bool AddRefNode(X3DNODE *aNode)=0

References X3DNODE::AddRefNode(), X3D_DICT::FindName(), and X3DNODE::Read().

Referenced by X3DTRANSFORM::Read().

◆ ReadSwitch()

bool X3D::ReadSwitch ( wxXmlNode *  aNode,
X3DNODE aParent,
X3D_DICT aDict 
)

Definition at line 72 of file x3d_ops.cpp.

73 {
74  // XXX - TO BE IMPLEMENTED
75  return false;
76 }

Referenced by X3DPARSER::Load(), and X3DTRANSFORM::Read().

◆ ReadTransform()

bool X3D::ReadTransform ( wxXmlNode *  aNode,
X3DNODE aParent,
X3D_DICT aDict 
)

Definition at line 34 of file x3d_ops.cpp.

35 {
36  // note: we must have a parent or else we will have a memory leak
37  if( nullptr == aParent || nullptr == aNode )
38  return false;
39 
40  wxXmlAttribute* prop;
41 
42  for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() )
43  {
44  const wxString& pname = prop->GetName();
45 
46  if( pname == "USE" )
47  {
48  X3DNODE* np = aDict.FindName( prop->GetValue() );
49 
50  if( nullptr == np )
51  return false;
52 
53  if( !aParent->AddRefNode( np ) )
54  return false;
55 
56  return true;
57  }
58  }
59 
60  X3DNODE* node = new X3DTRANSFORM;
61 
62  if( !node->Read( aNode, aParent, aDict ) )
63  {
64  delete node;
65  return false;
66  }
67 
68  return true;
69 }
X3DNODE * FindName(const wxString &aName)
Definition: x3d_base.cpp:68
The base class of all X3D nodes.
Definition: x3d_base.h:74
virtual bool Read(wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
virtual bool AddRefNode(X3DNODE *aNode)=0

References X3DNODE::AddRefNode(), X3D_DICT::FindName(), and X3DNODE::Read().

Referenced by X3DPARSER::Load(), and X3DTRANSFORM::Read().