KiCad PCB EDA Suite
WRL2BASE Class Reference

The top node of a VRML2 model. More...

#include <vrml2_base.h>

Inheritance diagram for WRL2BASE:
WRL2NODE

Public Member Functions

 WRL2BASE ()
 
virtual ~WRL2BASE ()
 
void SetEnableInline (bool enable)
 
bool GetEnableInline (void)
 
SGNODEGetInlineData (const std::string &aName)
 
bool Read (WRLPROC &proc)
 
bool ReadNode (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
virtual std::string GetName (void) override
 
virtual bool SetName (const std::string &aName) override
 
bool Read (WRLPROC &proc, WRL2BASE *aTopNode) override
 
bool SetParent (WRL2NODE *aParent, bool doUnlink=true) override
 Set the parent WRL2NODE of this object. More...
 
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
 
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)
 
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 implementUse (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool implementDef (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readTransform (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readShape (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readAppearance (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readMaterial (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readFaceSet (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readLineSet (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readPointSet (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readCoords (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readNorms (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readColor (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readBox (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readSwitch (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 
bool readInline (WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
 

Private Attributes

bool m_useInline
 
std::string m_dir
 
std::map< std::string, SGNODE * > m_inlineModels
 

Detailed Description

The top node of a VRML2 model.

Definition at line 59 of file vrml2_base.h.

Constructor & Destructor Documentation

◆ WRL2BASE()

WRL2BASE::WRL2BASE ( )

Definition at line 53 of file vrml2_base.cpp.

53 : WRL2NODE()
54{
55 m_useInline = false;
57}
bool m_useInline
Definition: vrml2_base.h:106
WRL2NODES m_Type
Definition: vrml2_node.h:170

References WRL2NODE::m_Type, m_useInline, and WRL2_BASE.

◆ ~WRL2BASE()

WRL2BASE::~WRL2BASE ( )
virtual

Definition at line 60 of file vrml2_base.cpp.

61{
62 std::map< std::string, SGNODE* >::iterator iS = m_inlineModels.begin();
63 std::map< std::string, SGNODE* >::iterator eS = m_inlineModels.end();
64
65 while( iS != eS )
66 {
67 SGNODE* np = iS->second;
68
69 // destroy any orphaned Inline{} node data
70 if( np && nullptr == S3D::GetSGNodeParent( np ) )
71 S3D::DestroyNode( np );
72
73 ++iS;
74 }
75
76 m_inlineModels.clear();
77}
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
std::map< std::string, SGNODE * > m_inlineModels
Definition: vrml2_base.h:108
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:494
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.
Definition: ifsg_api.cpp:149

References S3D::DestroyNode(), S3D::GetSGNodeParent(), and m_inlineModels.

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
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
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(), WRL2SWITCH::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::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}
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
WRL2NODE * m_Parent
Definition: vrml2_node.h:169

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

Referenced by WRL2NODE::AddRefNode().

◆ AddRefNode()

bool WRL2NODE::AddRefNode ( WRL2NODE aNode)
virtualinherited

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
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175

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

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

◆ 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}
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::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 implementUse().

◆ GetEnableInline()

bool WRL2BASE::GetEnableInline ( void  )

Definition at line 92 of file vrml2_base.cpp.

93{
94 return m_useInline;
95}

References m_useInline.

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

◆ GetInlineData()

SGNODE * WRL2BASE::GetInlineData ( const std::string &  aName)

Definition at line 98 of file vrml2_base.cpp.

99{
100 if( aName.empty() )
101 return nullptr;
102
103 std::map< std::string, SGNODE* >::iterator dp = m_inlineModels.find( aName );
104
105 if( dp != m_inlineModels.end() )
106 return dp->second;
107
108 wxString tname;
109
110 if( aName.compare( 0, 7, "file://" ) == 0 )
111 {
112 if( aName.length() <= 7 )
113 return nullptr;
114
115 tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() );
116 }
117 else
118 {
119 tname = wxString::FromUTF8Unchecked( aName.c_str() );
120 }
121
122 wxFileName fn;
123 fn.Assign( tname );
124
125 if( fn.IsRelative() && !m_dir.empty() )
126 {
127 wxString fname = wxString::FromUTF8Unchecked( m_dir.c_str() );
128 fname.append( tname );
129 fn.Assign( fname );
130 }
131
132 if( !fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS ) )
133 {
134 m_inlineModels.emplace( aName, nullptr );
135 return nullptr;
136 }
137
138 SCENEGRAPH* sp = LoadVRML( fn.GetFullPath(), false );
139
140 if( nullptr == sp )
141 {
142 m_inlineModels.emplace( aName, nullptr );
143 return nullptr;
144 }
145
146 m_inlineModels.emplace( aName, (SGNODE*) sp );
147
148 return (SGNODE*)sp;
149}
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:45
std::string m_dir
Definition: vrml2_base.h:107
SCENEGRAPH * LoadVRML(const wxString &aFileName, bool useInline)
Definition: vrml.cpp:170
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:38

References FN_NORMALIZE_FLAGS, LoadVRML(), m_dir, and m_inlineModels.

Referenced by WRL2INLINE::TranslateToSG().

◆ GetName()

std::string WRL2BASE::GetName ( void  )
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 152 of file vrml2_base.cpp.

153{
154 wxCHECK_MSG( false, std::string( "" ), wxT( "Attempt to extract name from base node." ) );
155}

◆ 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 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

◆ implementDef()

bool WRL2BASE::implementDef ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 236 of file vrml2_base.cpp.

237{
238 if( nullptr != aNode )
239 *aNode = nullptr;
240
241 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
242
243 std::string glob;
244 WRL2NODE* lnode = nullptr;
245
246 if( !proc.ReadName( glob ) )
247 {
248 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
249 "%s" ),
250 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
251
252 return false;
253 }
254
255 if( ReadNode( proc, aParent, &lnode ) )
256 {
257 if( nullptr != aNode )
258 *aNode = lnode;
259
260 if( lnode && !lnode->SetName( glob ) )
261 {
262 wxLogTrace( traceVrmlPlugin,
263 wxT( "%s:%s:%d\n"
264 " * [INFO] bad formatting (invalid name) %s." ),
265 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
266
267 return false;
268 }
269
270 return true;
271 }
272
273 return false;
274}
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:277
virtual bool SetName(const std::string &aName)
Definition: vrml2_node.cpp:222
std::string GetError(void)
Definition: wrlproc.cpp:1960
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982

References WRLPROC::GetError(), WRLPROC::GetFilePosition(), WRLPROC::ReadName(), ReadNode(), WRL2NODE::SetName(), and traceVrmlPlugin.

Referenced by ReadNode().

◆ implementUse()

bool WRL2BASE::implementUse ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 188 of file vrml2_base.cpp.

189{
190 if( nullptr != aNode )
191 *aNode = nullptr;
192
193 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
194
195 std::string glob;
196
197 if( !proc.ReadName( glob ) )
198 {
199 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
200 "%s" ),
201 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
202
203 return false;
204 }
205
206 WRL2NODE* ref = aParent->FindNode( glob, nullptr );
207
208 // return 'true' - the file may be defective but it may still be somewhat OK
209 if( nullptr == ref )
210 {
211 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
212 " * [INFO] node '%s' not found." ),
213 __FILE__, __FUNCTION__, __LINE__, glob );
214
215 return true;
216 }
217
218 if( !aParent->AddRefNode( ref ) )
219 {
220 wxLogTrace( traceVrmlPlugin,
221 wxT( "%s:%s:%d\n"
222 " * [INFO] failed to add node '%s' (%d) to parent of type %d" ),
223 __FILE__, __FUNCTION__, __LINE__, glob, ref->GetNodeType(),
224 aParent->GetNodeType() );
225
226 return false;
227 }
228
229 if( nullptr != aNode )
230 *aNode = ref;
231
232 return true;
233}
virtual bool AddRefNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:383

References WRL2NODE::AddRefNode(), WRL2NODE::FindNode(), WRLPROC::GetError(), WRL2NODE::GetNodeType(), WRLPROC::ReadName(), and traceVrmlPlugin.

Referenced by ReadNode().

◆ isDangling()

bool WRL2BASE::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 181 of file vrml2_base.cpp.

182{
183 // the base node is never dangling
184 return false;
185}

◆ Read() [1/2]

bool WRL2BASE::Read ( WRLPROC proc)

Definition at line 164 of file vrml2_base.cpp.

165{
166 wxCHECK_MSG( proc.GetVRMLType() == WRLVERSION::VRML_V2, false,
167 wxT( "No open file or file is not a VRML2 file." ) );
168
169 WRL2NODE* node = nullptr;
170 m_dir = proc.GetParentDir();
171
172 while( ReadNode( proc, this, &node ) && !proc.eof() );
173
174 if( proc.eof() )
175 return true;
176
177 return false;
178}
WRLVERSION GetVRMLType(void)
Definition: wrlproc.cpp:230
const char * GetParentDir(void)
Definition: wrlproc.cpp:236
bool eof(void)
Definition: wrlproc.cpp:1954

References WRLPROC::eof(), WRLPROC::GetParentDir(), WRLPROC::GetVRMLType(), m_dir, ReadNode(), and VRML_V2.

Referenced by LoadVRML().

◆ Read() [2/2]

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

Implements WRL2NODE.

Definition at line 633 of file vrml2_base.cpp.

634{
635 wxCHECK_MSG( false, false, wxT( "This method must never be invoked on a WRL2BASE object." ) );
636}

◆ readAppearance()

bool WRL2BASE::readAppearance ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 679 of file vrml2_base.cpp.

680{
681 if( nullptr != aNode )
682 *aNode = nullptr;
683
684 WRL2APPEARANCE* np = new WRL2APPEARANCE( aParent );
685
686 if( !np->Read( proc, this ) )
687 {
688 delete np;
689 return false;
690 }
691
692 if( nullptr != aNode )
693 *aNode = (WRL2NODE*) np;
694
695 return true;
696}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2APPEARANCE::Read().

Referenced by ReadNode().

◆ readBox()

bool WRL2BASE::readBox ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 839 of file vrml2_base.cpp.

840{
841 if( nullptr != aNode )
842 *aNode = nullptr;
843
844 WRL2BOX* np = new WRL2BOX( aParent );
845
846 if( !np->Read( proc, this ) )
847 {
848 delete np;
849 return false;
850 }
851
852 if( nullptr != aNode )
853 *aNode = (WRL2NODE*) np;
854
855 return true;
856}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition: vrml2_box.cpp:74

References WRL2BOX::Read().

Referenced by ReadNode().

◆ readColor()

bool WRL2BASE::readColor ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 819 of file vrml2_base.cpp.

820{
821 if( nullptr != aNode )
822 *aNode = nullptr;
823
824 WRL2COLOR* np = new WRL2COLOR( aParent );
825
826 if( !np->Read( proc, this ) )
827 {
828 delete np;
829 return false;
830 }
831
832 if( nullptr != aNode )
833 *aNode = (WRL2NODE*) np;
834
835 return true;
836}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition: vrml2_color.cpp:80

References WRL2COLOR::Read().

Referenced by ReadNode().

◆ readCoords()

bool WRL2BASE::readCoords ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 779 of file vrml2_base.cpp.

780{
781 if( nullptr != aNode )
782 *aNode = nullptr;
783
784 WRL2COORDS* np = new WRL2COORDS( aParent );
785
786 if( !np->Read( proc, this ) )
787 {
788 delete np;
789 return false;
790 }
791
792 if( nullptr != aNode )
793 *aNode = (WRL2NODE*) np;
794
795 return true;
796}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2COORDS::Read().

Referenced by ReadNode().

◆ readFaceSet()

bool WRL2BASE::readFaceSet ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 719 of file vrml2_base.cpp.

720{
721 if( nullptr != aNode )
722 *aNode = nullptr;
723
724 WRL2FACESET* np = new WRL2FACESET( aParent );
725
726 if( !np->Read( proc, this ) )
727 {
728 delete np;
729 return false;
730 }
731
732 if( nullptr != aNode )
733 *aNode = (WRL2NODE*) np;
734
735 return true;
736}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2FACESET::Read().

Referenced by ReadNode().

◆ readInline()

bool WRL2BASE::readInline ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 879 of file vrml2_base.cpp.

880{
881 if( nullptr != aNode )
882 *aNode = nullptr;
883
884 if( !m_useInline )
885 {
886 if( !proc.DiscardNode() )
887 {
888 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard in line node %s." ),
889 proc.GetFilePosition() );
890
891 return false;
892 }
893
894 return true;
895 }
896
897 WRL2INLINE* np = new WRL2INLINE( aParent );
898
899 if( !np->Read( proc, this ) )
900 {
901 delete np;
902 return false;
903 }
904
905 if( nullptr != aNode )
906 *aNode = (WRL2NODE*) np;
907
908 return true;
909}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool DiscardNode(void)
Definition: wrlproc.cpp:368

References WRLPROC::DiscardNode(), WRLPROC::GetFilePosition(), m_useInline, WRL2INLINE::Read(), and traceVrmlPlugin.

Referenced by ReadNode().

◆ readLineSet()

bool WRL2BASE::readLineSet ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 739 of file vrml2_base.cpp.

740{
741 if( nullptr != aNode )
742 *aNode = nullptr;
743
744 WRL2LINESET* np = new WRL2LINESET( aParent );
745
746 if( !np->Read( proc, this ) )
747 {
748 delete np;
749 return false;
750 }
751
752 if( nullptr != aNode )
753 *aNode = (WRL2NODE*) np;
754
755 return true;
756}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2LINESET::Read().

Referenced by ReadNode().

◆ readMaterial()

bool WRL2BASE::readMaterial ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 699 of file vrml2_base.cpp.

700{
701 if( nullptr != aNode )
702 *aNode = nullptr;
703
704 WRL2MATERIAL* np = new WRL2MATERIAL( aParent );
705
706 if( !np->Read( proc, this ) )
707 {
708 delete np;
709 return false;
710 }
711
712 if( nullptr != aNode )
713 *aNode = (WRL2NODE*) np;
714
715 return true;
716}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2MATERIAL::Read().

Referenced by ReadNode().

◆ ReadNode()

bool WRL2BASE::ReadNode ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)

Definition at line 277 of file vrml2_base.cpp.

278{
279 // This function reads a node and stores a pointer to it in aNode.
280 // A value 'true' is returned if a node is successfully read or,
281 // if the node is not supported, successfully discarded. Callers
282 // must always check the value of aNode when the function returns
283 // 'true' since it will be NULL if the node type is not supported.
284
285 if( nullptr != aNode )
286 *aNode = nullptr;
287
288 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
289
290 std::string glob;
291 WRL2NODES ntype;
292
293 if( !proc.ReadName( glob ) )
294 {
295 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
296 "%s" ),
297 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
298
299 return false;
300 }
301
302 // Process node name:
303 // the names encountered at this point should be one of the
304 // built-in node names or one of:
305 // DEF, USE
306 // PROTO, EXTERNPROTO
307 // ROUTE
308 // any PROTO or EXTERNPROTO defined name
309 // since we do not support PROTO or EXTERNPROTO, any unmatched names are
310 // assumed to be defined via PROTO/EXTERNPROTO and deleted according to
311 // a typical pattern.
312
313 if( !glob.compare( "USE" ) )
314 {
315 if( !implementUse( proc, aParent, aNode ) )
316 {
317 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
318 "%s" ),
319 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
320
321 return false;
322 }
323
324 return true;
325 }
326
327 if( !glob.compare( "DEF" ) )
328 {
329 if( !implementDef( proc, aParent, aNode ) )
330 {
331 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
332 "%s" ),
333 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
334
335 return false;
336 }
337
338 return true;
339 }
340
341 // pattern to skip: PROTO name list
342 if( !glob.compare( "PROTO" ) )
343 {
344 if( !proc.ReadName( glob ) || !proc.DiscardList() )
345 {
346 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
347 "%s" ),
348 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
349
350 return false;
351 }
352
353 return true;
354 }
355
356 // pattern to skip: EXTERNPROTO name1 name2 list
357 if( !glob.compare( "EXTERNPROTO" ) )
358 {
359 if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() )
360 {
361 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
362 "%s" ),
363 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
364
365 return false;
366 }
367
368 return true;
369 }
370
371 // pattern to skip: ROUTE glob1 glob2 glob3
372 if( !glob.compare( "ROUTE" ) )
373 {
374 if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) )
375 {
376 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
377 "%s" ),
378 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
379
380 return false;
381 }
382
383 return true;
384 }
385
386 ntype = getNodeTypeID( glob );
387
388 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Processing node '%s' ID: %d" ), glob, ntype );
389
390 switch( ntype )
391 {
392 //
393 // items to be implemented:
394 //
396
397 if( !readAppearance( proc, aParent, aNode ) )
398 return false;
399
400 break;
401
403
404 if( !readBox( proc, aParent, aNode ) )
405 return false;
406
407 break;
408
410
411 if( !readColor( proc, aParent, aNode ) )
412 return false;
413
414 break;
415
417 // XXX - IMPLEMENT
418 if( !proc.DiscardNode() )
419 {
420 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
421 glob, proc.GetFilePosition() );
422
423 return false;
424 }
425 else
426 {
427 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
428 glob, proc.GetFilePosition() );
429 }
430
431 break;
432
434
435 if( !readCoords( proc, aParent, aNode ) )
436 return false;
437
438 break;
439
441 // XXX - IMPLEMENT
442 if( !proc.DiscardNode() )
443 {
444 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
445 glob, proc.GetFilePosition() );
446
447 return false;
448 }
449 else
450 {
451 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
452 glob, proc.GetFilePosition() );
453 }
454
455 break;
456
458 // XXX - IMPLEMENT
459 if( !proc.DiscardNode() )
460 {
461 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
462 glob, proc.GetFilePosition() );
463
464 return false;
465 }
466 else
467 {
468 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
469 glob, proc.GetFilePosition() );
470 }
471
472 break;
473
475 // XXX - IMPLEMENT
476 if( !proc.DiscardNode() )
477 {
478 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
479 glob, proc.GetFilePosition() );
480
481 return false;
482 }
483 else
484 {
485 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
486 glob, proc.GetFilePosition() );
487 }
488
489 break;
490
492
493 if( !readFaceSet( proc, aParent, aNode ) )
494 return false;
495
496 break;
497
499
500 if( !readLineSet( proc, aParent, aNode ) )
501 return false;
502
503 break;
504
506
507 if( !readPointSet( proc, aParent, aNode ) )
508 return false;
509
510 break;
511
513
514 if( !readMaterial( proc, aParent, aNode ) )
515 return false;
516
517 break;
518
520
521 if( !readNorms( proc, aParent, aNode ) )
522 return false;
523
524 break;
525
527
528 if( !readShape( proc, aParent, aNode ) )
529 return false;
530
531 break;
532
534 // XXX - IMPLEMENT
535 if( !proc.DiscardNode() )
536 {
537 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
538 glob, proc.GetFilePosition() );
539
540 return false;
541 }
542 else
543 {
544 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
545 glob, proc.GetFilePosition() );
546 }
547
548 break;
549
551
552 if( !readSwitch( proc, aParent, aNode ) )
553 return false;
554
555 break;
556
559
560 if( !readTransform( proc, aParent, aNode ) )
561 return false;
562
563 break;
564
566
567 if( !readInline( proc, aParent, aNode ) )
568 return false;
569
570 break;
571
572 //
573 // items not implemented or for optional future implementation:
574 //
611 default:
612
613 if( !proc.DiscardNode() )
614 {
615 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
616 glob, proc.GetFilePosition() );
617
618 return false;
619 }
620 else
621 {
622 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
623 glob, proc.GetFilePosition() );
624 }
625
626 break;
627 }
628
629 return true;
630}
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:699
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:639
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:739
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:659
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:236
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:759
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:879
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:188
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:819
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:839
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:679
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:799
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:859
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:779
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:719
WRL2NODES getNodeTypeID(const std::string &aNodeName)
Definition: vrml2_node.cpp:288
bool DiscardList(void)
Definition: wrlproc.cpp:491
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:245
WRL2NODES
Definition: wrltypes.h:125
@ 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 WRLPROC::DiscardList(), WRLPROC::DiscardNode(), WRLPROC::GetError(), WRLPROC::GetFilePosition(), WRL2NODE::getNodeTypeID(), implementDef(), implementUse(), readAppearance(), readBox(), readColor(), readCoords(), readFaceSet(), WRLPROC::ReadGlob(), readInline(), readLineSet(), readMaterial(), WRLPROC::ReadName(), readNorms(), readPointSet(), readShape(), readSwitch(), readTransform(), traceVrmlPlugin, 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_EXTRUSION, WRL2_FOG, WRL2_FONTSTYLE, WRL2_GROUP, WRL2_IMAGETEXTURE, WRL2_INDEXEDFACESET, WRL2_INDEXEDLINESET, WRL2_INLINE, WRL2_INVALID, 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.

Referenced by implementDef(), Read(), WRL2APPEARANCE::Read(), WRL2FACESET::Read(), WRL2LINESET::Read(), WRL2POINTSET::Read(), WRL2SHAPE::Read(), WRL2SWITCH::readChildren(), and WRL2TRANSFORM::readChildren().

◆ readNorms()

bool WRL2BASE::readNorms ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 799 of file vrml2_base.cpp.

800{
801 if( nullptr != aNode )
802 *aNode = nullptr;
803
804 WRL2NORMS* np = new WRL2NORMS( aParent );
805
806 if( !np->Read( proc, this ) )
807 {
808 delete np;
809 return false;
810 }
811
812 if( nullptr != aNode )
813 *aNode = (WRL2NODE*) np;
814
815 return true;
816}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition: vrml2_norms.cpp:81

References WRL2NORMS::Read().

Referenced by ReadNode().

◆ readPointSet()

bool WRL2BASE::readPointSet ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 759 of file vrml2_base.cpp.

760{
761 if( nullptr != aNode )
762 *aNode = nullptr;
763
764 WRL2POINTSET* np = new WRL2POINTSET( aParent );
765
766 if( !np->Read( proc, this ) )
767 {
768 delete np;
769 return false;
770 }
771
772 if( nullptr != aNode )
773 *aNode = (WRL2NODE*) np;
774
775 return true;
776}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2POINTSET::Read().

Referenced by ReadNode().

◆ readShape()

bool WRL2BASE::readShape ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 659 of file vrml2_base.cpp.

660{
661 if( nullptr != aNode )
662 *aNode = nullptr;
663
664 WRL2SHAPE* np = new WRL2SHAPE( aParent );
665
666 if( !np->Read( proc, this ) )
667 {
668 delete np;
669 return false;
670 }
671
672 if( nullptr != aNode )
673 *aNode = (WRL2NODE*) np;
674
675 return true;
676}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2SHAPE::Read().

Referenced by ReadNode().

◆ readSwitch()

bool WRL2BASE::readSwitch ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 859 of file vrml2_base.cpp.

860{
861 if( nullptr != aNode )
862 *aNode = nullptr;
863
864 WRL2SWITCH* np = new WRL2SWITCH( aParent );
865
866 if( !np->Read( proc, this ) )
867 {
868 delete np;
869 return false;
870 }
871
872 if( nullptr != aNode )
873 *aNode = (WRL2NODE*) np;
874
875 return true;
876}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2SWITCH::Read().

Referenced by ReadNode().

◆ readTransform()

bool WRL2BASE::readTransform ( WRLPROC proc,
WRL2NODE aParent,
WRL2NODE **  aNode 
)
private

Definition at line 639 of file vrml2_base.cpp.

640{
641 if( nullptr != aNode )
642 *aNode = nullptr;
643
644 WRL2TRANSFORM* np = new WRL2TRANSFORM( aParent );
645
646 if( !np->Read( proc, this ) )
647 {
648 delete np;
649 return false;
650 }
651
652 if( nullptr != aNode )
653 *aNode = (WRL2NODE*) np;
654
655 return true;
656}
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override

References WRL2TRANSFORM::Read().

Referenced by ReadNode().

◆ SetEnableInline()

void WRL2BASE::SetEnableInline ( bool  enable)

Definition at line 86 of file vrml2_base.cpp.

87{
88 m_useInline = enable;
89}

References m_useInline.

Referenced by LoadVRML().

◆ SetName()

bool WRL2BASE::SetName ( const std::string &  aName)
overridevirtual

Reimplemented from WRL2NODE.

Definition at line 158 of file vrml2_base.cpp.

159{
160 wxCHECK_MSG( false, false, wxT( "Attempt to set name of base node." ) );
161}

◆ SetParent()

bool WRL2BASE::SetParent ( WRL2NODE aParent,
bool  doUnlink = true 
)
overridevirtual

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

Definition at line 80 of file vrml2_base.cpp.

81{
82 wxCHECK_MSG( false, false, wxT( "Attempt to set parent on WRL2BASE node." ) );
83}

◆ TranslateToSG()

SGNODE * WRL2BASE::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 912 of file vrml2_base.cpp.

913{
914 if( m_Children.empty() )
915 return nullptr;
916
917 if( m_sgNode )
918 {
919 if( nullptr != aParent )
920 {
921 if( nullptr == S3D::GetSGNodeParent( m_sgNode )
922 && !S3D::AddSGNodeChild( aParent, m_sgNode ) )
923 {
924 return nullptr;
925 }
926 else if( aParent != S3D::GetSGNodeParent( m_sgNode )
927 && !S3D::AddSGNodeRef( aParent, m_sgNode ) )
928 {
929 return nullptr;
930 }
931 }
932
933 return m_sgNode;
934 }
935
936 IFSG_TRANSFORM topNode( aParent );
937
938 std::list< WRL2NODE* >::iterator sC = m_Children.begin();
939 std::list< WRL2NODE* >::iterator eC = m_Children.end();
940 WRL2NODES type;
941
942 // Include only Shape and Transform nodes in the top node
943 bool test = false; // set to true if there are any subnodes for display
944
945 while( sC != eC )
946 {
947 type = (*sC)->GetNodeType();
948
949 switch( type )
950 {
952 // wrap the shape in a transform
953 do
954 {
955 IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
956 SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
957
958 if( nullptr != pshape )
959 test = true;
960 else
961 wrapper.Destroy();
962
963 } while( 0 );
964
965 break;
966
970
971 if( nullptr != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
972 test = true;
973
974 break;
975
976 default:
977 break;
978 }
979
980 ++ sC;
981 }
982
983 if( false == test )
984 {
985 topNode.Destroy();
986 return nullptr;
987 }
988
989 m_sgNode = topNode.GetRawPtr();
990
991 return m_sgNode;
992}
IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH.
SGNODE * m_sgNode
Definition: vrml2_node.h:178
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:512
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:503

References S3D::AddSGNodeChild(), S3D::AddSGNodeRef(), IFSG_NODE::Destroy(), IFSG_NODE::GetRawPtr(), S3D::GetSGNodeParent(), WRL2NODE::m_Children, WRL2NODE::m_sgNode, WRL2_INLINE, WRL2_SHAPE, WRL2_SWITCH, and WRL2_TRANSFORM.

Referenced by LoadVRML().

◆ 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

◆ m_BackPointers

◆ m_Children

◆ m_dir

std::string WRL2BASE::m_dir
private

Definition at line 107 of file vrml2_base.h.

Referenced by GetInlineData(), and Read().

◆ m_error

std::string WRL2NODE::m_error
protectedinherited

Definition at line 176 of file vrml2_node.h.

Referenced by WRL2NODE::GetError().

◆ m_inlineModels

std::map< std::string, SGNODE* > WRL2BASE::m_inlineModels
private

Definition at line 108 of file vrml2_base.h.

Referenced by GetInlineData(), and ~WRL2BASE().

◆ 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

◆ m_useInline

bool WRL2BASE::m_useInline
private

Definition at line 106 of file vrml2_base.h.

Referenced by GetEnableInline(), readInline(), SetEnableInline(), and WRL2BASE().


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