KiCad PCB EDA Suite
sg_faceset.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  *
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 
30 #ifndef SG_FACESET_H
31 #define SG_FACESET_H
32 
33 #include <vector>
34 #include "3d_cache/sg/sg_node.h"
35 
36 
37 class SGCOLORS;
38 class SGCOORDS;
39 class SGNORMALS;
40 class SGCOLORINDEX;
41 class SGCOORDINDEX;
42 
43 class SGFACESET : public SGNODE
44 {
45 private:
46  bool valid;
47  bool validated;
48  void unlinkNode( const SGNODE* aNode, bool isChild );
49  bool addNode( SGNODE* aNode, bool isChild );
50 
51 public:
52  // owned objects
57 
58  // referenced objects
62 
63  void unlinkChildNode( const SGNODE* aNode ) override;
64  void unlinkRefNode( const SGNODE* aNode ) override;
65  // validate the data held by this face set
66  bool validate( void );
67 
68 public:
69  SGFACESET( SGNODE* aParent );
70  virtual ~SGFACESET();
71 
72  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
73 
74  SGNODE* FindNode( const char *aNodeName, const SGNODE *aCaller ) override;
75  bool AddRefNode( SGNODE* aNode ) override;
76  bool AddChildNode( SGNODE* aNode ) override;
77 
78  bool CalcNormals( SGNODE** aPtr );
79 
80  void ReNameNodes( void ) override;
81  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
82 
83  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
84  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
85 
91  void GatherCoordIndices( std::vector< int >& aIndexList );
92 };
93 
94 /*
95  p.88
96  IndexedFaceSet {
97  color NULL
98  coord NULL
99  normal NULL
100  texCoord NULL
101  ccw TRUE
102  colorIndex []
103  colorPerVertex TRUE
104  convex TRUE
105  coordIndex []
106  creaseAngle 0
107  normalIndex []
108  normalPerVertex TRUE
109  solid TRUE
110  texCoordIndex []
111  }
112 */
113 
114 #endif // SG_FACESET_H
SGCOORDINDEX * m_CoordIndices
Definition: sg_faceset.h:55
bool CalcNormals(SGNODE **aPtr)
virtual ~SGFACESET()
Definition: sg_faceset.cpp:70
Class SGCOORDINDEX is a class which maintains a coordinate index list.
Definition: sg_coordindex.h:44
SGFACESET(SGNODE *aParent)
Definition: sg_faceset.cpp:36
bool validated
Definition: sg_faceset.h:47
SGCOLORS * m_Colors
Definition: sg_faceset.h:53
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: sg_faceset.cpp:541
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
bool valid
Definition: sg_faceset.h:46
SGCOLORS * m_RColors
Definition: sg_faceset.h:59
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Function ReadCache Reads binary format data from a cache file.
Definition: sg_faceset.cpp:673
void unlinkNode(const SGNODE *aNode, bool isChild)
Definition: sg_faceset.cpp:204
void ReNameNodes(void) override
Function ReNameNodes renames a node and all its child nodes in preparation for Write() operations...
Definition: sg_faceset.cpp:458
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: sg_faceset.cpp:154
SGCOORDS * m_RCoords
Definition: sg_faceset.h:60
bool validate(void)
Definition: sg_faceset.cpp:987
bool AddChildNode(SGNODE *aNode) override
Definition: sg_faceset.cpp:452
bool AddRefNode(SGNODE *aNode) override
Definition: sg_faceset.cpp:446
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Function SetParent sets the parent SGNODE of this object.
Definition: sg_faceset.cpp:124
bool addNode(SGNODE *aNode, bool isChild)
Definition: sg_faceset.cpp:290
SGCOORDS * m_Coords
Definition: sg_faceset.h:54
void unlinkChildNode(const SGNODE *aNode) override
Function unlinkChild removes references to an owned child; it is invoked by the child upon destructio...
Definition: sg_faceset.cpp:275
void GatherCoordIndices(std::vector< int > &aIndexList)
Function GatherCoordIndices adds all internal coordinate indices to the given list in preparation for...
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: sg_faceset.cpp:485
void unlinkRefNode(const SGNODE *aNode) override
Function unlinkRef removes pointers to a referenced node; it is invoked by the referenced node upon d...
Definition: sg_faceset.cpp:282
SGNORMALS * m_Normals
Definition: sg_faceset.h:56
SGNORMALS * m_RNormals
Definition: sg_faceset.h:61