KiCad PCB EDA Suite
Loading...
Searching...
No Matches
S3D Namespace Reference

Classes

struct  MATLIST
 

Enumerations

enum  SGTYPES {
  SGTYPE_TRANSFORM = 0 , SGTYPE_APPEARANCE , SGTYPE_COLORS , SGTYPE_COLORINDEX ,
  SGTYPE_FACESET , SGTYPE_COORDS , SGTYPE_COORDINDEX , SGTYPE_NORMALS ,
  SGTYPE_SHAPE , SGTYPE_END
}
 

Functions

bool degenerate (glm::dvec3 *pts) noexcept
 
bool CalcTriangleNormals (std::vector< SGPOINT > coords, std::vector< int > &index, std::vector< SGVECTOR > &norms)
 
void FormatFloat (std::string &result, double value)
 
void FormatOrientation (std::string &result, const SGVECTOR &axis, double rotation)
 
void FormatPoint (std::string &result, const SGPOINT &point)
 
void FormatVector (std::string &result, const SGVECTOR &aVector)
 
void FormatColor (std::string &result, const SGCOLOR &aColor)
 
bool WritePoint (std::ostream &aFile, const SGPOINT &aPoint)
 
bool WriteVector (std::ostream &aFile, const SGVECTOR &aVector)
 
bool WriteColor (std::ostream &aFile, const SGCOLOR &aColor)
 
S3D::SGTYPES ReadTag (std::istream &aFile, std::string &aName)
 Read the text tag of a binary cache file which is the NodeTag and unique ID number combined.
 
bool ReadPoint (std::istream &aFile, SGPOINT &aPoint)
 
bool ReadVector (std::istream &aFile, SGVECTOR &aVector)
 
bool ReadColor (std::istream &aFile, SGCOLOR &aColor)
 
char const * GetNodeTypeName (S3D::SGTYPES aType) noexcept
 Return the name of the given type of node.
 
bool GetMatIndex (MATLIST &aList, SGNODE *aNode, int &aIndex)
 
void INIT_SMATERIAL (SMATERIAL &aMaterial)
 
void INIT_SMESH (SMESH &aMesh) noexcept
 
void INIT_S3DMODEL (S3DMODEL &aModel) noexcept
 
void FREE_SMESH (SMESH &aMesh) noexcept
 
void FREE_S3DMODEL (S3DMODEL &aModel)
 
SGLIB_API void GetLibVersion (unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision) noexcept
 Function GetLibVersion retrieves version information of the kicad_3dsg library.
 
SGLIB_API S3D::SGTYPES GetSGNodeType (SGNODE *aNode)
 
SGLIB_API SGNODEGetSGNodeParent (SGNODE *aNode)
 
SGLIB_API bool AddSGNodeRef (SGNODE *aParent, SGNODE *aChild)
 
SGLIB_API bool AddSGNodeChild (SGNODE *aParent, SGNODE *aChild)
 
SGLIB_API void AssociateSGNodeWrapper (SGNODE *aObject, SGNODE **aRefPtr)
 
SGLIB_API SGVECTOR CalcTriNorm (const SGPOINT &p1, const SGPOINT &p2, const SGPOINT &p3)
 Function CalcTriNorm returns the normal vector of a triangle described by vertices p1, p2, p3.
 
SGLIB_API bool WriteCache (const char *aFileName, bool overwrite, SGNODE *aNode, const char *aPluginInfo)
 Function WriteCache writes the SGNODE tree to a binary cache file.
 
SGLIB_API SGNODEReadCache (const char *aFileName, void *aPluginMgr, bool(*aTagCheck)(const char *, void *))
 Function ReadCache reads a binary cache file and creates an SGNODE tree.
 
SGLIB_API bool WriteVRML (const char *filename, bool overwrite, SGNODE *aTopNode, bool reuse, bool renameNodes)
 Function WriteVRML writes out the given node and its subnodes to a VRML2 file.
 
SGLIB_API void ResetNodeIndex (SGNODE *aNode)
 Function ResetNodeIndex resets the global SG* class indices.
 
SGLIB_API void RenameNodes (SGNODE *aNode)
 Function RenameNodes renames a node and all children nodes based on the current values of the global SG* class indices.
 
SGLIB_API void DestroyNode (SGNODE *aNode) noexcept
 Function DestroyNode deletes the given SG* class node.
 
SGLIB_API S3DMODELGetModel (SCENEGRAPH *aNode)
 Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)
 
SGLIB_API void Destroy3DModel (S3DMODEL **aModel)
 Function Destroy3DModel frees memory used by an S3DMODEL structure and sets the pointer to the structure to NULL.
 
SGLIB_API void Free3DModel (S3DMODEL &aModel)
 Function Free3DModel frees memory used internally by an S3DMODEL structure.
 
SGLIB_API void Free3DMesh (SMESH &aMesh)
 Function Free3DMesh frees memory used internally by an SMESH structure.
 
SGLIB_API S3DMODELNew3DModel (void)
 Function New3DModel creates and initializes an S3DMODEL struct.
 
SGLIB_API void Init3DMaterial (SMATERIAL &aMat)
 Function Init3DMaterial initializes an SMATERIAL struct.
 
SGLIB_API void Init3DMesh (SMESH &aMesh)
 Function Init3DMesh creates and initializes an SMESH struct.
 

Enumeration Type Documentation

◆ SGTYPES

Enumerator
SGTYPE_TRANSFORM 
SGTYPE_APPEARANCE 
SGTYPE_COLORS 
SGTYPE_COLORINDEX 
SGTYPE_FACESET 
SGTYPE_COORDS 
SGTYPE_COORDINDEX 
SGTYPE_NORMALS 
SGTYPE_SHAPE 
SGTYPE_END 

Definition at line 34 of file sg_types.h.

Function Documentation

◆ AddSGNodeChild()

◆ AddSGNodeRef()

◆ AssociateSGNodeWrapper()

void S3D::AssociateSGNodeWrapper ( SGNODE aObject,
SGNODE **  aRefPtr 
)

Definition at line 521 of file ifsg_api.cpp.

References SGNODE::AssociateWrapper().

◆ CalcTriangleNormals()

bool S3D::CalcTriangleNormals ( std::vector< SGPOINT coords,
std::vector< int > &  index,
std::vector< SGVECTOR > &  norms 
)

Definition at line 353 of file sg_helpers.cpp.

References calcTriad().

Referenced by SGCOORDS::CalcNormals().

◆ CalcTriNorm()

SGVECTOR S3D::CalcTriNorm ( const SGPOINT p1,
const SGPOINT p2,
const SGPOINT p3 
)

Function CalcTriNorm returns the normal vector of a triangle described by vertices p1, p2, p3.

Definition at line 464 of file ifsg_api.cpp.

References degenerate(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Referenced by EXPORTER_PCB_VRML::create_vrml_shell(), and vrmlToSG().

◆ degenerate()

bool S3D::degenerate ( glm::dvec3 *  pts)
noexcept

Definition at line 310 of file sg_helpers.cpp.

Referenced by calcTriad(), and CalcTriNorm().

◆ Destroy3DModel()

void S3D::Destroy3DModel ( S3DMODEL **  aModel)

Function Destroy3DModel frees memory used by an S3DMODEL structure and sets the pointer to the structure to NULL.

Definition at line 403 of file ifsg_api.cpp.

References FREE_S3DMODEL().

Referenced by S3D_CACHE::load(), and S3D_CACHE_ENTRY::~S3D_CACHE_ENTRY().

◆ DestroyNode()

void S3D::DestroyNode ( SGNODE aNode)
noexcept

Function DestroyNode deletes the given SG* class node.

This function makes it possible to safely delete an SG* node without associating the node with its corresponding IFSG* wrapper.

Definition at line 149 of file ifsg_api.cpp.

Referenced by S3D_CACHE::load(), S3D_CACHE::loadCacheData(), WRL1MATERIAL::Reclaim(), DATA::~DATA(), EXPORTER_PCB_VRML::~EXPORTER_PCB_VRML(), WRL1MATERIAL::~WRL1MATERIAL(), and WRL2BASE::~WRL2BASE().

◆ FormatColor()

void S3D::FormatColor ( std::string &  result,
const SGCOLOR aColor 
)

Definition at line 135 of file sg_helpers.cpp.

References FormatFloat(), G, and SGCOLOR::GetColor().

Referenced by SGCOLORS::WriteVRML().

◆ FormatFloat()

void S3D::FormatFloat ( std::string &  result,
double  value 
)

◆ FormatOrientation()

void S3D::FormatOrientation ( std::string &  result,
const SGVECTOR axis,
double  rotation 
)

Definition at line 82 of file sg_helpers.cpp.

References FormatFloat(), and SGVECTOR::GetVector().

Referenced by SCENEGRAPH::WriteVRML().

◆ FormatPoint()

void S3D::FormatPoint ( std::string &  result,
const SGPOINT point 
)

Definition at line 103 of file sg_helpers.cpp.

References FormatFloat(), SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Referenced by SCENEGRAPH::WriteVRML(), and SGCOORDS::WriteVRML().

◆ FormatVector()

void S3D::FormatVector ( std::string &  result,
const SGVECTOR aVector 
)

Definition at line 118 of file sg_helpers.cpp.

References FormatFloat(), SGVECTOR::GetVector(), and X.

Referenced by SGNORMALS::WriteVRML().

◆ Free3DMesh()

void S3D::Free3DMesh ( SMESH aMesh)

Function Free3DMesh frees memory used internally by an SMESH structure.

Definition at line 421 of file ifsg_api.cpp.

References FREE_SMESH().

Referenced by GetModel().

◆ Free3DModel()

SGLIB_API void S3D::Free3DModel ( S3DMODEL aModel)

Function Free3DModel frees memory used internally by an S3DMODEL structure.

◆ FREE_S3DMODEL()

void S3D::FREE_S3DMODEL ( S3DMODEL aModel)

◆ FREE_SMESH()

void S3D::FREE_SMESH ( SMESH aMesh)
noexcept

Definition at line 288 of file sg_node.cpp.

Referenced by Free3DMesh(), and FREE_S3DMODEL().

◆ GetLibVersion()

void S3D::GetLibVersion ( unsigned char *  Major,
unsigned char *  Minor,
unsigned char *  Patch,
unsigned char *  Revision 
)
noexcept

Function GetLibVersion retrieves version information of the kicad_3dsg library.

Definition at line 447 of file ifsg_api.cpp.

References KICADSG_VERSION_MAJOR, KICADSG_VERSION_MINOR, KICADSG_VERSION_PATCH, and KICADSG_VERSION_REVISION.

◆ GetMatIndex()

bool S3D::GetMatIndex ( MATLIST aList,
SGNODE aNode,
int &  aIndex 
)

◆ GetModel()

S3DMODEL * S3D::GetModel ( SCENEGRAPH aNode)

Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)

Parameters
aNodeis the node to be transcribed into an S3DMODEL representation
Returns
an S3DMODEL representation of aNode on success, otherwise NULL

Definition at line 338 of file ifsg_api.cpp.

References SGAPPEARANCE::ambient, SGAPPEARANCE::diffuse, formatMaterial(), Free3DMesh(), SGNODE::GetNodeType(), S3DMODEL::m_Materials, S3DMODEL::m_MaterialsSize, S3DMODEL::m_Meshes, S3DMODEL::m_MeshesSize, S3D::MATLIST::matmap, S3D::MATLIST::matorder, New3DModel(), SCENEGRAPH::Prepare(), SGTYPE_TRANSFORM, SGAPPEARANCE::shininess, SGAPPEARANCE::specular, and SGAPPEARANCE::transparency.

Referenced by S3D_CACHE::GetModel().

◆ GetNodeTypeName()

char const * S3D::GetNodeTypeName ( S3D::SGTYPES  aType)
noexcept

Return the name of the given type of node.

Definition at line 53 of file sg_node.cpp.

References node_names.

Referenced by ReadTag().

◆ GetSGNodeParent()

◆ GetSGNodeType()

◆ Init3DMaterial()

void S3D::Init3DMaterial ( SMATERIAL aMat)

Function Init3DMaterial initializes an SMATERIAL struct.

Definition at line 435 of file ifsg_api.cpp.

References INIT_SMATERIAL().

◆ Init3DMesh()

void S3D::Init3DMesh ( SMESH aMesh)

Function Init3DMesh creates and initializes an SMESH struct.

Definition at line 441 of file ifsg_api.cpp.

References INIT_SMESH().

◆ INIT_S3DMODEL()

void S3D::INIT_S3DMODEL ( S3DMODEL aModel)
noexcept

Definition at line 282 of file sg_node.cpp.

Referenced by New3DModel().

◆ INIT_SMATERIAL()

void S3D::INIT_SMATERIAL ( SMATERIAL aMaterial)

Definition at line 270 of file sg_node.cpp.

Referenced by Init3DMaterial().

◆ INIT_SMESH()

void S3D::INIT_SMESH ( SMESH aMesh)
noexcept

Definition at line 276 of file sg_node.cpp.

Referenced by Init3DMesh(), and SGSHAPE::Prepare().

◆ New3DModel()

S3DMODEL * S3D::New3DModel ( void  )

Function New3DModel creates and initializes an S3DMODEL struct.

Definition at line 427 of file ifsg_api.cpp.

References INIT_S3DMODEL().

Referenced by GetModel().

◆ ReadCache()

SGNODE * S3D::ReadCache ( const char *  aFileName,
void *  aPluginMgr,
bool(*)(const char *, void *)  aTagCheck 
)

Function ReadCache reads a binary cache file and creates an SGNODE tree.

Parameters
aFileNameis the name of the binary cache file to be read
Returns
NULL on failure, on success a pointer to the top level SCENEGRAPH node; if desired this node can be associated with an IFSG_TRANSFORM wrapper via the IFSG_TRANSFORM::Attach() function.

Definition at line 221 of file ifsg_api.cpp.

References CLOSE_STREAM, name, OPEN_ISTREAM, and SG_VERSION_TAG.

Referenced by S3D_CACHE::loadCacheData().

◆ ReadColor()

bool S3D::ReadColor ( std::istream &  aFile,
SGCOLOR aColor 
)

Definition at line 295 of file sg_helpers.cpp.

References SGCOLOR::SetColor().

Referenced by SGAPPEARANCE::ReadCache(), and SGCOLORS::ReadCache().

◆ ReadPoint()

bool S3D::ReadPoint ( std::istream &  aFile,
SGPOINT aPoint 
)

Definition at line 267 of file sg_helpers.cpp.

References SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Referenced by SCENEGRAPH::ReadCache(), and SGCOORDS::ReadCache().

◆ ReadTag()

S3D::SGTYPES S3D::ReadTag ( std::istream &  aFile,
std::string &  aName 
)

Read the text tag of a binary cache file which is the NodeTag and unique ID number combined.

Parameters
aFileis a binary file open for reading.
aNamewill hold the tag name on successful return.
Returns
will be the NodeType which the tag represents or S3D::SGTYPES::SGTYPE_END on failure.

Definition at line 195 of file sg_helpers.cpp.

References GetNodeTypeName(), name, SGTYPE_APPEARANCE, SGTYPE_COLORINDEX, SGTYPE_COLORS, SGTYPE_COORDINDEX, SGTYPE_COORDS, SGTYPE_END, SGTYPE_FACESET, SGTYPE_NORMALS, SGTYPE_SHAPE, and SGTYPE_TRANSFORM.

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

◆ ReadVector()

bool S3D::ReadVector ( std::istream &  aFile,
SGVECTOR aVector 
)

Definition at line 280 of file sg_helpers.cpp.

References SGVECTOR::SetVector().

Referenced by SCENEGRAPH::ReadCache(), and SGNORMALS::ReadCache().

◆ RenameNodes()

void S3D::RenameNodes ( SGNODE aNode)

Function RenameNodes renames a node and all children nodes based on the current values of the global SG* class indices.

Parameters
aNodeis a top level node

Definition at line 141 of file ifsg_api.cpp.

References SGNODE::ReNameNodes().

◆ ResetNodeIndex()

void S3D::ResetNodeIndex ( SGNODE aNode)

Function ResetNodeIndex resets the global SG* class indices.

Parameters
aNodemay be any valid SGNODE

Definition at line 133 of file ifsg_api.cpp.

References SGNODE::ResetNodeIndex().

◆ WriteCache()

bool S3D::WriteCache ( const char *  aFileName,
bool  overwrite,
SGNODE aNode,
const char *  aPluginInfo 
)

Function WriteCache writes the SGNODE tree to a binary cache file.

Parameters
aFileNameis the name of the file to write
overwritemust be set to true to overwrite an existing file
aNodeis any node within the node tree which is to be written
Returns
true on success

Definition at line 157 of file ifsg_api.cpp.

References CLOSE_STREAM, OPEN_OSTREAM, SG_VERSION_TAG, and SGNODE::WriteCache().

Referenced by S3D_CACHE::saveCacheData().

◆ WriteColor()

bool S3D::WriteColor ( std::ostream &  aFile,
const SGCOLOR aColor 
)

Definition at line 180 of file sg_helpers.cpp.

References SGCOLOR::GetColor().

Referenced by SGAPPEARANCE::WriteCache(), and SGCOLORS::WriteCache().

◆ WritePoint()

bool S3D::WritePoint ( std::ostream &  aFile,
const SGPOINT aPoint 
)

Definition at line 152 of file sg_helpers.cpp.

References SGPOINT::x, SGPOINT::y, and SGPOINT::z.

Referenced by SCENEGRAPH::WriteCache(), and SGCOORDS::WriteCache().

◆ WriteVector()

bool S3D::WriteVector ( std::ostream &  aFile,
const SGVECTOR aVector 
)

Definition at line 165 of file sg_helpers.cpp.

References SGVECTOR::GetVector().

Referenced by SCENEGRAPH::WriteCache(), and SGNORMALS::WriteCache().

◆ WriteVRML()

bool S3D::WriteVRML ( const char *  filename,
bool  overwrite,
SGNODE aTopNode,
bool  reuse,
bool  renameNodes 
)

Function WriteVRML writes out the given node and its subnodes to a VRML2 file.

Parameters
filenameis the name of the output file
overwriteshould be set to true to overwrite an existing VRML file
aTopNodeis a pointer to a SCENEGRAPH object representing the VRML scene
reuseshould be set to true to make use of VRML DEF/USE features
Returns
true on success

Definition at line 77 of file ifsg_api.cpp.

References CLOSE_STREAM, SGNODE::GetNodeType(), OPEN_OSTREAM, SGNODE::ReNameNodes(), SGNODE::ResetNodeIndex(), SGTYPE_TRANSFORM, and SGNODE::WriteVRML().

Referenced by EXPORTER_PCB_VRML::ExportVrmlFootprint(), Load(), LoadModel(), LoadVRML(), and EXPORTER_PCB_VRML::writeLayers().