KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ifsg_api.h
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 <[email protected]>
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
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org 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 */
23
29#ifndef IFSG_API_H
30#define IFSG_API_H
31
35
36class SGNODE;
37class SCENEGRAPH;
38struct S3D_POINT;
39
40namespace S3D
41{
46 SGLIB_API void GetLibVersion( unsigned char* Major, unsigned char* Minor,
47 unsigned char* Patch, unsigned char* Revision ) noexcept;
48
49 // functions to extract information from SGNODE pointers
52 SGLIB_API bool AddSGNodeRef( SGNODE* aParent, SGNODE* aChild );
53 SGLIB_API bool AddSGNodeChild( SGNODE* aParent, SGNODE* aChild );
54 SGLIB_API void AssociateSGNodeWrapper( SGNODE* aObject, SGNODE** aRefPtr );
55
60 SGLIB_API SGVECTOR CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT& p3 );
61
71 SGLIB_API bool WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
72 const char* aPluginInfo );
73
83 SGLIB_API SGNODE* ReadCache( const char* aFileName, void* aPluginMgr,
84 bool (*aTagCheck)( const char*, void* ) );
85
96 SGLIB_API bool WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
97 bool reuse, bool renameNodes );
98
99 // NOTE: The following functions are used in combination to create a VRML
100 // assembly which may use various instances of each SG* representation of a module.
101 // A typical use case would be:
102 // 1. invoke 'ResetNodeIndex()' to reset the global node name indices
103 // 2. for each model pointer provided by 'S3DCACHE->Load()', invoke 'RenameNodes()' once;
104 // this ensures that all nodes have a unique name to present to the final output file.
105 // Internally, RenameNodes() will only rename the given node and all Child subnodes;
106 // nodes which are only referenced will not be renamed. Using the pointer supplied
107 // by 'S3DCACHE->Load()' ensures that all nodes but the returned node (top node) are
108 // children of at least one node, so all nodes are given unique names.
109 // 3. if SG* trees are created independently of S3DCACHE->Load() the user must invoke
110 // RenameNodes() as appropriate to ensure that all nodes have a unique name
111 // 4. create an assembly structure by creating new IFSG_TRANSFORM nodes as appropriate
112 // for each instance of a component; the component base model as returned by
113 // S3DCACHE->Load() may be added to these IFSG_TRANSFORM nodes via 'AddRefNode()';
114 // set the offset, rotation, etc of the IFSG_TRANSFORM node to ensure correct
115 // 5. Ensure that all new IFSG_TRANSFORM nodes are placed as child nodes within a
116 // top level IFSG_TRANSFORM node in preparation for final node naming and output
117 // 6. Invoke RenameNodes() on the top level assembly node
118 // 7. Invoke WriteVRML() as normal, with renameNodes = false, to write the entire assembly
119 // structure to a single VRML file
120 // 8. Clean up by deleting any extra IFSG_TRANSFORM wrappers and their underlying SG*
121 // classes which have been created solely for the assembly output
122
129 SGLIB_API void ResetNodeIndex( SGNODE* aNode );
130
138 SGLIB_API void RenameNodes( SGNODE* aNode );
139
146 SGLIB_API void DestroyNode( SGNODE* aNode ) noexcept;
147
148 // NOTE: The following functions facilitate the creation and destruction
149 // of data structures for rendering
150
159
165 SGLIB_API void Destroy3DModel( S3DMODEL** aModel );
166
172
177 SGLIB_API void Free3DMesh( SMESH& aMesh );
178
184
189 SGLIB_API void Init3DMaterial( SMATERIAL& aMat );
190
195 SGLIB_API void Init3DMesh( SMESH& aMesh );
196}
197
198#endif // IFSG_API_H
define an internal structure to be used by the 3D renders
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:45
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
#define SGLIB_API
Definition: ifsg_defs.h:56
SGLIB_API void Init3DMaterial(SMATERIAL &aMat)
Function Init3DMaterial initializes an SMATERIAL struct.
Definition: ifsg_api.cpp:435
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:141
SGLIB_API void Free3DMesh(SMESH &aMesh)
Function Free3DMesh frees memory used internally by an SMESH structure.
Definition: ifsg_api.cpp:421
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:221
SGLIB_API S3D::SGTYPES GetSGNodeType(SGNODE *aNode)
Definition: ifsg_api.cpp:485
SGLIB_API void Init3DMesh(SMESH &aMesh)
Function Init3DMesh creates and initializes an SMESH struct.
Definition: ifsg_api.cpp:441
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:157
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:77
SGLIB_API S3DMODEL * New3DModel(void)
Function New3DModel creates and initializes an S3DMODEL struct.
Definition: ifsg_api.cpp:427
SGLIB_API void ResetNodeIndex(SGNODE *aNode)
Function ResetNodeIndex resets the global SG* class indices.
Definition: ifsg_api.cpp:133
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:494
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:464
SGLIB_API void Free3DModel(S3DMODEL &aModel)
Function Free3DModel frees memory used internally by an S3DMODEL structure.
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.
Definition: ifsg_api.cpp:149
SGTYPES
Definition: sg_types.h:35
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)
Definition: ifsg_api.cpp:338
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:512
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.
Definition: ifsg_api.cpp:447
SGLIB_API void AssociateSGNodeWrapper(SGNODE *aObject, SGNODE **aRefPtr)
Definition: ifsg_api.cpp:521
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition: ifsg_api.cpp:503
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:403
defines the low level classes common to scene graph nodes
defines the types of intermediate scene graph objects
Store the a model based on meshes and materials.
Definition: c3dmodel.h:91
Per-vertex normal/color/texcoors structure.
Definition: c3dmodel.h:77