KiCad PCB EDA Suite
scenegraph.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 <cirilo.bernardo@gmail.com>
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 
33 #ifndef SCENE_GRAPH_H
34 #define SCENE_GRAPH_H
35 
36 #include <vector>
37 #include "3d_cache/sg/sg_node.h"
38 
39 class SGSHAPE;
40 
41 class SCENEGRAPH : public SGNODE
42 {
43 private:
44  // The following are items which may be defined for reuse
45  // in a VRML output file. They do not necessarily correspond
46  // to the use of DEF within a VRML input file; it is the
47  // responsibility of the plugin to perform any necessary
48  // conversions to comply with the restrictions imposed by
49  // this scene graph structure
50  std::vector< SCENEGRAPH* > m_Transforms; // local Transform nodes
51  std::vector< SGSHAPE* > m_Shape; // local Shape nodes
52 
53  std::vector< SCENEGRAPH* > m_RTransforms; // referenced Transform nodes
54  std::vector< SGSHAPE* > m_RShape; // referenced Shape nodes
55 
56  void unlinkNode( const SGNODE* aNode, bool isChild );
57  bool addNode( SGNODE* aNode, bool isChild );
58 
59 public:
60  void unlinkChildNode( const SGNODE* aNode ) override;
61  void unlinkRefNode( const SGNODE* aNode ) override;
62 
63 public:
64  // note: order of transformation is Translate, Rotate, Offset
68  double rotation_angle; // radians
71  double scale_angle; // radians
72 
73  SCENEGRAPH( SGNODE* aParent );
74  virtual ~SCENEGRAPH();
75 
76  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
77  SGNODE* FindNode(const char *aNodeName, const SGNODE *aCaller) override;
78  bool AddRefNode( SGNODE* aNode ) override;
79  bool AddChildNode( SGNODE* aNode ) override;
80 
81  void ReNameNodes( void ) override;
82  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
83 
84  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
85  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
86 
87  bool Prepare( const glm::dmat4* aTransform,
88  S3D::MATLIST& materials, std::vector< SMESH >& meshes );
89 };
90 
91 /*
92  p.120
93  Transform {
94  center 0 0 0
95  children []
96  rotation 0 0 1 0
97  scale 1 1 1
98  scaleOrientation 0 0 1 0
99  translation 0 0 0
100  bboxCenter 0 0 0
101  bboxSize -1 -1 -1
102  }
103 */
104 
105 #endif // SCENE_GRAPH_H
SGVECTOR rotation_axis
Definition: scenegraph.h:67
SGPOINT center
Definition: scenegraph.h:65
void unlinkRefNode(const SGNODE *aNode) override
Function unlinkRef removes pointers to a referenced node; it is invoked by the referenced node upon d...
Definition: scenegraph.cpp:170
virtual ~SCENEGRAPH()
Definition: scenegraph.cpp:68
defines the base class of the intermediate scene graph NODE
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
SGPOINT translation
Definition: scenegraph.h:66
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
Definition: scenegraph.cpp:513
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Function WriteVRML writes this node's data to a VRML file; this includes all data of child and refere...
Definition: scenegraph.cpp:260
SGVECTOR scale_axis
Definition: scenegraph.h:70
double rotation_angle
Definition: scenegraph.h:68
std::vector< SCENEGRAPH * > m_RTransforms
Definition: scenegraph.h:53
std::vector< SGSHAPE * > m_RShape
Definition: scenegraph.h:54
std::vector< SGSHAPE * > m_Shape
Definition: scenegraph.h:51
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Function WriteCache write's this node's data to a binary cache file; the data includes all data of ch...
Definition: scenegraph.cpp:367
bool AddChildNode(SGNODE *aNode) override
Definition: scenegraph.cpp:214
double scale_angle
Definition: scenegraph.h:71
void unlinkNode(const SGNODE *aNode, bool isChild)
Definition: scenegraph.cpp:131
bool addNode(SGNODE *aNode, bool isChild)
Definition: scenegraph.cpp:177
std::vector< SCENEGRAPH * > m_Transforms
Definition: scenegraph.h:50
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations...
Definition: scenegraph.cpp:220
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
Definition: scenegraph.cpp:82
bool AddRefNode(SGNODE *aNode) override
Definition: scenegraph.cpp:208
void unlinkChildNode(const SGNODE *aNode) override
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: scenegraph.cpp:163
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) override
Function FindNode searches the tree of linked nodes and returns a reference to the first node found w...
Definition: scenegraph.cpp:112
SCENEGRAPH(SGNODE *aParent)
Definition: scenegraph.cpp:37
SGPOINT scale
Definition: scenegraph.h:69
bool Prepare(const glm::dmat4 *aTransform, S3D::MATLIST &materials, std::vector< SMESH > &meshes)
Definition: scenegraph.cpp:737