0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IGESAppli / IGESAppli_ReadWriteModule.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14
15#include <IGESAppli_DrilledHole.hxx>
16#include <IGESAppli_ElementResults.hxx>
17#include <IGESAppli_FiniteElement.hxx>
18#include <IGESAppli_Flow.hxx>
19#include <IGESAppli_FlowLineSpec.hxx>
20#include <IGESAppli_LevelFunction.hxx>
21#include <IGESAppli_LevelToPWBLayerMap.hxx>
22#include <IGESAppli_LineWidening.hxx>
23#include <IGESAppli_NodalConstraint.hxx>
24#include <IGESAppli_NodalDisplAndRot.hxx>
25#include <IGESAppli_NodalResults.hxx>
26#include <IGESAppli_Node.hxx>
7fd59977 27#include <IGESAppli_PartNumber.hxx>
28#include <IGESAppli_PinNumber.hxx>
29#include <IGESAppli_PipingFlow.hxx>
42cf5bc1 30#include <IGESAppli_PWBArtworkStackup.hxx>
31#include <IGESAppli_PWBDrilledHole.hxx>
32#include <IGESAppli_ReadWriteModule.hxx>
7fd59977 33#include <IGESAppli_ReferenceDesignator.hxx>
34#include <IGESAppli_RegionRestriction.hxx>
7fd59977 35#include <IGESAppli_ToolDrilledHole.hxx>
36#include <IGESAppli_ToolElementResults.hxx>
37#include <IGESAppli_ToolFiniteElement.hxx>
38#include <IGESAppli_ToolFlow.hxx>
39#include <IGESAppli_ToolFlowLineSpec.hxx>
40#include <IGESAppli_ToolLevelFunction.hxx>
41#include <IGESAppli_ToolLevelToPWBLayerMap.hxx>
42#include <IGESAppli_ToolLineWidening.hxx>
43#include <IGESAppli_ToolNodalConstraint.hxx>
44#include <IGESAppli_ToolNodalDisplAndRot.hxx>
45#include <IGESAppli_ToolNodalResults.hxx>
46#include <IGESAppli_ToolNode.hxx>
7fd59977 47#include <IGESAppli_ToolPartNumber.hxx>
48#include <IGESAppli_ToolPinNumber.hxx>
49#include <IGESAppli_ToolPipingFlow.hxx>
42cf5bc1 50#include <IGESAppli_ToolPWBArtworkStackup.hxx>
51#include <IGESAppli_ToolPWBDrilledHole.hxx>
7fd59977 52#include <IGESAppli_ToolReferenceDesignator.hxx>
53#include <IGESAppli_ToolRegionRestriction.hxx>
42cf5bc1 54#include <IGESData_IGESEntity.hxx>
55#include <IGESData_IGESReaderData.hxx>
56#include <IGESData_IGESWriter.hxx>
57#include <IGESData_ParamReader.hxx>
58#include <Interface_Macros.hxx>
59#include <Standard_DomainError.hxx>
60#include <Standard_Type.hxx>
7fd59977 61
92efcf78 62IMPLEMENT_STANDARD_RTTIEXT(IGESAppli_ReadWriteModule,IGESData_ReadWriteModule)
63
7fd59977 64// Each Module is attached to a Protocol : it must interprete Case Numbers
65// (arguments <CN> of various methods) in accordance to values returned by
66// the method TypeNumber from this Protocol
b311480e 67IGESAppli_ReadWriteModule::IGESAppli_ReadWriteModule () { }
7fd59977 68
69
70 Standard_Integer IGESAppli_ReadWriteModule::CaseIGES
71 (const Standard_Integer typenum, const Standard_Integer formnum) const
72{
73 switch (typenum) {
74 case 134 : return 12;
75 case 136 : return 3;
76 case 138 : return 10;
77 case 146 : return 11;
78 case 148 : return 2;
79 case 402 :
80 switch (formnum) {
81 case 18 : return 4;
82 case 20 : return 17;
83 default : break;
84 }
85 break;
86 case 406 :
87 switch (formnum) {
88 case 2 : return 19;
89 case 3 : return 6;
90 case 5 : return 8;
91 case 6 : return 1;
92 case 7 : return 18;
93 case 8 : return 16;
94 case 9 : return 15;
95 case 14 : return 5;
96 case 24 : return 7;
97 case 25 : return 13;
98 case 26 : return 14;
99 default : break;
100 }
101 break;
102 case 418 : return 9;
103 default : break;
104 }
105 return 0;
106}
107
108
109 void IGESAppli_ReadWriteModule::ReadOwnParams
110 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
111 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
112{
113 switch (CN) {
114 case 1 : {
115 DeclareAndCast(IGESAppli_DrilledHole,anent,ent);
116 if (anent.IsNull()) return;
117 IGESAppli_ToolDrilledHole tool;
118 tool.ReadOwnParams(anent,IR,PR);
119 }
120 break;
121 case 2 : {
122 DeclareAndCast(IGESAppli_ElementResults,anent,ent);
123 if (anent.IsNull()) return;
124 IGESAppli_ToolElementResults tool;
125 tool.ReadOwnParams(anent,IR,PR);
126 }
127 break;
128 case 3 : {
129 DeclareAndCast(IGESAppli_FiniteElement,anent,ent);
130 if (anent.IsNull()) return;
131 IGESAppli_ToolFiniteElement tool;
132 tool.ReadOwnParams(anent,IR,PR);
133 }
134 break;
135 case 4 : {
136 DeclareAndCast(IGESAppli_Flow,anent,ent);
137 if (anent.IsNull()) return;
138 IGESAppli_ToolFlow tool;
139 tool.ReadOwnParams(anent,IR,PR);
140 }
141 break;
142 case 5 : {
143 DeclareAndCast(IGESAppli_FlowLineSpec,anent,ent);
144 if (anent.IsNull()) return;
145 IGESAppli_ToolFlowLineSpec tool;
146 tool.ReadOwnParams(anent,IR,PR);
147 }
148 break;
149 case 6 : {
150 DeclareAndCast(IGESAppli_LevelFunction,anent,ent);
151 if (anent.IsNull()) return;
152 IGESAppli_ToolLevelFunction tool;
153 tool.ReadOwnParams(anent,IR,PR);
154 }
155 break;
156 case 7 : {
157 DeclareAndCast(IGESAppli_LevelToPWBLayerMap,anent,ent);
158 if (anent.IsNull()) return;
159 IGESAppli_ToolLevelToPWBLayerMap tool;
160 tool.ReadOwnParams(anent,IR,PR);
161 }
162 break;
163 case 8 : {
164 DeclareAndCast(IGESAppli_LineWidening,anent,ent);
165 if (anent.IsNull()) return;
166 IGESAppli_ToolLineWidening tool;
167 tool.ReadOwnParams(anent,IR,PR);
168 }
169 break;
170 case 9 : {
171 DeclareAndCast(IGESAppli_NodalConstraint,anent,ent);
172 if (anent.IsNull()) return;
173 IGESAppli_ToolNodalConstraint tool;
174 tool.ReadOwnParams(anent,IR,PR);
175 }
176 break;
177 case 10 : {
178 DeclareAndCast(IGESAppli_NodalDisplAndRot,anent,ent);
179 if (anent.IsNull()) return;
180 IGESAppli_ToolNodalDisplAndRot tool;
181 tool.ReadOwnParams(anent,IR,PR);
182 }
183 break;
184 case 11 : {
185 DeclareAndCast(IGESAppli_NodalResults,anent,ent);
186 if (anent.IsNull()) return;
187 IGESAppli_ToolNodalResults tool;
188 tool.ReadOwnParams(anent,IR,PR);
189 }
190 break;
191 case 12 : {
192 DeclareAndCast(IGESAppli_Node,anent,ent);
193 if (anent.IsNull()) return;
194 IGESAppli_ToolNode tool;
195 tool.ReadOwnParams(anent,IR,PR);
196 }
197 break;
198 case 13 : {
199 DeclareAndCast(IGESAppli_PWBArtworkStackup,anent,ent);
200 if (anent.IsNull()) return;
201 IGESAppli_ToolPWBArtworkStackup tool;
202 tool.ReadOwnParams(anent,IR,PR);
203 }
204 break;
205 case 14 : {
206 DeclareAndCast(IGESAppli_PWBDrilledHole,anent,ent);
207 if (anent.IsNull()) return;
208 IGESAppli_ToolPWBDrilledHole tool;
209 tool.ReadOwnParams(anent,IR,PR);
210 }
211 break;
212 case 15 : {
213 DeclareAndCast(IGESAppli_PartNumber,anent,ent);
214 if (anent.IsNull()) return;
215 IGESAppli_ToolPartNumber tool;
216 tool.ReadOwnParams(anent,IR,PR);
217 }
218 break;
219 case 16 : {
220 DeclareAndCast(IGESAppli_PinNumber,anent,ent);
221 if (anent.IsNull()) return;
222 IGESAppli_ToolPinNumber tool;
223 tool.ReadOwnParams(anent,IR,PR);
224 }
225 break;
226 case 17 : {
227 DeclareAndCast(IGESAppli_PipingFlow,anent,ent);
228 if (anent.IsNull()) return;
229 IGESAppli_ToolPipingFlow tool;
230 tool.ReadOwnParams(anent,IR,PR);
231 }
232 break;
233 case 18 : {
234 DeclareAndCast(IGESAppli_ReferenceDesignator,anent,ent);
235 if (anent.IsNull()) return;
236 IGESAppli_ToolReferenceDesignator tool;
237 tool.ReadOwnParams(anent,IR,PR);
238 }
239 break;
240 case 19 : {
241 DeclareAndCast(IGESAppli_RegionRestriction,anent,ent);
242 if (anent.IsNull()) return;
243 IGESAppli_ToolRegionRestriction tool;
244 tool.ReadOwnParams(anent,IR,PR);
245 }
246 break;
247 default : break;
248 }
249}
250
251
252 void IGESAppli_ReadWriteModule::WriteOwnParams
253 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
254 IGESData_IGESWriter& IW) const
255{
256 switch (CN) {
257 case 1 : {
258 DeclareAndCast(IGESAppli_DrilledHole,anent,ent);
259 if (anent.IsNull()) return;
260 IGESAppli_ToolDrilledHole tool;
261 tool.WriteOwnParams(anent,IW);
262 }
263 break;
264 case 2 : {
265 DeclareAndCast(IGESAppli_ElementResults,anent,ent);
266 if (anent.IsNull()) return;
267 IGESAppli_ToolElementResults tool;
268 tool.WriteOwnParams(anent,IW);
269 }
270 break;
271 case 3 : {
272 DeclareAndCast(IGESAppli_FiniteElement,anent,ent);
273 if (anent.IsNull()) return;
274 IGESAppli_ToolFiniteElement tool;
275 tool.WriteOwnParams(anent,IW);
276 }
277 break;
278 case 4 : {
279 DeclareAndCast(IGESAppli_Flow,anent,ent);
280 if (anent.IsNull()) return;
281 IGESAppli_ToolFlow tool;
282 tool.WriteOwnParams(anent,IW);
283 }
284 break;
285 case 5 : {
286 DeclareAndCast(IGESAppli_FlowLineSpec,anent,ent);
287 if (anent.IsNull()) return;
288 IGESAppli_ToolFlowLineSpec tool;
289 tool.WriteOwnParams(anent,IW);
290 }
291 break;
292 case 6 : {
293 DeclareAndCast(IGESAppli_LevelFunction,anent,ent);
294 if (anent.IsNull()) return;
295 IGESAppli_ToolLevelFunction tool;
296 tool.WriteOwnParams(anent,IW);
297 }
298 break;
299 case 7 : {
300 DeclareAndCast(IGESAppli_LevelToPWBLayerMap,anent,ent);
301 if (anent.IsNull()) return;
302 IGESAppli_ToolLevelToPWBLayerMap tool;
303 tool.WriteOwnParams(anent,IW);
304 }
305 break;
306 case 8 : {
307 DeclareAndCast(IGESAppli_LineWidening,anent,ent);
308 if (anent.IsNull()) return;
309 IGESAppli_ToolLineWidening tool;
310 tool.WriteOwnParams(anent,IW);
311 }
312 break;
313 case 9 : {
314 DeclareAndCast(IGESAppli_NodalConstraint,anent,ent);
315 if (anent.IsNull()) return;
316 IGESAppli_ToolNodalConstraint tool;
317 tool.WriteOwnParams(anent,IW);
318 }
319 break;
320 case 10 : {
321 DeclareAndCast(IGESAppli_NodalDisplAndRot,anent,ent);
322 if (anent.IsNull()) return;
323 IGESAppli_ToolNodalDisplAndRot tool;
324 tool.WriteOwnParams(anent,IW);
325 }
326 break;
327 case 11 : {
328 DeclareAndCast(IGESAppli_NodalResults,anent,ent);
329 if (anent.IsNull()) return;
330 IGESAppli_ToolNodalResults tool;
331 tool.WriteOwnParams(anent,IW);
332 }
333 break;
334 case 12 : {
335 DeclareAndCast(IGESAppli_Node,anent,ent);
336 if (anent.IsNull()) return;
337 IGESAppli_ToolNode tool;
338 tool.WriteOwnParams(anent,IW);
339 }
340 break;
341 case 13 : {
342 DeclareAndCast(IGESAppli_PWBArtworkStackup,anent,ent);
343 if (anent.IsNull()) return;
344 IGESAppli_ToolPWBArtworkStackup tool;
345 tool.WriteOwnParams(anent,IW);
346 }
347 break;
348 case 14 : {
349 DeclareAndCast(IGESAppli_PWBDrilledHole,anent,ent);
350 if (anent.IsNull()) return;
351 IGESAppli_ToolPWBDrilledHole tool;
352 tool.WriteOwnParams(anent,IW);
353 }
354 break;
355 case 15 : {
356 DeclareAndCast(IGESAppli_PartNumber,anent,ent);
357 if (anent.IsNull()) return;
358 IGESAppli_ToolPartNumber tool;
359 tool.WriteOwnParams(anent,IW);
360 }
361 break;
362 case 16 : {
363 DeclareAndCast(IGESAppli_PinNumber,anent,ent);
364 if (anent.IsNull()) return;
365 IGESAppli_ToolPinNumber tool;
366 tool.WriteOwnParams(anent,IW);
367 }
368 break;
369 case 17 : {
370 DeclareAndCast(IGESAppli_PipingFlow,anent,ent);
371 if (anent.IsNull()) return;
372 IGESAppli_ToolPipingFlow tool;
373 tool.WriteOwnParams(anent,IW);
374 }
375 break;
376 case 18 : {
377 DeclareAndCast(IGESAppli_ReferenceDesignator,anent,ent);
378 if (anent.IsNull()) return;
379 IGESAppli_ToolReferenceDesignator tool;
380 tool.WriteOwnParams(anent,IW);
381 }
382 break;
383 case 19 : {
384 DeclareAndCast(IGESAppli_RegionRestriction,anent,ent);
385 if (anent.IsNull()) return;
386 IGESAppli_ToolRegionRestriction tool;
387 tool.WriteOwnParams(anent,IW);
388 }
389 break;
390 default : break;
391 }
392}