KiCad PCB EDA Suite
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Cirilo Bernardo <>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  *
19  * or you may search the website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
29 #ifndef IFSG_API_H
30 #define IFSG_API_H
32 #include "plugins/3dapi/sg_types.h"
33 #include "plugins/3dapi/sg_base.h"
34 #include "plugins/3dapi/c3dmodel.h"
36 class SGNODE;
37 class SCENEGRAPH;
38 struct S3D_INFO;
39 struct S3D_POINT;
41 namespace S3D
42 {
47  SGLIB_API void GetLibVersion( unsigned char* Major, unsigned char* Minor,
48  unsigned char* Patch, unsigned char* Revision );
50  // functions to extract information from SGNODE pointers
53  SGLIB_API bool AddSGNodeRef( SGNODE* aParent, SGNODE* aChild );
54  SGLIB_API bool AddSGNodeChild( SGNODE* aParent, SGNODE* aChild );
55  SGLIB_API void AssociateSGNodeWrapper( SGNODE* aObject, SGNODE** aRefPtr );
61  SGLIB_API SGVECTOR CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT& p3 );
72  SGLIB_API bool WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
73  const char* aPluginInfo );
84  SGLIB_API SGNODE* ReadCache( const char* aFileName, void* aPluginMgr,
85  bool (*aTagCheck)( const char*, void* ) );
97  SGLIB_API bool WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
98  bool reuse, bool renameNodes );
100  // NOTE: The following functions are used in combination to create a VRML
101  // assembly which may use various instances of each SG* representation of a module.
102  // A typical use case would be:
103  // 1. invoke 'ResetNodeIndex()' to reset the global node name indices
104  // 2. for each model pointer provided by 'S3DCACHE->Load()', invoke 'RenameNodes()' once;
105  // this ensures that all nodes have a unique name to present to the final output file.
106  // Internally, RenameNodes() will only rename the given node and all Child subnodes;
107  // nodes which are only referenced will not be renamed. Using the pointer supplied
108  // by 'S3DCACHE->Load()' ensures that all nodes but the returned node (top node) are
109  // children of at least one node, so all nodes are given unique names.
110  // 3. if SG* trees are created independently of S3DCACHE->Load() the user must invoke
111  // RenameNodes() as appropriate to ensure that all nodes have a unique name
112  // 4. create an assembly structure by creating new IFSG_TRANSFORM nodes as appropriate
113  // for each instance of a component; the component base model as returned by
114  // S3DCACHE->Load() may be added to these IFSG_TRANSFORM nodes via 'AddRefNode()';
115  // set the offset, rotation, etc of the IFSG_TRANSFORM node to ensure correct
116  // 5. Ensure that all new IFSG_TRANSFORM nodes are placed as child nodes within a
117  // top level IFSG_TRANSFORM node in preparation for final node naming and output
118  // 6. Invoke RenameNodes() on the top level assembly node
119  // 7. Invoke WriteVRML() as normal, with renameNodes = false, to write the entire assembly
120  // structure to a single VRML file
121  // 8. Clean up by deleting any extra IFSG_TRANSFORM wrappers and their underlying SG*
122  // classes which have been created solely for the assembly output
130  SGLIB_API void ResetNodeIndex( SGNODE* aNode );
139  SGLIB_API void RenameNodes( SGNODE* aNode );
147  SGLIB_API void DestroyNode( SGNODE* aNode );
149  // NOTE: The following functions facilitate the creation and destruction
150  // of data structures for rendering
166  SGLIB_API void Destroy3DModel( S3DMODEL** aModel );
172  SGLIB_API void Free3DModel( S3DMODEL& aModel );
178  SGLIB_API void Free3DMesh( SMESH& aMesh );
184  SGLIB_API S3DMODEL* New3DModel( void );
190  SGLIB_API void Init3DMaterial( SMATERIAL& aMat );
196  SGLIB_API void Init3DMesh( SMESH& aMesh );
197 };
199 #endif // IFSG_API_H
define an internal structure to be used by the 3D renders
SGLIB_API void RenameNodes(SGNODE *aNode)
Function RenameNodes renames a node and all children nodes based on the current values of the global ...
Definition: ifsg_api.cpp:192
SGLIB_API S3DMODEL * New3DModel(void)
Function New3DModel creates and initializes an S3DMODEL struct.
Definition: ifsg_api.cpp:571
defines the types of intermediate scene graph objects
SGLIB_API void Init3DMaterial(SMATERIAL &aMat)
Function Init3DMaterial initializes an SMATERIAL struct.
Definition: ifsg_api.cpp:579
SGLIB_API SGNODE * ReadCache(const char *aFileName, void *aPluginMgr, bool(*aTagCheck)(const char *, void *))
Function ReadCache reads a binary cache file and creates an SGNODE tree.
Definition: ifsg_api.cpp:328
SGLIB_API void ResetNodeIndex(SGNODE *aNode)
Function ResetNodeIndex resets the global SG* class indices.
Definition: ifsg_api.cpp:170
SGLIB_API void AssociateSGNodeWrapper(SGNODE *aObject, SGNODE **aRefPtr)
Definition: ifsg_api.cpp:670
SGLIB_API void Destroy3DModel(S3DMODEL **aModel)
Function Destroy3DModel frees memory used by an S3DMODEL structure and sets the pointer to the struct...
Definition: ifsg_api.cpp:543
Definition: ifsg_api.cpp:643
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
Per-vertex normal/color/texcoors structure.
Definition: c3dmodel.h:76
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:652
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.
Definition: ifsg_api.cpp:81
defines the low level classes common to scene graph nodes
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:661
SGLIB_API void Free3DModel(S3DMODEL &aModel)
Function Free3DModel frees memory used internally by an S3DMODEL structure.
Definition: ifsg_api.cpp:557
SGLIB_API void Init3DMesh(SMESH &aMesh)
Function Init3DMesh creates and initializes an SMESH struct.
Definition: ifsg_api.cpp:586
Definition: sg_types.h:34
#define SGLIB_API
Definition: ifsg_defs.h:56
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...
Definition: ifsg_api.cpp:613
Definition: ifsg_api.cpp:634
SGLIB_API void DestroyNode(SGNODE *aNode)
Function DestroyNode deletes the given SG* class node.
Definition: ifsg_api.cpp:214
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.
Definition: ifsg_api.cpp:236
Store the a model based on meshes and materials.
Definition: c3dmodel.h:90
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms) ...
Definition: ifsg_api.cpp:478
SGLIB_API void GetLibVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
Function GetLibVersion retrieves version information of the kicad_3dsg library.
Definition: ifsg_api.cpp:594
SGLIB_API void Free3DMesh(SMESH &aMesh)
Function Free3DMesh frees memory used internally by an SMESH structure.
Definition: ifsg_api.cpp:564