0032961: Coding - get rid of unused headers [IGESAppli to IGESToBRep]
[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_IGESReaderData.hxx>
16 #include <IGESData_IGESWriter.hxx>
17 #include <IGESData_ParamReader.hxx>
18 #include <IGESDefs_AssociativityDef.hxx>
19 #include <IGESDefs_AttributeDef.hxx>
20 #include <IGESDefs_AttributeTable.hxx>
21 #include <IGESDefs_GenericData.hxx>
22 #include <IGESDefs_MacroDef.hxx>
23 #include <IGESDefs_ReadWriteModule.hxx>
24 #include <IGESDefs_TabularData.hxx>
25 #include <IGESDefs_ToolAssociativityDef.hxx>
26 #include <IGESDefs_ToolAttributeDef.hxx>
27 #include <IGESDefs_ToolAttributeTable.hxx>
28 #include <IGESDefs_ToolGenericData.hxx>
29 #include <IGESDefs_ToolMacroDef.hxx>
30 #include <IGESDefs_ToolTabularData.hxx>
31 #include <IGESDefs_ToolUnitsData.hxx>
32 #include <IGESDefs_UnitsData.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Standard_Type.hxx>
35
36 IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_ReadWriteModule,IGESData_ReadWriteModule)
37
38 //  Each Module is attached to a Protocol : it must interpret Case Numbers
39 //  (arguments <CN> of various methods) in accordance to values returned by
40 //  the method TypeNumber from this Protocol
41 IGESDefs_ReadWriteModule::IGESDefs_ReadWriteModule ()    {  }
42
43
44     Standard_Integer  IGESDefs_ReadWriteModule::CaseIGES
45   (const Standard_Integer typenum, const Standard_Integer formnum) const 
46 {
47   switch (typenum) {
48     case 302 : return  1;
49     case 306 : return  5;
50     case 316 : return  7;
51     case 322 : return  2;
52     case 406 :
53       switch (formnum) {
54         case 11 : return  6;
55         case 27 : return  4;
56         default : break;
57       }
58       break;
59     case 422 : return  3;
60     default : break;
61   }
62   return 0;
63 }
64
65
66     void  IGESDefs_ReadWriteModule::ReadOwnParams
67   (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
68    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const 
69 {
70   switch (CN) {
71     case  1 : {
72       DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
73       if (anent.IsNull()) return;
74       IGESDefs_ToolAssociativityDef tool;
75       tool.ReadOwnParams(anent,IR,PR);
76     }
77       break;
78     case  2 : {
79       DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
80       if (anent.IsNull()) return;
81       IGESDefs_ToolAttributeDef tool;
82       tool.ReadOwnParams(anent,IR,PR);
83     }
84       break;
85     case  3 : {
86       DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
87       if (anent.IsNull()) return;
88       IGESDefs_ToolAttributeTable tool;
89       tool.ReadOwnParams(anent,IR,PR);
90     }
91       break;
92     case  4 : {
93       DeclareAndCast(IGESDefs_GenericData,anent,ent);
94       if (anent.IsNull()) return;
95       IGESDefs_ToolGenericData tool;
96       tool.ReadOwnParams(anent,IR,PR);
97     }
98       break;
99     case  5 : {
100       DeclareAndCast(IGESDefs_MacroDef,anent,ent);
101       if (anent.IsNull()) return;
102       IGESDefs_ToolMacroDef tool;
103       tool.ReadOwnParams(anent,IR,PR);
104     }
105       break;
106     case  6 : {
107       DeclareAndCast(IGESDefs_TabularData,anent,ent);
108       if (anent.IsNull()) return;
109       IGESDefs_ToolTabularData tool;
110       tool.ReadOwnParams(anent,IR,PR);
111     }
112       break;
113     case  7 : {
114       DeclareAndCast(IGESDefs_UnitsData,anent,ent);
115       if (anent.IsNull()) return;
116       IGESDefs_ToolUnitsData tool;
117       tool.ReadOwnParams(anent,IR,PR);
118     }
119       break;
120     default : break;
121   }
122 }
123
124
125     void  IGESDefs_ReadWriteModule::WriteOwnParams
126   (const Standard_Integer CN,  const Handle(IGESData_IGESEntity)& ent,
127    IGESData_IGESWriter& IW) const
128 {
129   switch (CN) {
130     case  1 : {
131       DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
132       if (anent.IsNull()) return;
133       IGESDefs_ToolAssociativityDef tool;
134       tool.WriteOwnParams(anent,IW);
135     }
136       break;
137     case  2 : {
138       DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
139       if (anent.IsNull()) return;
140       IGESDefs_ToolAttributeDef tool;
141       tool.WriteOwnParams(anent,IW);
142     }
143       break;
144     case  3 : {
145       DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
146       if (anent.IsNull()) return;
147       IGESDefs_ToolAttributeTable tool;
148       tool.WriteOwnParams(anent,IW);
149     }
150       break;
151     case  4 : {
152       DeclareAndCast(IGESDefs_GenericData,anent,ent);
153       if (anent.IsNull()) return;
154       IGESDefs_ToolGenericData tool;
155       tool.WriteOwnParams(anent,IW);
156     }
157       break;
158     case  5 : {
159       DeclareAndCast(IGESDefs_MacroDef,anent,ent);
160       if (anent.IsNull()) return;
161       IGESDefs_ToolMacroDef tool;
162       tool.WriteOwnParams(anent,IW);
163     }
164       break;
165     case  6 : {
166       DeclareAndCast(IGESDefs_TabularData,anent,ent);
167       if (anent.IsNull()) return;
168       IGESDefs_ToolTabularData tool;
169       tool.WriteOwnParams(anent,IW);
170     }
171       break;
172     case  7 : {
173       DeclareAndCast(IGESDefs_UnitsData,anent,ent);
174       if (anent.IsNull()) return;
175       IGESDefs_ToolUnitsData tool;
176       tool.WriteOwnParams(anent,IW);
177     }
178       break;
179     default : break;
180   }
181 }