KiCad PCB EDA Suite
vrml2_base.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-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
5  * Copyright (C) 2021 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 /*
31  * Notes on deleting unsupported entities:
32  * 1. PROTO: PROTO ProtoName [parameter list] {body}
33  * the parameter list will always have '[]'. So the items
34  * to delete are: String, List, Body
35  * 2. EXTERNPROTO: EXTERNPROTO extern protoname [] MFstring
36  * delete: string, string, string, list, list
37  * 3. Unsupported node types: NodeName (Optional DEF RefName) {body}
38  * This scheme should also apply to PROTO'd node types.
39  * 4. ROUTE: ROUTE nodename1.event to nodename2.event
40  * Delete a String 3 times
41  * 5. Script: Script { ... }
42  */
43 
44 #ifndef VRML2_BASE_H
45 #define VRML2_BASE_H
46 
47 #include <list>
48 #include <string>
49 #include <map>
50 
51 #include "vrml2_node.h"
52 
53 class SGNODE;
54 class WRL2INLINE;
55 
59 class WRL2BASE : public WRL2NODE
60 {
61 public:
62  WRL2BASE();
63  virtual ~WRL2BASE();
64 
65  // function to enable/disable Inline{} expansion
66  void SetEnableInline( bool enable );
67  bool GetEnableInline( void );
68 
69  // function to manipulate Inline{} objects
70  SGNODE* GetInlineData( const std::string& aName );
71 
72  // function to read entire VRML file
73  bool Read( WRLPROC& proc );
74 
75  // read in a VRML node
76  bool ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
77 
78  virtual std::string GetName( void ) override;
79  virtual bool SetName( const std::string& aName ) override;
80 
81  bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
82  bool SetParent( WRL2NODE* aParent, bool doUnlink = true ) override;
83  SGNODE* TranslateToSG( SGNODE* aParent ) override;
84 
85  bool isDangling( void ) override;
86 
87 private:
88  // handle cases of USE / DEF
89  bool implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
90  bool implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
91 
92  bool readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
93  bool readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
94  bool readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
95  bool readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
96  bool readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
97  bool readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
98  bool readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
99  bool readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
100  bool readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
101  bool readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
102  bool readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
103  bool readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
104  bool readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
105 
107  std::string m_dir; // parent directory of the file
108  std::map< std::string, SGNODE* > m_inlineModels;
109 };
110 
111 #endif // VRML2_BASE_H
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:235
virtual ~WRL2BASE()
Definition: vrml2_base.cpp:59
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:658
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:698
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:738
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:778
bool Read(WRLPROC &proc)
Definition: vrml2_base.cpp:163
The base class of all Scene Graph nodes.
Definition: sg_node.h:74
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:678
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:276
SGNODE * GetInlineData(const std::string &aName)
Definition: vrml2_base.cpp:97
bool isDangling(void) override
Determine whether an object should be moved to a different parent during the VRML to SG* translation.
Definition: vrml2_base.cpp:180
void SetEnableInline(bool enable)
Definition: vrml2_base.cpp:85
bool GetEnableInline(void)
Definition: vrml2_base.cpp:91
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:818
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:718
std::map< std::string, SGNODE * > m_inlineModels
Definition: vrml2_base.h:108
The top node of a VRML2 model.
Definition: vrml2_base.h:59
virtual bool SetName(const std::string &aName) override
Definition: vrml2_base.cpp:157
bool m_useInline
Definition: vrml2_base.h:106
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:638
virtual std::string GetName(void) override
Definition: vrml2_base.cpp:151
bool SetParent(WRL2NODE *aParent, bool doUnlink=true) override
Set the parent WRL2NODE of this object.
Definition: vrml2_base.cpp:79
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:858
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:798
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:838
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:758
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:878
std::string m_dir
Definition: vrml2_base.h:107
SGNODE * TranslateToSG(SGNODE *aParent) override
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
Definition: vrml2_base.cpp:911
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:187