KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SCENEGRAPH Class Reference

Define the basic data set required to represent a 3D model. More...

#include <scenegraph.h>

Inheritance diagram for SCENEGRAPH:
SGNODE

Public Member Functions

void unlinkChildNode (const SGNODE *aNode) override
 Remove references to an owned child.
 
void unlinkRefNode (const SGNODE *aNode) override
 Remove pointers to a referenced node.
 
 SCENEGRAPH (SGNODE *aParent)
 
virtual ~SCENEGRAPH ()
 
virtual bool SetParent (SGNODE *aParent, bool notify=true) override
 Set the parent SGNODE of this object.
 
SGNODEFindNode (const char *aNodeName, const SGNODE *aCaller) override
 Search the tree of linked nodes and return a reference to the first node found with the given name.
 
bool AddRefNode (SGNODE *aNode) override
 
bool AddChildNode (SGNODE *aNode) override
 
void ReNameNodes (void) override
 Rename a node and all its child nodes in preparation for write operations.
 
bool WriteVRML (std::ostream &aFile, bool aReuseFlag) override
 Writes this node's data to a VRML file.
 
bool WriteCache (std::ostream &aFile, SGNODE *parentNode) override
 Write this node's data to a binary cache file.
 
bool ReadCache (std::istream &aFile, SGNODE *parentNode) override
 Reads binary format data from a cache file.
 
bool Prepare (const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
 
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.
 
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
 
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.
 
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.
 

Public Attributes

SGPOINT center
 
SGPOINT translation
 
SGVECTOR rotation_axis
 
double rotation_angle
 
SGPOINT scale
 
SGVECTOR scale_axis
 
double scale_angle
 

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 Member Functions

void unlinkNode (const SGNODE *aNode, bool isChild)
 
bool addNode (SGNODE *aNode, bool isChild)
 

Private Attributes

std::vector< SCENEGRAPH * > m_Transforms
 
std::vector< SGSHAPE * > m_Shape
 
std::vector< SCENEGRAPH * > m_RTransforms
 
std::vector< SGSHAPE * > m_RShape
 
SGNODE ** m_Association
 Handle to the instance held by a wrapper.
 

Detailed Description

Define the basic data set required to represent a 3D model.

This model must remain compatible with VRML2.0 in order to facilitate VRML export of scene graph data created by available 3D plugins.

Definition at line 44 of file scenegraph.h.

Constructor & Destructor Documentation

◆ SCENEGRAPH()

◆ ~SCENEGRAPH()

SCENEGRAPH::~SCENEGRAPH ( )
virtual

Definition at line 64 of file scenegraph.cpp.

References DEL_OBJS, DROP_REFS, m_RShape, m_RTransforms, m_Shape, and m_Transforms.

Member Function Documentation

◆ AddChildNode()

bool SCENEGRAPH::AddChildNode ( SGNODE aNode)
overridevirtual

Implements SGNODE.

Definition at line 187 of file scenegraph.cpp.

References addNode().

◆ addNode()

bool SCENEGRAPH::addNode ( SGNODE aNode,
bool  isChild 
)
private

◆ addNodeRef()

void SGNODE::addNodeRef ( SGNODE aNode)
inherited

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 SGNODE::m_BackPointers.

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

◆ AddRefNode()

bool SCENEGRAPH::AddRefNode ( SGNODE aNode)
overridevirtual

Implements SGNODE.

Definition at line 181 of file scenegraph.cpp.

References addNode().

Referenced by ReadCache().

◆ AssociateWrapper()

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

◆ delNodeRef()

void SGNODE::delNodeRef ( const SGNODE aNode)
inherited

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 SGNODE::GetNodeType(), SGNODE::m_BackPointers, and SGNODE::m_SGtype.

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

◆ DisassociateWrapper()

◆ FindNode()

SGNODE * SCENEGRAPH::FindNode ( const char *  aNodeName,
const SGNODE aCaller 
)
overridevirtual

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.

Implements SGNODE.

Definition at line 106 of file scenegraph.cpp.

References FIND_NODE, SGNODE::FindNode(), SGNODE::m_Name, SGNODE::m_Parent, m_Shape, and m_Transforms.

Referenced by ReadCache().

◆ GetName()

◆ GetNodeType()

◆ GetNodeTypeName()

◆ GetParent()

◆ isWritten()

bool SGNODE::isWritten ( void  )
inlinenoexceptinherited

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 SGNODE::m_written.

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

◆ Prepare()

bool SCENEGRAPH::Prepare ( const glm::dmat4 *  aTransform,
S3D::MATLIST materials,
std::vector< SMESH > &  meshes 
)

◆ ReadCache()

bool SCENEGRAPH::ReadCache ( std::istream &  aFile,
SGNODE parentNode 
)
overridevirtual

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.

Implements SGNODE.

Definition at line 466 of file scenegraph.cpp.

References AddRefNode(), center, FindNode(), SGNODE::GetNodeType(), SGNODE::m_Name, m_RShape, m_RTransforms, m_Shape, m_Transforms, name, ReadCache(), SGSHAPE::ReadCache(), S3D::ReadPoint(), S3D::ReadTag(), S3D::ReadVector(), rotation_angle, rotation_axis, scale, scale_angle, scale_axis, SGNODE::SetName(), S3D::SGTYPE_SHAPE, S3D::SGTYPE_TRANSFORM, and translation.

Referenced by ReadCache().

◆ ReNameNodes()

void SCENEGRAPH::ReNameNodes ( void  )
overridevirtual

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

Implements SGNODE.

Definition at line 193 of file scenegraph.cpp.

References SGNODE::GetName(), SGNODE::m_Name, m_Shape, m_Transforms, and SGNODE::m_written.

Referenced by WriteCache().

◆ ResetNodeIndex()

void SGNODE::ResetNodeIndex ( void  )
noexceptinherited

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(), WriteCache(), and S3D::WriteVRML().

◆ SetName()

void SGNODE::SetName ( const char *  aName)
inherited

◆ SetParent()

bool SCENEGRAPH::SetParent ( SGNODE aParent,
bool  notify = true 
)
overridevirtual

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.

Implements SGNODE.

Definition at line 76 of file scenegraph.cpp.

References SGNODE::AddChildNode(), SGNODE::GetNodeType(), SGNODE::m_Parent, S3D::SGTYPE_TRANSFORM, and SGNODE::unlinkChildNode().

◆ SwapParent()

bool SGNODE::SwapParent ( SGNODE aNewParent)
inherited

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 SGNODE::AddChildNode(), SGNODE::AddRefNode(), SGNODE::GetNodeType(), SGNODE::m_Parent, SGNODE::unlinkChildNode(), and SGNODE::unlinkRefNode().

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

◆ unlinkChildNode()

void SCENEGRAPH::unlinkChildNode ( const SGNODE aNode)
overridevirtual

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.

Implements SGNODE.

Definition at line 150 of file scenegraph.cpp.

References unlinkNode().

◆ unlinkNode()

void SCENEGRAPH::unlinkNode ( const SGNODE aNode,
bool  isChild 
)
private

◆ unlinkRefNode()

void SCENEGRAPH::unlinkRefNode ( const SGNODE aNode)
overridevirtual

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.

Implements SGNODE.

Definition at line 157 of file scenegraph.cpp.

References unlinkNode().

◆ WriteCache()

bool SCENEGRAPH::WriteCache ( std::ostream &  aFile,
SGNODE parentNode 
)
overridevirtual

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.

Implements SGNODE.

Definition at line 337 of file scenegraph.cpp.

References center, SGNODE::GetName(), SGNODE::GetParent(), SGNODE::isWritten(), SGNODE::m_Parent, m_RShape, m_RTransforms, m_Shape, m_Transforms, SGNODE::m_written, ReNameNodes(), SGNODE::ResetNodeIndex(), rotation_angle, rotation_axis, scale, scale_angle, scale_axis, translation, WriteCache(), SGNODE::WriteCache(), S3D::WritePoint(), and S3D::WriteVector().

Referenced by WriteCache().

◆ WriteVRML()

bool SCENEGRAPH::WriteVRML ( std::ostream &  aFile,
bool  aReuseFlag 
)
overridevirtual

Writes this node's data to a VRML file.

This includes all data of child and referenced nodes.

Implements SGNODE.

Definition at line 231 of file scenegraph.cpp.

References center, S3D::FormatOrientation(), S3D::FormatPoint(), SGNODE::GetName(), m_RShape, m_RTransforms, m_Shape, m_Transforms, SGNODE::m_written, rotation_angle, rotation_axis, scale, scale_angle, scale_axis, translation, SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Member Data Documentation

◆ center

SGPOINT SCENEGRAPH::center

Definition at line 73 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), WriteCache(), and WriteVRML().

◆ m_Association

SGNODE** SGNODE::m_Association
privateinherited

Handle to the instance held by a wrapper.

Definition at line 233 of file sg_node.h.

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

◆ m_BackPointers

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

nodes which hold a reference to this.

Definition at line 226 of file sg_node.h.

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

◆ m_Name

◆ m_Parent

◆ m_RShape

std::vector< SGSHAPE* > SCENEGRAPH::m_RShape
private

Definition at line 92 of file scenegraph.h.

Referenced by addNode(), Prepare(), ReadCache(), unlinkNode(), WriteCache(), WriteVRML(), and ~SCENEGRAPH().

◆ m_RTransforms

std::vector< SCENEGRAPH* > SCENEGRAPH::m_RTransforms
private

Definition at line 91 of file scenegraph.h.

Referenced by addNode(), Prepare(), ReadCache(), unlinkNode(), WriteCache(), WriteVRML(), and ~SCENEGRAPH().

◆ m_SGtype

◆ m_Shape

std::vector< SGSHAPE* > SCENEGRAPH::m_Shape
private

◆ m_Transforms

std::vector< SCENEGRAPH* > SCENEGRAPH::m_Transforms
private

◆ m_written

◆ rotation_angle

double SCENEGRAPH::rotation_angle

Definition at line 76 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), SCENEGRAPH(), WriteCache(), and WriteVRML().

◆ rotation_axis

SGVECTOR SCENEGRAPH::rotation_axis

Definition at line 75 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), WriteCache(), and WriteVRML().

◆ scale

SGPOINT SCENEGRAPH::scale

Definition at line 77 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), SCENEGRAPH(), WriteCache(), and WriteVRML().

◆ scale_angle

double SCENEGRAPH::scale_angle

Definition at line 79 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), SCENEGRAPH(), WriteCache(), and WriteVRML().

◆ scale_axis

SGVECTOR SCENEGRAPH::scale_axis

Definition at line 78 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), WriteCache(), and WriteVRML().

◆ translation

SGPOINT SCENEGRAPH::translation

Definition at line 74 of file scenegraph.h.

Referenced by Prepare(), ReadCache(), WriteCache(), and WriteVRML().


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