KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SGNODE Class Referenceabstract

The base class of all Scene Graph nodes. More...

#include <sg_node.h>

Inheritance diagram for SGNODE:
SCENEGRAPH SGAPPEARANCE SGCOLORS SGCOORDS SGFACESET SGINDEX SGNORMALS SGSHAPE

Public Member Functions

 SGNODE (SGNODE *aParent)
 
virtual ~SGNODE ()
 
S3D::SGTYPES GetNodeType (void) const noexcept
 Return the type of this node instance.
 
SGNODEGetParent (void) const noexcept
 Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
 
virtual bool SetParent (SGNODE *aParent, bool notify=true)=0
 Set the parent SGNODE of this object.
 
bool SwapParent (SGNODE *aNewParent)
 Swap the ownership with the given parent.
 
const char * GetName (void)
 
void SetName (const char *aName)
 
const char * GetNodeTypeName (S3D::SGTYPES aNodeType) const noexcept
 
virtual SGNODEFindNode (const char *aNodeName, const SGNODE *aCaller)=0
 Search the tree of linked nodes and return a reference to the first node found with the given name.
 
virtual bool AddRefNode (SGNODE *aNode)=0
 
virtual bool AddChildNode (SGNODE *aNode)=0
 
void AssociateWrapper (SGNODE **aWrapperRef) noexcept
 Associate this object with a handle to itself.
 
void DisassociateWrapper (SGNODE **aWrapperRef) noexcept
 Remove the association between an IFSG* wrapper object and this object.
 
void ResetNodeIndex (void) noexcept
 Reset the global SG* node indices in preparation for write operations.
 
virtual void ReNameNodes (void)=0
 Rename a node and all its child nodes in preparation for write operations.
 
virtual bool WriteVRML (std::ostream &aFile, bool aReuseFlag)=0
 Writes this node's data to a VRML file.
 
virtual bool WriteCache (std::ostream &aFile, SGNODE *parentNode)=0
 Write this node's data to a binary cache file.
 
virtual bool ReadCache (std::istream &aFile, SGNODE *parentNode)=0
 Reads binary format data from a cache file.
 
virtual void unlinkChildNode (const SGNODE *aNode)=0
 Remove references to an owned child.
 
virtual void unlinkRefNode (const SGNODE *aNode)=0
 Remove pointers to a referenced node.
 
void addNodeRef (SGNODE *aNode)
 Add a pointer to a node which references this node, but does not own.
 
void delNodeRef (const SGNODE *aNode)
 Remove a pointer to a node which references this node, but does not own.
 
bool isWritten (void) noexcept
 Return true if the object had already been written to a cache file or VRML file.
 

Protected Attributes

std::list< SGNODE * > m_BackPointers
 nodes which hold a reference to this.
 
SGNODEm_Parent
 Pointer to parent node; may be NULL for top level transform.
 
S3D::SGTYPES m_SGtype
 Type of Scene Graph node.
 
std::string m_Name
 name to use for referencing the entity by name.
 
bool m_written
 Set to true when the object has been written after a ReNameNodes().
 

Private Attributes

SGNODE ** m_Association
 Handle to the instance held by a wrapper.
 

Detailed Description

The base class of all Scene Graph nodes.

Definition at line 74 of file sg_node.h.

Constructor & Destructor Documentation

◆ SGNODE()

SGNODE::SGNODE ( SGNODE aParent)

Definition at line 76 of file sg_node.cpp.

References m_Association, m_Parent, m_SGtype, m_written, and S3D::SGTYPE_END.

◆ ~SGNODE()

SGNODE::~SGNODE ( )
virtual

Definition at line 85 of file sg_node.cpp.

References m_Association, m_BackPointers, m_Parent, and unlinkChildNode().

Member Function Documentation

◆ AddChildNode()

◆ addNodeRef()

void SGNODE::addNodeRef ( SGNODE aNode)

Add a pointer to a node which references this node, but does not own.

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 170 of file sg_node.cpp.

References m_BackPointers.

Referenced by SGFACESET::addNode(), SGSHAPE::addNode(), SGFACESET::ReadCache(), and SGSHAPE::ReadCache().

◆ AddRefNode()

virtual bool SGNODE::AddRefNode ( SGNODE aNode)
pure virtual

◆ AssociateWrapper()

void SGNODE::AssociateWrapper ( SGNODE **  aWrapperRef)
noexcept

◆ delNodeRef()

void SGNODE::delNodeRef ( const SGNODE aNode)

Remove a pointer to a node which references this node, but does not own.

Parameters
aNodeis the node holding a reference to this object.

Definition at line 185 of file sg_node.cpp.

References GetNodeType(), m_BackPointers, and m_SGtype.

Referenced by SGFACESET::unlinkNode(), SGSHAPE::unlinkNode(), SGFACESET::~SGFACESET(), and SGSHAPE::~SGSHAPE().

◆ DisassociateWrapper()

◆ FindNode()

virtual SGNODE * SGNODE::FindNode ( const char *  aNodeName,
const SGNODE aCaller 
)
pure virtual

Search the tree of linked nodes and return 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, otherwise NULL.

Implemented in SGAPPEARANCE, SGCOLORS, SGCOORDS, SGINDEX, SGNORMALS, SCENEGRAPH, SGFACESET, and SGSHAPE.

Referenced by IFSG_NODE::FindNode(), SCENEGRAPH::FindNode(), SGFACESET::FindNode(), and SGSHAPE::FindNode().

◆ GetName()

◆ GetNodeType()

◆ GetNodeTypeName()

◆ GetParent()

◆ isWritten()

bool SGNODE::isWritten ( void  )
inlinenoexcept

Return true if the object had already been written to a cache file or VRML file.

For internal use only.

Definition at line 220 of file sg_node.h.

References m_written.

Referenced by SCENEGRAPH::WriteCache(), SGFACESET::WriteCache(), and SGSHAPE::WriteCache().

◆ ReadCache()

virtual bool SGNODE::ReadCache ( std::istream &  aFile,
SGNODE parentNode 
)
pure virtual

Reads binary format data from a cache file.

To read a cache file, open the file for reading and invoke this function from a new SCENEGRAPH node.

Implemented in SCENEGRAPH, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGFACESET, SGINDEX, SGNORMALS, and SGSHAPE.

◆ ReNameNodes()

virtual void SGNODE::ReNameNodes ( void  )
pure virtual

Rename a node and all its child nodes in preparation for write operations.

Implemented in SCENEGRAPH, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGFACESET, SGINDEX, SGNORMALS, and SGSHAPE.

Referenced by S3D::RenameNodes(), and S3D::WriteVRML().

◆ ResetNodeIndex()

void SGNODE::ResetNodeIndex ( void  )
noexcept

Reset the global SG* node indices in preparation for write operations.

Definition at line 238 of file sg_node.cpp.

References node_counts, and S3D::SGTYPE_END.

Referenced by S3D::ResetNodeIndex(), SCENEGRAPH::WriteCache(), and S3D::WriteVRML().

◆ SetName()

void SGNODE::SetName ( const char *  aName)

◆ SetParent()

virtual bool SGNODE::SetParent ( SGNODE aParent,
bool  notify = true 
)
pure virtual

Set the parent SGNODE of this object.

Parameters
aParent[in] is the desired parent node
Returns
true if the operation succeeds; false if the given node is not allowed to be a parent to the derived object.

Implemented in SCENEGRAPH, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGFACESET, SGINDEX, SGNORMALS, and SGSHAPE.

Referenced by IFSG_APPEARANCE::IFSG_APPEARANCE(), IFSG_COLORS::IFSG_COLORS(), IFSG_COORDINDEX::IFSG_COORDINDEX(), IFSG_COORDS::IFSG_COORDS(), IFSG_FACESET::IFSG_FACESET(), IFSG_NORMALS::IFSG_NORMALS(), IFSG_SHAPE::IFSG_SHAPE(), IFSG_TRANSFORM::IFSG_TRANSFORM(), and IFSG_NODE::SetParent().

◆ SwapParent()

bool SGNODE::SwapParent ( SGNODE aNewParent)

Swap the ownership with the given parent.

This operation may be required when reordering nodes for optimization.

Parameters
aNewParentwill become the new parent to the object; it must be the same type as the parent of this instance.

Definition at line 116 of file sg_node.cpp.

References AddChildNode(), AddRefNode(), GetNodeType(), m_Parent, unlinkChildNode(), and unlinkRefNode().

Referenced by SGFACESET::WriteCache(), and SGSHAPE::WriteCache().

◆ unlinkChildNode()

virtual void SGNODE::unlinkChildNode ( const SGNODE aNode)
pure virtual

Remove references to an owned child.

This is invoked by the child upon destruction to ensure that the parent has no invalid references.

Parameters
aNodeis the child which is being deleted.

Implemented in SGINDEX, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGNORMALS, SCENEGRAPH, SGFACESET, and SGSHAPE.

Referenced by SCENEGRAPH::SetParent(), SGAPPEARANCE::SetParent(), SGCOLORS::SetParent(), SGCOORDS::SetParent(), SGFACESET::SetParent(), SGINDEX::SetParent(), SGNORMALS::SetParent(), SGSHAPE::SetParent(), SwapParent(), and ~SGNODE().

◆ unlinkRefNode()

virtual void SGNODE::unlinkRefNode ( const SGNODE aNode)
pure virtual

Remove pointers to a referenced node.

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

Implemented in SGINDEX, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGNORMALS, SCENEGRAPH, SGFACESET, and SGSHAPE.

Referenced by SwapParent().

◆ WriteCache()

virtual bool SGNODE::WriteCache ( std::ostream &  aFile,
SGNODE parentNode 
)
pure virtual

Write this node's data to a binary cache file.

The data includes all data of children and references to children. If this function is invoked by the user, parentNode must be set to NULL in order to ensure coherent data.

Implemented in SCENEGRAPH, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGFACESET, SGINDEX, SGNORMALS, and SGSHAPE.

Referenced by S3D::WriteCache(), SCENEGRAPH::WriteCache(), SGAPPEARANCE::WriteCache(), SGCOLORS::WriteCache(), SGCOORDS::WriteCache(), SGFACESET::WriteCache(), SGINDEX::WriteCache(), SGNORMALS::WriteCache(), and SGSHAPE::WriteCache().

◆ WriteVRML()

virtual bool SGNODE::WriteVRML ( std::ostream &  aFile,
bool  aReuseFlag 
)
pure virtual

Writes this node's data to a VRML file.

This includes all data of child and referenced nodes.

Implemented in SCENEGRAPH, SGAPPEARANCE, SGCOLORS, SGCOORDS, SGFACESET, SGINDEX, SGNORMALS, and SGSHAPE.

Referenced by S3D::WriteVRML().

Member Data Documentation

◆ m_Association

SGNODE** SGNODE::m_Association
private

Handle to the instance held by a wrapper.

Definition at line 233 of file sg_node.h.

Referenced by SGNODE(), and ~SGNODE().

◆ m_BackPointers

std::list< SGNODE* > SGNODE::m_BackPointers
protected

nodes which hold a reference to this.

Definition at line 226 of file sg_node.h.

Referenced by addNodeRef(), SGCOORDS::CalcNormals(), delNodeRef(), and ~SGNODE().

◆ m_Name

◆ m_Parent

◆ m_SGtype

◆ m_written


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