0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / IGESGeom / IGESGeom_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 <IGESGeom_Boundary.hxx>
20 #include <IGESGeom_BoundedSurface.hxx>
21 #include <IGESGeom_BSplineCurve.hxx>
22 #include <IGESGeom_BSplineSurface.hxx>
23 #include <IGESGeom_CircularArc.hxx>
24 #include <IGESGeom_CompositeCurve.hxx>
25 #include <IGESGeom_ConicArc.hxx>
26 #include <IGESGeom_CopiousData.hxx>
27 #include <IGESGeom_CurveOnSurface.hxx>
28 #include <IGESGeom_Direction.hxx>
29 #include <IGESGeom_Flash.hxx>
30 #include <IGESGeom_Line.hxx>
31 #include <IGESGeom_OffsetCurve.hxx>
32 #include <IGESGeom_OffsetSurface.hxx>
33 #include <IGESGeom_Plane.hxx>
34 #include <IGESGeom_Point.hxx>
35 #include <IGESGeom_ReadWriteModule.hxx>
36 #include <IGESGeom_RuledSurface.hxx>
37 #include <IGESGeom_SplineCurve.hxx>
38 #include <IGESGeom_SplineSurface.hxx>
39 #include <IGESGeom_SurfaceOfRevolution.hxx>
40 #include <IGESGeom_TabulatedCylinder.hxx>
41 #include <IGESGeom_ToolBoundary.hxx>
42 #include <IGESGeom_ToolBoundedSurface.hxx>
43 #include <IGESGeom_ToolBSplineCurve.hxx>
44 #include <IGESGeom_ToolBSplineSurface.hxx>
45 #include <IGESGeom_ToolCircularArc.hxx>
46 #include <IGESGeom_ToolCompositeCurve.hxx>
47 #include <IGESGeom_ToolConicArc.hxx>
48 #include <IGESGeom_ToolCopiousData.hxx>
49 #include <IGESGeom_ToolCurveOnSurface.hxx>
50 #include <IGESGeom_ToolDirection.hxx>
51 #include <IGESGeom_ToolFlash.hxx>
52 #include <IGESGeom_ToolLine.hxx>
53 #include <IGESGeom_ToolOffsetCurve.hxx>
54 #include <IGESGeom_ToolOffsetSurface.hxx>
55 #include <IGESGeom_ToolPlane.hxx>
56 #include <IGESGeom_ToolPoint.hxx>
57 #include <IGESGeom_ToolRuledSurface.hxx>
58 #include <IGESGeom_ToolSplineCurve.hxx>
59 #include <IGESGeom_ToolSplineSurface.hxx>
60 #include <IGESGeom_ToolSurfaceOfRevolution.hxx>
61 #include <IGESGeom_ToolTabulatedCylinder.hxx>
62 #include <IGESGeom_ToolTransformationMatrix.hxx>
63 #include <IGESGeom_ToolTrimmedSurface.hxx>
64 #include <IGESGeom_TransformationMatrix.hxx>
65 #include <IGESGeom_TrimmedSurface.hxx>
66 #include <Interface_Macros.hxx>
67 #include <Standard_DomainError.hxx>
68 #include <Standard_Type.hxx>
69
70 IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_ReadWriteModule,IGESData_ReadWriteModule)
71
72 //  Each Module is attached to a Protocol : it must interprete Case Numbers
73 //  (arguments <CN> of various methods) in accordance to values returned by
74 //  the method TypeNumber from this Protocol
75 IGESGeom_ReadWriteModule::IGESGeom_ReadWriteModule ()    {  }
76
77
78     Standard_Integer  IGESGeom_ReadWriteModule::CaseIGES
79   (const Standard_Integer typenum, const Standard_Integer formnum) const 
80 {
81   switch (typenum) {
82     case 100 : return  5;
83     case 102 : return  6;
84     case 104 : return  7;
85     case 106 : if (formnum < 20 || formnum > 40) return 8;
86       break;
87     case 108 : return 15;
88     case 110 : return 12;
89     case 112 : return 18;
90     case 114 : return 19;
91     case 116 : return 16;
92     case 118 : return 17;
93     case 120 : return 20;
94     case 122 : return 21;
95     case 123 : return 10;
96     case 124 : return 22;
97     case 125 : return 11;
98     case 126 : return  1;
99     case 128 : return  2;
100     case 130 : return 13;
101     case 140 : return 14;
102     case 141 : return  3;
103     case 142 : return  9;
104     case 143 : return  4;
105     case 144 : return 23;
106     default : break;
107   }
108   return 0;
109 }
110
111
112     void  IGESGeom_ReadWriteModule::ReadOwnParams
113   (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
114    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const 
115 {
116   switch (CN) {
117     case  1 : {
118       DeclareAndCast(IGESGeom_BSplineCurve,anent,ent);
119       if (anent.IsNull()) return;
120       IGESGeom_ToolBSplineCurve tool;
121       tool.ReadOwnParams(anent,IR,PR);
122     }
123       break;
124     case  2 : {
125       DeclareAndCast(IGESGeom_BSplineSurface,anent,ent);
126       if (anent.IsNull()) return;
127       IGESGeom_ToolBSplineSurface tool;
128       tool.ReadOwnParams(anent,IR,PR);
129     }
130       break;
131     case  3 : {
132       DeclareAndCast(IGESGeom_Boundary,anent,ent);
133       if (anent.IsNull()) return;
134       IGESGeom_ToolBoundary tool;
135       tool.ReadOwnParams(anent,IR,PR);
136     }
137       break;
138     case  4 : {
139       DeclareAndCast(IGESGeom_BoundedSurface,anent,ent);
140       if (anent.IsNull()) return;
141       IGESGeom_ToolBoundedSurface tool;
142       tool.ReadOwnParams(anent,IR,PR);
143     }
144       break;
145     case  5 : {
146       DeclareAndCast(IGESGeom_CircularArc,anent,ent);
147       if (anent.IsNull()) return;
148       IGESGeom_ToolCircularArc tool;
149       tool.ReadOwnParams(anent,IR,PR);
150     }
151       break;
152     case  6 : {
153       DeclareAndCast(IGESGeom_CompositeCurve,anent,ent);
154       if (anent.IsNull()) return;
155       IGESGeom_ToolCompositeCurve tool;
156       tool.ReadOwnParams(anent,IR,PR);
157     }
158       break;
159     case  7 : {
160       DeclareAndCast(IGESGeom_ConicArc,anent,ent);
161       if (anent.IsNull()) return;
162       IGESGeom_ToolConicArc tool;
163       tool.ReadOwnParams(anent,IR,PR);
164     }
165       break;
166     case  8 : {
167       DeclareAndCast(IGESGeom_CopiousData,anent,ent);
168       if (anent.IsNull()) return;
169       IGESGeom_ToolCopiousData tool;
170       tool.ReadOwnParams(anent,IR,PR);
171     }
172       break;
173     case  9 : {
174       DeclareAndCast(IGESGeom_CurveOnSurface,anent,ent);
175       if (anent.IsNull()) return;
176       IGESGeom_ToolCurveOnSurface tool;
177       tool.ReadOwnParams(anent,IR,PR);
178     }
179       break;
180     case 10 : {
181       DeclareAndCast(IGESGeom_Direction,anent,ent);
182       if (anent.IsNull()) return;
183       IGESGeom_ToolDirection tool;
184       tool.ReadOwnParams(anent,IR,PR);
185     }
186       break;
187     case 11 : {
188       DeclareAndCast(IGESGeom_Flash,anent,ent);
189       if (anent.IsNull()) return;
190       IGESGeom_ToolFlash tool;
191       tool.ReadOwnParams(anent,IR,PR);
192     }
193       break;
194     case 12 : {
195       DeclareAndCast(IGESGeom_Line,anent,ent);
196       if (anent.IsNull()) return;
197       IGESGeom_ToolLine tool;
198       tool.ReadOwnParams(anent,IR,PR);
199     }
200       break;
201     case 13 : {
202       DeclareAndCast(IGESGeom_OffsetCurve,anent,ent);
203       if (anent.IsNull()) return;
204       IGESGeom_ToolOffsetCurve tool;
205       tool.ReadOwnParams(anent,IR,PR);
206     }
207       break;
208     case 14 : {
209       DeclareAndCast(IGESGeom_OffsetSurface,anent,ent);
210       if (anent.IsNull()) return;
211       IGESGeom_ToolOffsetSurface tool;
212       tool.ReadOwnParams(anent,IR,PR);
213     }
214       break;
215     case 15 : {
216       DeclareAndCast(IGESGeom_Plane,anent,ent);
217       if (anent.IsNull()) return;
218       IGESGeom_ToolPlane tool;
219       tool.ReadOwnParams(anent,IR,PR);
220     }
221       break;
222     case 16 : {
223       DeclareAndCast(IGESGeom_Point,anent,ent);
224       if (anent.IsNull()) return;
225       IGESGeom_ToolPoint tool;
226       tool.ReadOwnParams(anent,IR,PR);
227     }
228       break;
229     case 17 : {
230       DeclareAndCast(IGESGeom_RuledSurface,anent,ent);
231       if (anent.IsNull()) return;
232       IGESGeom_ToolRuledSurface tool;
233       tool.ReadOwnParams(anent,IR,PR);
234     }
235       break;
236     case 18 : {
237       DeclareAndCast(IGESGeom_SplineCurve,anent,ent);
238       if (anent.IsNull()) return;
239       IGESGeom_ToolSplineCurve tool;
240       tool.ReadOwnParams(anent,IR,PR);
241     }
242       break;
243     case 19 : {
244       DeclareAndCast(IGESGeom_SplineSurface,anent,ent);
245       if (anent.IsNull()) return;
246       IGESGeom_ToolSplineSurface tool;
247       tool.ReadOwnParams(anent,IR,PR);
248     }
249       break;
250     case 20 : {
251       DeclareAndCast(IGESGeom_SurfaceOfRevolution,anent,ent);
252       if (anent.IsNull()) return;
253       IGESGeom_ToolSurfaceOfRevolution tool;
254       tool.ReadOwnParams(anent,IR,PR);
255     }
256       break;
257     case 21 : {
258       DeclareAndCast(IGESGeom_TabulatedCylinder,anent,ent);
259       if (anent.IsNull()) return;
260       IGESGeom_ToolTabulatedCylinder tool;
261       tool.ReadOwnParams(anent,IR,PR);
262     }
263       break;
264     case 22 : {
265       DeclareAndCast(IGESGeom_TransformationMatrix,anent,ent);
266       if (anent.IsNull()) return;
267       IGESGeom_ToolTransformationMatrix tool;
268       tool.ReadOwnParams(anent,IR,PR);
269     }
270       break;
271     case 23 : {
272       DeclareAndCast(IGESGeom_TrimmedSurface,anent,ent);
273       if (anent.IsNull()) return;
274       IGESGeom_ToolTrimmedSurface tool;
275       tool.ReadOwnParams(anent,IR,PR);
276     }
277       break;
278     default : break;
279   }
280 }
281
282
283     void  IGESGeom_ReadWriteModule::WriteOwnParams
284   (const Standard_Integer CN,  const Handle(IGESData_IGESEntity)& ent,
285    IGESData_IGESWriter& IW) const
286 {
287   switch (CN) {
288     case  1 : {
289       DeclareAndCast(IGESGeom_BSplineCurve,anent,ent);
290       if (anent.IsNull()) return;
291       IGESGeom_ToolBSplineCurve tool;
292       tool.WriteOwnParams(anent,IW);
293     }
294       break;
295     case  2 : {
296       DeclareAndCast(IGESGeom_BSplineSurface,anent,ent);
297       if (anent.IsNull()) return;
298       IGESGeom_ToolBSplineSurface tool;
299       tool.WriteOwnParams(anent,IW);
300     }
301       break;
302     case  3 : {
303       DeclareAndCast(IGESGeom_Boundary,anent,ent);
304       if (anent.IsNull()) return;
305       IGESGeom_ToolBoundary tool;
306       tool.WriteOwnParams(anent,IW);
307     }
308       break;
309     case  4 : {
310       DeclareAndCast(IGESGeom_BoundedSurface,anent,ent);
311       if (anent.IsNull()) return;
312       IGESGeom_ToolBoundedSurface tool;
313       tool.WriteOwnParams(anent,IW);
314     }
315       break;
316     case  5 : {
317       DeclareAndCast(IGESGeom_CircularArc,anent,ent);
318       if (anent.IsNull()) return;
319       IGESGeom_ToolCircularArc tool;
320       tool.WriteOwnParams(anent,IW);
321     }
322       break;
323     case  6 : {
324       DeclareAndCast(IGESGeom_CompositeCurve,anent,ent);
325       if (anent.IsNull()) return;
326       IGESGeom_ToolCompositeCurve tool;
327       tool.WriteOwnParams(anent,IW);
328     }
329       break;
330     case  7 : {
331       DeclareAndCast(IGESGeom_ConicArc,anent,ent);
332       if (anent.IsNull()) return;
333       IGESGeom_ToolConicArc tool;
334       tool.WriteOwnParams(anent,IW);
335     }
336       break;
337     case  8 : {
338       DeclareAndCast(IGESGeom_CopiousData,anent,ent);
339       if (anent.IsNull()) return;
340       IGESGeom_ToolCopiousData tool;
341       tool.WriteOwnParams(anent,IW);
342     }
343       break;
344     case  9 : {
345       DeclareAndCast(IGESGeom_CurveOnSurface,anent,ent);
346       if (anent.IsNull()) return;
347       IGESGeom_ToolCurveOnSurface tool;
348       tool.WriteOwnParams(anent,IW);
349     }
350       break;
351     case 10 : {
352       DeclareAndCast(IGESGeom_Direction,anent,ent);
353       if (anent.IsNull()) return;
354       IGESGeom_ToolDirection tool;
355       tool.WriteOwnParams(anent,IW);
356     }
357       break;
358     case 11 : {
359       DeclareAndCast(IGESGeom_Flash,anent,ent);
360       if (anent.IsNull()) return;
361       IGESGeom_ToolFlash tool;
362       tool.WriteOwnParams(anent,IW);
363     }
364       break;
365     case 12 : {
366       DeclareAndCast(IGESGeom_Line,anent,ent);
367       if (anent.IsNull()) return;
368       IGESGeom_ToolLine tool;
369       tool.WriteOwnParams(anent,IW);
370     }
371       break;
372     case 13 : {
373       DeclareAndCast(IGESGeom_OffsetCurve,anent,ent);
374       if (anent.IsNull()) return;
375       IGESGeom_ToolOffsetCurve tool;
376       tool.WriteOwnParams(anent,IW);
377     }
378       break;
379     case 14 : {
380       DeclareAndCast(IGESGeom_OffsetSurface,anent,ent);
381       if (anent.IsNull()) return;
382       IGESGeom_ToolOffsetSurface tool;
383       tool.WriteOwnParams(anent,IW);
384     }
385       break;
386     case 15 : {
387       DeclareAndCast(IGESGeom_Plane,anent,ent);
388       if (anent.IsNull()) return;
389       IGESGeom_ToolPlane tool;
390       tool.WriteOwnParams(anent,IW);
391     }
392       break;
393     case 16 : {
394       DeclareAndCast(IGESGeom_Point,anent,ent);
395       if (anent.IsNull()) return;
396       IGESGeom_ToolPoint tool;
397       tool.WriteOwnParams(anent,IW);
398     }
399       break;
400     case 17 : {
401       DeclareAndCast(IGESGeom_RuledSurface,anent,ent);
402       if (anent.IsNull()) return;
403       IGESGeom_ToolRuledSurface tool;
404       tool.WriteOwnParams(anent,IW);
405     }
406       break;
407     case 18 : {
408       DeclareAndCast(IGESGeom_SplineCurve,anent,ent);
409       if (anent.IsNull()) return;
410       IGESGeom_ToolSplineCurve tool;
411       tool.WriteOwnParams(anent,IW);
412     }
413       break;
414     case 19 : {
415       DeclareAndCast(IGESGeom_SplineSurface,anent,ent);
416       if (anent.IsNull()) return;
417       IGESGeom_ToolSplineSurface tool;
418       tool.WriteOwnParams(anent,IW);
419     }
420       break;
421     case 20 : {
422       DeclareAndCast(IGESGeom_SurfaceOfRevolution,anent,ent);
423       if (anent.IsNull()) return;
424       IGESGeom_ToolSurfaceOfRevolution tool;
425       tool.WriteOwnParams(anent,IW);
426     }
427       break;
428     case 21 : {
429       DeclareAndCast(IGESGeom_TabulatedCylinder,anent,ent);
430       if (anent.IsNull()) return;
431       IGESGeom_ToolTabulatedCylinder tool;
432       tool.WriteOwnParams(anent,IW);
433     }
434       break;
435     case 22 : {
436       DeclareAndCast(IGESGeom_TransformationMatrix,anent,ent);
437       if (anent.IsNull()) return;
438       IGESGeom_ToolTransformationMatrix tool;
439       tool.WriteOwnParams(anent,IW);
440     }
441       break;
442     case 23 : {
443       DeclareAndCast(IGESGeom_TrimmedSurface,anent,ent);
444       if (anent.IsNull()) return;
445       IGESGeom_ToolTrimmedSurface tool;
446       tool.WriteOwnParams(anent,IW);
447     }
448       break;
449     default : break;
450   }
451 }