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  *
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 
29 /*
30  * Notes on deleting unsupported entities:
31  * 1. PROTO: PROTO ProtoName [parameter list] {body}
32  * the parameter list will always have '[]'. So the items
33  * to delete are: String, List, Body
34  * 2. EXTERNPROTO: EXTERNPROTO extern protoname [] MFstring
35  * delete: string, string, string, list, list
36  * 3. Unsupported node types: NodeName (Optional DEF RefName) {body}
37  * This scheme should also apply to PROTO'd node types.
38  * 4. ROUTE: ROUTE nodename1.event to nodename2.event
39  * Delete a String 3 times
40  * 5. Script: Script { ... }
41  */
42 
43 #ifndef VRML2_BASE_H
44 #define VRML2_BASE_H
45 
46 #include <list>
47 #include <string>
48 #include <map>
49 
50 #include "vrml2_node.h"
51 
52 class SGNODE;
53 class WRL2INLINE;
54 
59 class WRL2BASE : public WRL2NODE
60 {
61 private:
63  std::string m_dir; // parent directory of the file
64 
65  // handle cases of USE / DEF
66  bool implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
67  bool implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
68 
69  bool readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
70  bool readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
71  bool readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
72  bool readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
73  bool readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
74  bool readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
75  bool readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
76  bool readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
77  bool readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
78  bool readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
79  bool readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
80  bool readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
81  bool readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
82 
83  std::map< std::string, SGNODE* > m_inlineModels;
84 
85 public:
86 
87  // functions inherited from WRL2NODE
88  bool isDangling( void ) override;
89 
90 public:
91  WRL2BASE();
92  virtual ~WRL2BASE();
93 
94  // function to enable/disable Inline{} expansion
95  void SetEnableInline( bool enable );
96  bool GetEnableInline( void );
97 
98  // functions to manipulate Inline{} objects
99  SGNODE* GetInlineData( const std::string& aName );
100 
101  // function to read entire VRML file
102  bool Read( WRLPROC& proc );
103 
104  // read in a VRML node
105  bool ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode );
106 
107  // overrides
108  virtual std::string GetName( void ) override;
109  virtual bool SetName( const std::string& aName ) override;
110 
111  // functions inherited from WRL2NODE
112  bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) override;
113  bool SetParent( WRL2NODE* aParent, bool doUnlink = true ) override;
114  SGNODE* TranslateToSG( SGNODE* aParent ) override;
115 };
116 
117 #endif // VRML2_BASE_H
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:303
WRL2NODE represents the base class of all VRML2 nodes.
Definition: vrml2_node.h:58
virtual ~WRL2BASE()
Definition: vrml2_base.cpp:58
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:884
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:924
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:964
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc)
Definition: vrml2_base.cpp:193
SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:904
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:371
SGNODE * GetInlineData(const std::string &aName)
Definition: vrml2_base.cpp:109
bool isDangling(void) override
Function isDangling returns true if the object does not have a parent which is a logical container fo...
Definition: vrml2_base.cpp:221
void SetEnableInline(bool enable)
Definition: vrml2_base.cpp:96
bool GetEnableInline(void)
Definition: vrml2_base.cpp:103
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:944
std::map< std::string, SGNODE * > m_inlineModels
Definition: vrml2_base.h:83
WRL2BASE represents the top node of a VRML2 model.
Definition: vrml2_base.h:59
virtual bool SetName(const std::string &aName) override
Definition: vrml2_base.cpp:178
bool m_useInline
Definition: vrml2_base.h:62
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:864
virtual std::string GetName(void) override
Definition: vrml2_base.cpp:163
bool SetParent(WRL2NODE *aParent, bool doUnlink=true) override
Function SetParent sets the parent WRL2NODE of this object.
Definition: vrml2_base.cpp:81
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:984
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
std::string m_dir
Definition: vrml2_base.h:63
WRL2INLINE.
Definition: vrml2_inline.h:40
SGNODE * TranslateToSG(SGNODE *aParent) override
Function TranslateToSG produces a representation of the data using the intermediate scenegraph struct...
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
Definition: vrml2_base.cpp:228