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
52 SGLIB_API void LockModelImport() noexcept;
53 SGLIB_API void UnlockModelImport() noexcept;
54
67
68 // functions to extract information from SGNODE pointers
71 SGLIB_API bool AddSGNodeRef( SGNODE* aParent, SGNODE* aChild );
72 SGLIB_API bool AddSGNodeChild( SGNODE* aParent, SGNODE* aChild );
73 SGLIB_API void AssociateSGNodeWrapper( SGNODE* aObject, SGNODE** aRefPtr );
74
78 SGLIB_API SGVECTOR CalcTriNorm( const SGPOINT& p1, const SGPOINT& p2, const SGPOINT& p3 );
79
89 SGLIB_API bool WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
90 const char* aPluginInfo );
91
103 SGLIB_API SGNODE* ReadCache( const char* aFileName, void* aPluginMgr,
104 bool (*aTagCheck)( const char*, void* ) );
105
117 SGLIB_API bool WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
118 bool reuse, bool renameNodes );
119
120 // NOTE: The following functions are used in combination to create a VRML
121 // assembly which may use various instances of each SG* representation of a module.
122 // A typical use case would be:
123 // 1. invoke 'ResetNodeIndex()' to reset the global node name indices
124 // 2. for each model pointer provided by 'S3DCACHE->Load()', invoke 'RenameNodes()' once;
125 // this ensures that all nodes have a unique name to present to the final output file.
126 // Internally, RenameNodes() will only rename the given node and all Child subnodes;
127 // nodes which are only referenced will not be renamed. Using the pointer supplied
128 // by 'S3DCACHE->Load()' ensures that all nodes but the returned node (top node) are
129 // children of at least one node, so all nodes are given unique names.
130 // 3. if SG* trees are created independently of S3DCACHE->Load() the user must invoke
131 // RenameNodes() as appropriate to ensure that all nodes have a unique name
132 // 4. create an assembly structure by creating new IFSG_TRANSFORM nodes as appropriate
133 // for each instance of a component; the component base model as returned by
134 // S3DCACHE->Load() may be added to these IFSG_TRANSFORM nodes via 'AddRefNode()';
135 // set the offset, rotation, etc of the IFSG_TRANSFORM node to ensure correct
136 // 5. Ensure that all new IFSG_TRANSFORM nodes are placed as child nodes within a
137 // top level IFSG_TRANSFORM node in preparation for final node naming and output
138 // 6. Invoke RenameNodes() on the top level assembly node
139 // 7. Invoke WriteVRML() as normal, with renameNodes = false, to write the entire assembly
140 // structure to a single VRML file
141 // 8. Clean up by deleting any extra IFSG_TRANSFORM wrappers and their underlying SG*
142 // classes which have been created solely for the assembly output
143
149 SGLIB_API void ResetNodeIndex( SGNODE* aNode );
150
157 SGLIB_API void RenameNodes( SGNODE* aNode );
158
165 SGLIB_API void DestroyNode( SGNODE* aNode ) noexcept;
166
167 // NOTE: The following functions facilitate the creation and destruction
168 // of data structures for rendering
169
177
181 SGLIB_API void Destroy3DModel( S3DMODEL** aModel );
182
186 SGLIB_API void Free3DModel( S3DMODEL& aModel );
187
191 SGLIB_API void Free3DMesh( SMESH& aMesh );
192
197
201 SGLIB_API void Init3DMaterial( SMATERIAL& aMat );
202
206 SGLIB_API void Init3DMesh( SMESH& aMesh );
207} // namespace S3D
208
209#endif // IFSG_API_H
define an internal structure to be used by the 3D renders
MODEL_IMPORT_LOCK(const MODEL_IMPORT_LOCK &)=delete
MODEL_IMPORT_LOCK() noexcept
Definition ifsg_api.h:61
MODEL_IMPORT_LOCK & operator=(const MODEL_IMPORT_LOCK &)=delete
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:459
SGLIB_API void UnlockModelImport() noexcept
Definition ifsg_api.cpp:53
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:159
SGLIB_API void Free3DModel(S3DMODEL &aModel)
Free memory used internally by an S3DMODEL structure.
Definition ifsg_api.cpp:439
SGLIB_API void Free3DMesh(SMESH &aMesh)
Free memory used internally by an SMESH structure.
Definition ifsg_api.cpp:445
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:243
SGLIB_API S3D::SGTYPES GetSGNodeType(SGNODE *aNode)
Definition ifsg_api.cpp:509
SGLIB_API void Init3DMesh(SMESH &aMesh)
Create and initialize an SMESH structure.
Definition ifsg_api.cpp:465
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:177
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:91
SGLIB_API S3DMODEL * New3DModel(void)
Create and initialize an S3DMODEL structure.
Definition ifsg_api.cpp:451
SGLIB_API void ResetNodeIndex(SGNODE *aNode)
Reset the global SG* class indices.
Definition ifsg_api.cpp:149
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition ifsg_api.cpp:518
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:488
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Delete the given SG* class node.
Definition ifsg_api.cpp:169
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:362
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:536
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:471
SGLIB_API void AssociateSGNodeWrapper(SGNODE *aObject, SGNODE **aRefPtr)
Definition ifsg_api.cpp:545
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:527
SGLIB_API void LockModelImport() noexcept
Serialize parser and scene-name operations.
Definition ifsg_api.cpp:47
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:427
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:111
Per-vertex normal/color/texcoors structure.
Definition c3dmodel.h:77