0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IGESDefs / IGESDefs_ReadWriteModule.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IGESData_IGESEntity.hxx>
16 #include <IGESData_IGESReaderData.hxx>
17 #include <IGESData_IGESWriter.hxx>
18 #include <IGESData_ParamReader.hxx>
19 #include <IGESDefs_AssociativityDef.hxx>
20 #include <IGESDefs_AttributeDef.hxx>
21 #include <IGESDefs_AttributeTable.hxx>
22 #include <IGESDefs_GenericData.hxx>
23 #include <IGESDefs_MacroDef.hxx>
24 #include <IGESDefs_ReadWriteModule.hxx>
25 #include <IGESDefs_TabularData.hxx>
26 #include <IGESDefs_ToolAssociativityDef.hxx>
27 #include <IGESDefs_ToolAttributeDef.hxx>
28 #include <IGESDefs_ToolAttributeTable.hxx>
29 #include <IGESDefs_ToolGenericData.hxx>
30 #include <IGESDefs_ToolMacroDef.hxx>
31 #include <IGESDefs_ToolTabularData.hxx>
32 #include <IGESDefs_ToolUnitsData.hxx>
33 #include <IGESDefs_UnitsData.hxx>
34 #include <Interface_Macros.hxx>
35 #include <Standard_DomainError.hxx>
36 #include <Standard_Type.hxx>
37
38 IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_ReadWriteModule,IGESData_ReadWriteModule)
39
40 //  Each Module is attached to a Protocol : it must interprete Case Numbers
41 //  (arguments <CN> of various methods) in accordance to values returned by
42 //  the method TypeNumber from this Protocol
43 IGESDefs_ReadWriteModule::IGESDefs_ReadWriteModule ()    {  }
44
45
46     Standard_Integer  IGESDefs_ReadWriteModule::CaseIGES
47   (const Standard_Integer typenum, const Standard_Integer formnum) const 
48 {
49   switch (typenum) {
50     case 302 : return  1;
51     case 306 : return  5;
52     case 316 : return  7;
53     case 322 : return  2;
54     case 406 :
55       switch (formnum) {
56         case 11 : return  6;
57         case 27 : return  4;
58         default : break;
59       }
60       break;
61     case 422 : return  3;
62     default : break;
63   }
64   return 0;
65 }
66
67
68     void  IGESDefs_ReadWriteModule::ReadOwnParams
69   (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
70    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const 
71 {
72   switch (CN) {
73     case  1 : {
74       DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
75       if (anent.IsNull()) return;
76       IGESDefs_ToolAssociativityDef tool;
77       tool.ReadOwnParams(anent,IR,PR);
78     }
79       break;
80     case  2 : {
81       DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
82       if (anent.IsNull()) return;
83       IGESDefs_ToolAttributeDef tool;
84       tool.ReadOwnParams(anent,IR,PR);
85     }
86       break;
87     case  3 : {
88       DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
89       if (anent.IsNull()) return;
90       IGESDefs_ToolAttributeTable tool;
91       tool.ReadOwnParams(anent,IR,PR);
92     }
93       break;
94     case  4 : {
95       DeclareAndCast(IGESDefs_GenericData,anent,ent);
96       if (anent.IsNull()) return;
97       IGESDefs_ToolGenericData tool;
98       tool.ReadOwnParams(anent,IR,PR);
99     }
100       break;
101     case  5 : {
102       DeclareAndCast(IGESDefs_MacroDef,anent,ent);
103       if (anent.IsNull()) return;
104       IGESDefs_ToolMacroDef tool;
105       tool.ReadOwnParams(anent,IR,PR);
106     }
107       break;
108     case  6 : {
109       DeclareAndCast(IGESDefs_TabularData,anent,ent);
110       if (anent.IsNull()) return;
111       IGESDefs_ToolTabularData tool;
112       tool.ReadOwnParams(anent,IR,PR);
113     }
114       break;
115     case  7 : {
116       DeclareAndCast(IGESDefs_UnitsData,anent,ent);
117       if (anent.IsNull()) return;
118       IGESDefs_ToolUnitsData tool;
119       tool.ReadOwnParams(anent,IR,PR);
120     }
121       break;
122     default : break;
123   }
124 }
125
126
127     void  IGESDefs_ReadWriteModule::WriteOwnParams
128   (const Standard_Integer CN,  const Handle(IGESData_IGESEntity)& ent,
129    IGESData_IGESWriter& IW) const
130 {
131   switch (CN) {
132     case  1 : {
133       DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
134       if (anent.IsNull()) return;
135       IGESDefs_ToolAssociativityDef tool;
136       tool.WriteOwnParams(anent,IW);
137     }
138       break;
139     case  2 : {
140       DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
141       if (anent.IsNull()) return;
142       IGESDefs_ToolAttributeDef tool;
143       tool.WriteOwnParams(anent,IW);
144     }
145       break;
146     case  3 : {
147       DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
148       if (anent.IsNull()) return;
149       IGESDefs_ToolAttributeTable tool;
150       tool.WriteOwnParams(anent,IW);
151     }
152       break;
153     case  4 : {
154       DeclareAndCast(IGESDefs_GenericData,anent,ent);
155       if (anent.IsNull()) return;
156       IGESDefs_ToolGenericData tool;
157       tool.WriteOwnParams(anent,IW);
158     }
159       break;
160     case  5 : {
161       DeclareAndCast(IGESDefs_MacroDef,anent,ent);
162       if (anent.IsNull()) return;
163       IGESDefs_ToolMacroDef tool;
164       tool.WriteOwnParams(anent,IW);
165     }
166       break;
167     case  6 : {
168       DeclareAndCast(IGESDefs_TabularData,anent,ent);
169       if (anent.IsNull()) return;
170       IGESDefs_ToolTabularData tool;
171       tool.WriteOwnParams(anent,IW);
172     }
173       break;
174     case  7 : {
175       DeclareAndCast(IGESDefs_UnitsData,anent,ent);
176       if (anent.IsNull()) return;
177       IGESDefs_ToolUnitsData tool;
178       tool.WriteOwnParams(anent,IW);
179     }
180       break;
181     default : break;
182   }
183 }