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 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#ifndef IFSG_API_H
31#define IFSG_API_H
32
36
37class SGNODE;
38class SCENEGRAPH;
39struct S3D_POINT;
40
41namespace S3D
42{
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
59 SGLIB_API SGVECTOR CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT& p3 );
60
69 SGLIB_API bool WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
70 const char* aPluginInfo );
71
80 SGLIB_API SGNODE* ReadCache( const char* aFileName, void* aPluginMgr,
81 bool (*aTagCheck)( const char*, void* ) );
82
92 SGLIB_API bool WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
93 bool reuse, bool renameNodes );
94
95 // NOTE: The following functions are used in combination to create a VRML
96 // assembly which may use various instances of each SG* representation of a module.
97 // A typical use case would be:
98 // 1. invoke 'ResetNodeIndex()' to reset the global node name indices
99 // 2. for each model pointer provided by 'S3DCACHE->Load()', invoke 'RenameNodes()' once;
100 // this ensures that all nodes have a unique name to present to the final output file.
101 // Internally, RenameNodes() will only rename the given node and all Child subnodes;
102 // nodes which are only referenced will not be renamed. Using the pointer supplied
103 // by 'S3DCACHE->Load()' ensures that all nodes but the returned node (top node) are
104 // children of at least one node, so all nodes are given unique names.
105 // 3. if SG* trees are created independently of S3DCACHE->Load() the user must invoke
106 // RenameNodes() as appropriate to ensure that all nodes have a unique name
107 // 4. create an assembly structure by creating new IFSG_TRANSFORM nodes as appropriate
108 // for each instance of a component; the component base model as returned by
109 // S3DCACHE->Load() may be added to these IFSG_TRANSFORM nodes via 'AddRefNode()';
110 // set the offset, rotation, etc of the IFSG_TRANSFORM node to ensure correct
111 // 5. Ensure that all new IFSG_TRANSFORM nodes are placed as child nodes within a
112 // top level IFSG_TRANSFORM node in preparation for final node naming and output
113 // 6. Invoke RenameNodes() on the top level assembly node
114 // 7. Invoke WriteVRML() as normal, with renameNodes = false, to write the entire assembly
115 // structure to a single VRML file
116 // 8. Clean up by deleting any extra IFSG_TRANSFORM wrappers and their underlying SG*
117 // classes which have been created solely for the assembly output
118
124 SGLIB_API void ResetNodeIndex( SGNODE* aNode );
125
132 SGLIB_API void RenameNodes( SGNODE* aNode );
133
140 SGLIB_API void DestroyNode( SGNODE* aNode ) noexcept;
141
142 // NOTE: The following functions facilitate the creation and destruction
143 // of data structures for rendering
144
152
156 SGLIB_API void Destroy3DModel( S3DMODEL** aModel );
157
162
166 SGLIB_API void Free3DMesh( SMESH& aMesh );
167
172
176 SGLIB_API void Init3DMaterial( SMATERIAL& aMat );
177
181 SGLIB_API void Init3DMesh( SMESH& aMesh );
182}
183
184#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)
Initializes an SMATERIAL structure.
Definition: ifsg_api.cpp:435
SGLIB_API void RenameNodes(SGNODE *aNode)
Rename a node and all children nodes based on the current values of the global SG* class indices.
Definition: ifsg_api.cpp:141
SGLIB_API void Free3DMesh(SMESH &aMesh)
Free 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 *))
Read 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)
Create and initialize an SMESH structure.
Definition: ifsg_api.cpp:441
SGLIB_API bool WriteCache(const char *aFileName, bool overwrite, SGNODE *aNode, const char *aPluginInfo)
Write 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)
Write out the given node and its subnodes to a VRML2 file.
Definition: ifsg_api.cpp:77
SGLIB_API S3DMODEL * New3DModel(void)
Create and initialize an S3DMODEL structure.
Definition: ifsg_api.cpp:427
SGLIB_API void ResetNodeIndex(SGNODE *aNode)
Reset 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)
Return the normal vector of a triangle described by vertices p1, p2, p3.
Definition: ifsg_api.cpp:464
SGLIB_API void Free3DModel(S3DMODEL &aModel)
Free memory used internally by an S3DMODEL structure.
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Delete the given SG* class node.
Definition: ifsg_api.cpp:149
SGTYPES
Definition: sg_types.h:36
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Create 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
Retrieve 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)
Free memory used by an S3DMODEL structure and sets the pointer to the structure to NULL.
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:95
Per-vertex normal/color/texcoors structure.
Definition: c3dmodel.h:81