KiCad PCB EDA Suite
sg_shape.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-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
5  * Copyright (C) 2020 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 SG_SHAPE_H
31 #define SG_SHAPE_H
32 
33 #include <vector>
34 #include "3d_cache/sg/sg_node.h"
35 
36 class SGAPPEARANCE;
37 class SGFACESET;
38 
42 class SGSHAPE : public SGNODE
43 {
44 public:
45  SGSHAPE( SGNODE* aParent );
46  virtual ~SGSHAPE();
47 
48  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
49 
50  SGNODE* FindNode(const char* aNodeName, const SGNODE* aCaller) override;
51  bool AddRefNode( SGNODE* aNode ) override;
52  bool AddChildNode( SGNODE* aNode ) override;
53 
54  void ReNameNodes( void ) override;
55  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
56 
57  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
58  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
59 
60  bool Prepare( const glm::dmat4* aTransform, S3D::MATLIST& materials,
61  std::vector< SMESH >& meshes );
62 
63  void unlinkChildNode( const SGNODE* aNode ) override;
64  void unlinkRefNode( const SGNODE* aNode ) override;
65 
66 private:
67  void unlinkNode( const SGNODE* aNode, bool isChild );
68  bool addNode( SGNODE* aNode, bool isChild );
69 
70 public:
71  // owned node
74 
75  // referenced nodes
78 };
79 
80 /*
81  p.107
82  Shape {
83  appearance NULL
84  geometry NULL
85  }
86 */
87 
88 #endif // SG_SHAPE_H
Define an indexed face set for a scenegraph.
Definition: sg_faceset.h:46
virtual ~SGSHAPE()
Definition: sg_shape.cpp:62
void unlinkChildNode(const SGNODE *aNode) override
Remove references to an owned child.
Definition: sg_shape.cpp:203
Define a complex 3D shape for a scenegraph object.
Definition: sg_shape.h:42
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
Definition: sg_shape.cpp:444
void unlinkNode(const SGNODE *aNode, bool isChild)
Definition: sg_shape.cpp:162
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
Definition: sg_shape.cpp:314
bool addNode(SGNODE *aNode, bool isChild)
Definition: sg_shape.cpp:215
SGFACESET * m_RFaceSet
Definition: sg_shape.h:77
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
bool Prepare(const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
Definition: sg_shape.cpp:594
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
Definition: sg_shape.cpp:357
SGAPPEARANCE * m_Appearance
Definition: sg_shape.h:72
bool AddRefNode(SGNODE *aNode) override
Definition: sg_shape.cpp:284
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
Definition: sg_shape.cpp:296
SGFACESET * m_FaceSet
Definition: sg_shape.h:73
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Search the tree of linked nodes and return a reference to the first node found with the given name.
Definition: sg_shape.cpp:124
SGSHAPE(SGNODE *aParent)
Definition: sg_shape.cpp:40
bool AddChildNode(SGNODE *aNode) override
Definition: sg_shape.cpp:290
SGAPPEARANCE * m_RAppearance
Definition: sg_shape.h:76
void unlinkRefNode(const SGNODE *aNode) override
Remove pointers to a referenced node.
Definition: sg_shape.cpp:209
Defines the generic material appearance of a scenegraph object.
Definition: sg_appearance.h:37
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
Definition: sg_shape.cpp:94