KiCad PCB EDA Suite
WRL2MATERIAL Class Reference

#include <vrml2_material.h>

Inheritance diagram for WRL2MATERIAL:
WRL2NODE

Public Member Functions

 WRL2MATERIAL ()
 
 WRL2MATERIAL (WRL2NODE *aParent)
 
virtual ~WRL2MATERIAL ()
 
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 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...
 
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

void setDefaults (void)
 

Private Attributes

WRLVEC3F diffuseColor
 
WRLVEC3F emissiveColor
 
WRLVEC3F specularColor
 
float ambientIntensity
 
float shininess
 
float transparency
 

Detailed Description

Definition at line 38 of file vrml2_material.h.

Constructor & Destructor Documentation

◆ WRL2MATERIAL() [1/2]

WRL2MATERIAL::WRL2MATERIAL ( )

Definition at line 35 of file vrml2_material.cpp.

35  : WRL2NODE()
36 {
37  setDefaults();
39 }
void setDefaults(void)
WRL2NODES m_Type
Definition: vrml2_node.h:170

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

◆ WRL2MATERIAL() [2/2]

WRL2MATERIAL::WRL2MATERIAL ( WRL2NODE aParent)

Definition at line 42 of file vrml2_material.cpp.

42  : WRL2NODE()
43 {
44  setDefaults();
46  m_Parent = aParent;
47 
48  if( nullptr != m_Parent )
49  m_Parent->AddChildNode( this );
50 }
void setDefaults(void)
WRL2NODES m_Type
Definition: vrml2_node.h:170
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, setDefaults(), and WRL2_MATERIAL.

◆ ~WRL2MATERIAL()

WRL2MATERIAL::~WRL2MATERIAL ( )
virtual

Definition at line 53 of file vrml2_material.cpp.

54 {
55  wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Destroying Material node." ) );
56 }
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition: vrml.cpp:63

References traceVrmlPlugin.

Member Function Documentation

◆ AddChildNode()

bool WRL2MATERIAL::AddChildNode ( WRL2NODE aNode)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 96 of file vrml2_material.cpp.

97 {
98  // this node may not own or reference any other node
99  wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
100 }

◆ 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 WRL2MATERIAL::AddRefNode ( WRL2NODE aNode)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 89 of file vrml2_material.cpp.

90 {
91  // this node may not own or reference any other node
92  wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
93 }

◆ 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(), WRL2LINESET::AddChildNode(), WRL2POINTSET::AddChildNode(), WRL2FACESET::AddChildNode(), WRL2APPEARANCE::AddRefNode(), WRL2SHAPE::AddRefNode(), WRL2LINESET::AddRefNode(), WRL2POINTSET::AddRefNode(), and WRL2FACESET::AddRefNode().

◆ GetParent()

WRL2NODE * WRL2NODE::GetParent ( void  ) const
inherited

◆ isDangling()

bool WRL2MATERIAL::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 78 of file vrml2_material.cpp.

79 {
80  // this node is dangling unless it has a parent of type WRL2NODES::WRL2_APPEARANCE
81 
83  return true;
84 
85  return false;
86 }
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_APPEARANCE.

◆ Read()

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

Implements WRL2NODE.

Definition at line 103 of file vrml2_material.cpp.

104 {
105  wxCHECK_MSG( aTopNode, false, wxT( "Invalid top node." ) );
106 
107  char tok = proc.Peek();
108 
109  if( proc.eof() )
110  {
111  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
112  " * [INFO] bad file format; unexpected eof %s." ),
113  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
114 
115  return false;
116  }
117 
118  if( '{' != tok )
119  {
120  wxLogTrace( traceVrmlPlugin,
121  wxT( "%s:%s:%d\n"
122  " * [INFO] bad file format; expecting '{' but got '%s' %s." ),
123  __FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
124 
125  return false;
126  }
127 
128  proc.Pop();
129  std::string glob;
130 
131  while( true )
132  {
133  if( proc.Peek() == '}' )
134  {
135  proc.Pop();
136  break;
137  }
138 
139  if( !proc.ReadName( glob ) )
140  {
141  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
142  "%s" ),
143  __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
144 
145  return false;
146  }
147 
148  // expecting one of:
149  // ambientIntensity
150  // diffuseColor
151  // emissiveColor
152  // shininess
153  // specularColor
154  // transparency
155 
156  if( !glob.compare( "specularColor" ) )
157  {
158  if( !proc.ReadSFVec3f( specularColor ) )
159  {
160  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
161  " * [INFO] invalid specularColor set %s\n"
162  " * [INFO] file: '%s'\n"
163  "%s" ),
164  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
165  proc.GetFileName(), proc.GetError() );
166 
167  return false;
168  }
169  }
170  else if( !glob.compare( "diffuseColor" ) )
171  {
172  if( !proc.ReadSFVec3f( diffuseColor ) )
173  {
174  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
175  " * [INFO] invalid diffuseColor set %s\n"
176  " * [INFO] file: '%s'\n"
177  "%s" ),
178  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
179  proc.GetFileName(), proc.GetError() );
180 
181  return false;
182  }
183  }
184  else if( !glob.compare( "emissiveColor" ) )
185  {
186  if( !proc.ReadSFVec3f( emissiveColor ) )
187  {
188  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
189  " * [INFO] invalid emissiveColor set %s\n"
190  " * [INFO] file: '%s'\n"
191  "%s" ),
192  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
193  proc.GetFileName(), proc.GetError() );
194 
195  return false;
196  }
197  }
198  else if( !glob.compare( "shininess" ) )
199  {
200  if( !proc.ReadSFFloat( shininess ) )
201  {
202  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
203  " * [INFO] invalid shininess set %s\n"
204  " * [INFO] file: '%s'\n"
205  "%s" ),
206  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
207  proc.GetFileName(), proc.GetError() );
208 
209  return false;
210  }
211  }
212  else if( !glob.compare( "transparency" ) )
213  {
214  if( !proc.ReadSFFloat( transparency ) )
215  {
216  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
217  " * [INFO] invalid transparency set %s\n"
218  " * [INFO] file: '%s'\n"
219  "%s" ),
220  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
221  proc.GetFileName(), proc.GetError() );
222 
223  return false;
224  }
225  }
226  else if( !glob.compare( "ambientIntensity" ) )
227  {
228  if( !proc.ReadSFFloat( ambientIntensity ) )
229  {
230  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
231  " * [INFO] invalid ambientIntensity set %s\n"
232  " * [INFO] file: '%s'\n"
233  "%s" ),
234  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
235  proc.GetFileName(), proc.GetError() );
236 
237  return false;
238  }
239  }
240  else
241  {
242  wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
243  " * [INFO] invalid Material %s.\n"
244  " * [INFO] file: '%s'\n" ),
245  __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
246  proc.GetFileName() );
247 
248  return false;
249  }
250  } // while( true ) -- reading contents of Material{}
251 
252  return true;
253 }
void Pop(void)
Definition: wrlproc.cpp:2035
bool ReadSFVec3f(WRLVEC3F &aSFVec3f)
Definition: wrlproc.cpp:1082
float transparency
WRLVEC3F emissiveColor
WRLVEC3F diffuseColor
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982
bool ReadSFFloat(float &aSFFloat)
Definition: wrlproc.cpp:806
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
WRLVEC3F specularColor
float ambientIntensity
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 ambientIntensity, diffuseColor, emissiveColor, WRLPROC::eof(), WRLPROC::GetError(), WRLPROC::GetFileName(), WRLPROC::GetFilePosition(), WRLPROC::Peek(), WRLPROC::Pop(), WRLPROC::ReadName(), WRLPROC::ReadSFFloat(), WRLPROC::ReadSFVec3f(), shininess, specularColor, traceVrmlPlugin, and transparency.

Referenced by WRL2BASE::readMaterial().

◆ setDefaults()

void WRL2MATERIAL::setDefaults ( void  )
private

Definition at line 59 of file vrml2_material.cpp.

60 {
61  // default material values as per VRML2 spec
62  diffuseColor.x = 0.8f;
63  diffuseColor.y = 0.8f;
64  diffuseColor.z = 0.8f;
65 
66  emissiveColor.x = 0.0f;
67  emissiveColor.y = 0.0f;
68  emissiveColor.z = 0.0f;
69 
71 
72  ambientIntensity = 0.2f;
73  shininess = 0.2f;
74  transparency = 0.0f;
75 }
float transparency
WRLVEC3F emissiveColor
WRLVEC3F diffuseColor
WRLVEC3F specularColor
float ambientIntensity

References ambientIntensity, diffuseColor, emissiveColor, shininess, specularColor, and transparency.

Referenced by WRL2MATERIAL().

◆ 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(), WRL2SWITCH::AddRefNode(), and WRL2TRANSFORM::AddRefNode().

◆ TranslateToSG()

SGNODE * WRL2MATERIAL::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 256 of file vrml2_material.cpp.

257 {
258  S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
259 
260  wxCHECK_MSG( aParent && ( ptype == S3D::SGTYPE_SHAPE ), nullptr,
261  wxString::Format( wxT( "IndexedFaceSet does not have a Shape parent (parent "
262  "ID: %d)." ), ptype ) );
263 
264  wxLogTrace( traceVrmlPlugin,
265  wxT( " * [INFO] Translating IndexedFaceSet with %zu children, %zu references, and"
266  "%zu back pointers." ),
267  m_Children.size(), m_Refs.size(), m_BackPointers.size() );
268 
269  if( m_sgNode )
270  {
271  if( nullptr != aParent )
272  {
273  if( nullptr == S3D::GetSGNodeParent( m_sgNode )
274  && !S3D::AddSGNodeChild( aParent, m_sgNode ) )
275  {
276  return nullptr;
277  }
278  else if( aParent != S3D::GetSGNodeParent( m_sgNode )
279  && !S3D::AddSGNodeRef( aParent, m_sgNode ) )
280  {
281  return nullptr;
282  }
283  }
284 
285  return m_sgNode;
286  }
287 
288  IFSG_APPEARANCE matNode( aParent );
289  matNode.SetEmissive( emissiveColor.x, emissiveColor.y, emissiveColor.z );
290  matNode.SetSpecular( specularColor.x, specularColor.y, specularColor.z );
291  matNode.SetDiffuse( diffuseColor.x, diffuseColor.y, diffuseColor.z );
292  float ambr = ambientIntensity * diffuseColor.x;
293  float ambg = ambientIntensity * diffuseColor.y;
294  float ambb = ambientIntensity * diffuseColor.z;
295  matNode.SetAmbient( ambr, ambg, ambb );
296  matNode.SetShininess( shininess );
297  matNode.SetTransparency( transparency );
298  m_sgNode = matNode.GetRawPtr();
299 
300  return m_sgNode;
301 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
float transparency
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:494
WRLVEC3F emissiveColor
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:503
WRLVEC3F diffuseColor
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:512
SGNODE * m_sgNode
Definition: vrml2_node.h:178
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
SGTYPES
Definition: sg_types.h:34
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
WRLVEC3F specularColor
SGLIB_API S3D::SGTYPES GetSGNodeType(SGNODE *aNode)
Definition: ifsg_api.cpp:485
float ambientIntensity

References S3D::AddSGNodeChild(), S3D::AddSGNodeRef(), ambientIntensity, diffuseColor, emissiveColor, Format(), IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), S3D::GetSGNodeType(), WRL2NODE::m_BackPointers, WRL2NODE::m_Children, WRL2NODE::m_Refs, WRL2NODE::m_sgNode, IFSG_APPEARANCE::SetAmbient(), IFSG_APPEARANCE::SetDiffuse(), IFSG_APPEARANCE::SetEmissive(), IFSG_APPEARANCE::SetShininess(), IFSG_APPEARANCE::SetSpecular(), IFSG_APPEARANCE::SetTransparency(), S3D::SGTYPE_SHAPE, shininess, specularColor, traceVrmlPlugin, and transparency.

◆ 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 WRL2FACESET, WRL2LINESET, WRL2POINTSET, WRL2APPEARANCE, 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 }
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174

References WRL2NODE::m_Children.

Referenced by WRL2NODE::SetParent(), WRL2APPEARANCE::unlinkChildNode(), WRL2SHAPE::unlinkChildNode(), WRL2LINESET::unlinkChildNode(), WRL2FACESET::unlinkChildNode(), WRL2POINTSET::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 WRL2FACESET, WRL2LINESET, WRL2POINTSET, WRL2APPEARANCE, 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 }
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175

References WRL2NODE::m_Refs.

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

Member Data Documentation

◆ ambientIntensity

float WRL2MATERIAL::ambientIntensity
private

Definition at line 58 of file vrml2_material.h.

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

◆ diffuseColor

WRLVEC3F WRL2MATERIAL::diffuseColor
private

Definition at line 55 of file vrml2_material.h.

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

◆ emissiveColor

WRLVEC3F WRL2MATERIAL::emissiveColor
private

Definition at line 56 of file vrml2_material.h.

Referenced by Read(), setDefaults(), 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

◆ shininess

float WRL2MATERIAL::shininess
private

Definition at line 59 of file vrml2_material.h.

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

◆ specularColor

WRLVEC3F WRL2MATERIAL::specularColor
private

Definition at line 57 of file vrml2_material.h.

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

◆ transparency

float WRL2MATERIAL::transparency
private

Definition at line 60 of file vrml2_material.h.

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


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