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 25 /** 26 * @file sg_faceset.h 27 */ 28 29 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 /** 44 * Define an indexed face set for a scenegraph. 45 */ 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 66 /** 67 * Add all internal coordinate indices to the given list in preparation for a normals 68 * calculation. 69 */ 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 79 SGCOLORS* m_Colors; 80 SGCOORDS* m_Coords; 81 SGCOORDINDEX* m_CoordIndices; 82 SGNORMALS* m_Normals; 83 84 // referenced objects 85 SGCOLORS* m_RColors; 86 SGCOORDS* m_RCoords; 87 SGNORMALS* m_RNormals; 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 118