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  * 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_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 
46 class SGFACESET : public SGNODE
47 {
48 public:
49  SGFACESET( SGNODE* aParent );
50  virtual ~SGFACESET();
51 
52  virtual bool SetParent( SGNODE* aParent, bool notify = true ) override;
53 
54  SGNODE* FindNode( const char* aNodeName, const SGNODE* aCaller ) override;
55  bool AddRefNode( SGNODE* aNode ) override;
56  bool AddChildNode( SGNODE* aNode ) override;
57 
58  bool CalcNormals( SGNODE** aPtr );
59 
60  void ReNameNodes( void ) override;
61  bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override;
62 
63  bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override;
64  bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override;
65 
70  void GatherCoordIndices( std::vector< int >& aIndexList );
71 
72  void unlinkChildNode( const SGNODE* aNode ) override;
73  void unlinkRefNode( const SGNODE* aNode ) override;
74 
75  // validate the data held by this face set
76  bool validate( void );
77 
78  // owned objects
83 
84  // referenced objects
88 
89 private:
90  bool valid;
91  bool validated;
92  void unlinkNode( const SGNODE* aNode, bool isChild );
93  bool addNode( SGNODE* aNode, bool isChild );
94 
95 };
96 
97 /*
98  p.88
99  IndexedFaceSet {
100  color NULL
101  coord NULL
102  normal NULL
103  texCoord NULL
104  ccw TRUE
105  colorIndex []
106  colorPerVertex TRUE
107  convex TRUE
108  coordIndex []
109  creaseAngle 0
110  normalIndex []
111  normalPerVertex TRUE
112  solid TRUE
113  texCoordIndex []
114  }
115 */
116 
117 #endif // SG_FACESET_H
Define an indexed face set for a scenegraph.
Definition: sg_faceset.h:46
Define an RGB color set for a scenegraph object.
Definition: sg_colors.h:38
SGCOORDINDEX * m_CoordIndices
Definition: sg_faceset.h:81
bool CalcNormals(SGNODE **aPtr)
Definition: sg_faceset.cpp:950
virtual ~SGFACESET()
Definition: sg_faceset.cpp:65
An object to maintain a coordinate index list.
Definition: sg_coordindex.h:42
SGFACESET(SGNODE *aParent)
Definition: sg_faceset.cpp:38
bool validated
Definition: sg_faceset.h:91
SGCOLORS * m_Colors
Definition: sg_faceset.h:79
Define a vertex coordinate set for a scenegraph object.
Definition: sg_coords.h:40
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
Definition: sg_faceset.cpp:488
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
bool valid
Definition: sg_faceset.h:90
SGCOLORS * m_RColors
Definition: sg_faceset.h:85
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
Definition: sg_faceset.cpp:595
Define a set of vertex normals for a scene graph object.
Definition: sg_normals.h:38
void unlinkNode(const SGNODE *aNode, bool isChild)
Definition: sg_faceset.cpp:197
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
Definition: sg_faceset.cpp:408
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_faceset.cpp:147
SGCOORDS * m_RCoords
Definition: sg_faceset.h:86
bool validate(void)
Definition: sg_faceset.cpp:831
bool AddChildNode(SGNODE *aNode) override
Definition: sg_faceset.cpp:402
bool AddRefNode(SGNODE *aNode) override
Definition: sg_faceset.cpp:396
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
Definition: sg_faceset.cpp:117
bool addNode(SGNODE *aNode, bool isChild)
Definition: sg_faceset.cpp:273
SGCOORDS * m_Coords
Definition: sg_faceset.h:80
void unlinkChildNode(const SGNODE *aNode) override
Remove references to an owned child.
Definition: sg_faceset.cpp:260
void GatherCoordIndices(std::vector< int > &aIndexList)
Add all internal coordinate indices to the given list in preparation for a normals calculation.
Definition: sg_faceset.cpp:943
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
Definition: sg_faceset.cpp:433
void unlinkRefNode(const SGNODE *aNode) override
Remove pointers to a referenced node.
Definition: sg_faceset.cpp:266
SGNORMALS * m_Normals
Definition: sg_faceset.h:82
SGNORMALS * m_RNormals
Definition: sg_faceset.h:87