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, see <https://www.gnu.org/licenses/>.
19 */
20
25
26#ifndef IFSG_API_H
27#define IFSG_API_H
28
32
33class SGNODE;
34class SCENEGRAPH;
35struct S3D_POINT;
36
37namespace S3D
38{
42 SGLIB_API void GetLibVersion( unsigned char* Major, unsigned char* Minor,
43 unsigned char* Patch, unsigned char* Revision ) noexcept;
44
45 // functions to extract information from SGNODE pointers
46 SGLIB_API S3D::SGTYPES GetSGNodeType( SGNODE* aNode );
47 SGLIB_API SGNODE* GetSGNodeParent( SGNODE* aNode );
48 SGLIB_API bool AddSGNodeRef( SGNODE* aParent, SGNODE* aChild );
49 SGLIB_API bool AddSGNodeChild( SGNODE* aParent, SGNODE* aChild );
50 SGLIB_API void AssociateSGNodeWrapper( SGNODE* aObject, SGNODE** aRefPtr );
51
55 SGLIB_API SGVECTOR CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT& p3 );
56
65 SGLIB_API bool WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
66 const char* aPluginInfo );
67
76 SGLIB_API SGNODE* ReadCache( const char* aFileName, void* aPluginMgr,
77 bool (*aTagCheck)( const char*, void* ) );
78
88 SGLIB_API bool WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
89 bool reuse, bool renameNodes );
90
91 // NOTE: The following functions are used in combination to create a VRML
92 // assembly which may use various instances of each SG* representation of a module.
93 // A typical use case would be:
94 // 1. invoke 'ResetNodeIndex()' to reset the global node name indices
95 // 2. for each model pointer provided by 'S3DCACHE->Load()', invoke 'RenameNodes()' once;
96 // this ensures that all nodes have a unique name to present to the final output file.
97 // Internally, RenameNodes() will only rename the given node and all Child subnodes;
98 // nodes which are only referenced will not be renamed. Using the pointer supplied
99 // by 'S3DCACHE->Load()' ensures that all nodes but the returned node (top node) are
100 // children of at least one node, so all nodes are given unique names.
101 // 3. if SG* trees are created independently of S3DCACHE->Load() the user must invoke
102 // RenameNodes() as appropriate to ensure that all nodes have a unique name
103 // 4. create an assembly structure by creating new IFSG_TRANSFORM nodes as appropriate
104 // for each instance of a component; the component base model as returned by
105 // S3DCACHE->Load() may be added to these IFSG_TRANSFORM nodes via 'AddRefNode()';
106 // set the offset, rotation, etc of the IFSG_TRANSFORM node to ensure correct
107 // 5. Ensure that all new IFSG_TRANSFORM nodes are placed as child nodes within a
108 // top level IFSG_TRANSFORM node in preparation for final node naming and output
109 // 6. Invoke RenameNodes() on the top level assembly node
110 // 7. Invoke WriteVRML() as normal, with renameNodes = false, to write the entire assembly
111 // structure to a single VRML file
112 // 8. Clean up by deleting any extra IFSG_TRANSFORM wrappers and their underlying SG*
113 // classes which have been created solely for the assembly output
114
120 SGLIB_API void ResetNodeIndex( SGNODE* aNode );
121
128 SGLIB_API void RenameNodes( SGNODE* aNode );
129
136 SGLIB_API void DestroyNode( SGNODE* aNode ) noexcept;
137
138 // NOTE: The following functions facilitate the creation and destruction
139 // of data structures for rendering
140
147 SGLIB_API S3DMODEL* GetModel( SCENEGRAPH* aNode );
148
152 SGLIB_API void Destroy3DModel( S3DMODEL** aModel );
153
158
162 SGLIB_API void Free3DMesh( SMESH& aMesh );
163
168
172 SGLIB_API void Init3DMaterial( SMATERIAL& aMat );
173
177 SGLIB_API void Init3DMesh( SMESH& aMesh );
178}
179
180#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:41
The base class of all Scene Graph nodes.
Definition sg_node.h:71
#define SGLIB_API
Definition ifsg_defs.h:52
SGLIB_API void Init3DMaterial(SMATERIAL &aMat)
Initializes an SMATERIAL structure.
Definition ifsg_api.cpp:431
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:137
SGLIB_API void Free3DMesh(SMESH &aMesh)
Free memory used internally by an SMESH structure.
Definition ifsg_api.cpp:417
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:217
SGLIB_API S3D::SGTYPES GetSGNodeType(SGNODE *aNode)
Definition ifsg_api.cpp:481
SGLIB_API void Init3DMesh(SMESH &aMesh)
Create and initialize an SMESH structure.
Definition ifsg_api.cpp:437
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:153
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:73
SGLIB_API S3DMODEL * New3DModel(void)
Create and initialize an S3DMODEL structure.
Definition ifsg_api.cpp:423
SGLIB_API void ResetNodeIndex(SGNODE *aNode)
Reset the global SG* class indices.
Definition ifsg_api.cpp:129
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition ifsg_api.cpp:490
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:460
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:145
SGTYPES
Definition sg_types.h:32
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Create an S3DMODEL representation of aNode (raw data, no transforms).
Definition ifsg_api.cpp:334
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:508
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:443
SGLIB_API void AssociateSGNodeWrapper(SGNODE *aObject, SGNODE **aRefPtr)
Definition ifsg_api.cpp:517
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:499
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:399
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