0027104: DownCast() cannot return null for mismatched handle
[occt.git] / src / IGESAppli / IGESAppli_SpecificModule.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>
7fd59977 32#include <IGESAppli_ReferenceDesignator.hxx>
33#include <IGESAppli_RegionRestriction.hxx>
42cf5bc1 34#include <IGESAppli_SpecificModule.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_IGESDumper.hxx>
55#include <IGESData_IGESEntity.hxx>
56#include <Interface_Macros.hxx>
57#include <Message_Messenger.hxx>
58#include <Standard_Type.hxx>
7fd59977 59
92efcf78 60IMPLEMENT_STANDARD_RTTIEXT(IGESAppli_SpecificModule,IGESData_SpecificModule)
61
7fd59977 62// Each Module is attached to a Protocol : it must interprete Case Numbers
63// (arguments <CN> of various methods) in accordance to values returned by
64// the method TypeNumber from this Protocol
b311480e 65IGESAppli_SpecificModule::IGESAppli_SpecificModule() { }
7fd59977 66
67
68 void IGESAppli_SpecificModule::OwnDump
69 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
70 const IGESData_IGESDumper& dumper, const Handle(Message_Messenger)& S,
71 const Standard_Integer own) const
72{
73 switch (CN) {
74 case 1 : {
75 DeclareAndCast(IGESAppli_DrilledHole,anent,ent);
76 if (anent.IsNull()) return;
77 IGESAppli_ToolDrilledHole tool;
78 tool.OwnDump(anent,dumper,S,own);
79 }
80 break;
81 case 2 : {
82 DeclareAndCast(IGESAppli_ElementResults,anent,ent);
83 if (anent.IsNull()) return;
84 IGESAppli_ToolElementResults tool;
85 tool.OwnDump(anent,dumper,S,own);
86 }
87 break;
88 case 3 : {
89 DeclareAndCast(IGESAppli_FiniteElement,anent,ent);
90 if (anent.IsNull()) return;
91 IGESAppli_ToolFiniteElement tool;
92 tool.OwnDump(anent,dumper,S,own);
93 }
94 break;
95 case 4 : {
96 DeclareAndCast(IGESAppli_Flow,anent,ent);
97 if (anent.IsNull()) return;
98 IGESAppli_ToolFlow tool;
99 tool.OwnDump(anent,dumper,S,own);
100 }
101 break;
102 case 5 : {
103 DeclareAndCast(IGESAppli_FlowLineSpec,anent,ent);
104 if (anent.IsNull()) return;
105 IGESAppli_ToolFlowLineSpec tool;
106 tool.OwnDump(anent,dumper,S,own);
107 }
108 break;
109 case 6 : {
110 DeclareAndCast(IGESAppli_LevelFunction,anent,ent);
111 if (anent.IsNull()) return;
112 IGESAppli_ToolLevelFunction tool;
113 tool.OwnDump(anent,dumper,S,own);
114 }
115 break;
116 case 7 : {
117 DeclareAndCast(IGESAppli_LevelToPWBLayerMap,anent,ent);
118 if (anent.IsNull()) return;
119 IGESAppli_ToolLevelToPWBLayerMap tool;
120 tool.OwnDump(anent,dumper,S,own);
121 }
122 break;
123 case 8 : {
124 DeclareAndCast(IGESAppli_LineWidening,anent,ent);
125 if (anent.IsNull()) return;
126 IGESAppli_ToolLineWidening tool;
127 tool.OwnDump(anent,dumper,S,own);
128 }
129 break;
130 case 9 : {
131 DeclareAndCast(IGESAppli_NodalConstraint,anent,ent) ;
132 if (anent.IsNull()) return;
133 IGESAppli_ToolNodalConstraint tool;
134 tool.OwnDump(anent,dumper,S,own);
135 }
136 break;
137 case 10 : {
138 DeclareAndCast(IGESAppli_NodalDisplAndRot,anent,ent);
139 if (anent.IsNull()) return;
140 IGESAppli_ToolNodalDisplAndRot tool;
141 tool.OwnDump(anent,dumper,S,own);
142 }
143 break;
144 case 11 : {
145 DeclareAndCast(IGESAppli_NodalResults,anent,ent);
146 if (anent.IsNull()) return;
147 IGESAppli_ToolNodalResults tool;
148 tool.OwnDump(anent,dumper,S,own);
149 }
150 break;
151 case 12 : {
152 DeclareAndCast(IGESAppli_Node,anent,ent);
153 if (anent.IsNull()) return;
154 IGESAppli_ToolNode tool;
155 tool.OwnDump(anent,dumper,S,own);
156 }
157 break;
158 case 13 : {
159 DeclareAndCast(IGESAppli_PWBArtworkStackup,anent,ent);
160 if (anent.IsNull()) return;
161 IGESAppli_ToolPWBArtworkStackup tool;
162 tool.OwnDump(anent,dumper,S,own);
163 }
164 break;
165 case 14 : {
166 DeclareAndCast(IGESAppli_PWBDrilledHole,anent,ent);
167 if (anent.IsNull()) return;
168 IGESAppli_ToolPWBDrilledHole tool;
169 tool.OwnDump(anent,dumper,S,own);
170 }
171 break;
172 case 15 : {
173 DeclareAndCast(IGESAppli_PartNumber,anent,ent);
174 if (anent.IsNull()) return;
175 IGESAppli_ToolPartNumber tool;
176 tool.OwnDump(anent,dumper,S,own);
177 }
178 break;
179 case 16 : {
180 DeclareAndCast(IGESAppli_PinNumber,anent,ent);
181 if (anent.IsNull()) return;
182 IGESAppli_ToolPinNumber tool;
183 tool.OwnDump(anent,dumper,S,own);
184 }
185 break;
186 case 17 : {
187 DeclareAndCast(IGESAppli_PipingFlow,anent,ent);
188 if (anent.IsNull()) return;
189 IGESAppli_ToolPipingFlow tool;
190 tool.OwnDump(anent,dumper,S,own);
191 }
192 break;
193 case 18 : {
194 DeclareAndCast(IGESAppli_ReferenceDesignator,anent,ent);
195 if (anent.IsNull()) return;
196 IGESAppli_ToolReferenceDesignator tool;
197 tool.OwnDump(anent,dumper,S,own);
198 }
199 break;
200 case 19 : {
201 DeclareAndCast(IGESAppli_RegionRestriction,anent,ent);
202 if (anent.IsNull()) return;
203 IGESAppli_ToolRegionRestriction tool;
204 tool.OwnDump(anent,dumper,S,own);
205 }
206 break;
207 default : break;
208 }
209}
210
211
212 Standard_Boolean IGESAppli_SpecificModule::OwnCorrect
213 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent) const
214{
215// Applies only on some types
216 switch (CN) {
217 case 1 : {
218 DeclareAndCast(IGESAppli_DrilledHole,anent,ent);
219 if (anent.IsNull()) break;
220 IGESAppli_ToolDrilledHole tool;
221 return tool.OwnCorrect(anent);
222 }
223 case 4 : {
224 DeclareAndCast(IGESAppli_Flow,anent,ent);
225 if (anent.IsNull()) break;
226 IGESAppli_ToolFlow tool;
227 return tool.OwnCorrect(anent);
228 }
229 case 6 : {
230 DeclareAndCast(IGESAppli_LevelFunction,anent,ent);
231 if (anent.IsNull()) break;
232 IGESAppli_ToolLevelFunction tool;
233 return tool.OwnCorrect(anent);
234 }
235 case 8 : {
236 DeclareAndCast(IGESAppli_LineWidening,anent,ent);
237 if (anent.IsNull()) break;
238 IGESAppli_ToolLineWidening tool;
239 return tool.OwnCorrect(anent);
240 }
241 case 14 : {
242 DeclareAndCast(IGESAppli_PWBDrilledHole,anent,ent);
243 if (anent.IsNull()) break;
244 IGESAppli_ToolPWBDrilledHole tool;
245 return tool.OwnCorrect(anent);
246 }
247 case 15 : {
248 DeclareAndCast(IGESAppli_PartNumber,anent,ent);
249 if (anent.IsNull()) break;
250 IGESAppli_ToolPartNumber tool;
251 return tool.OwnCorrect(anent);
252 }
253 case 16 : {
254 DeclareAndCast(IGESAppli_PinNumber,anent,ent);
255 if (anent.IsNull()) break;
256 IGESAppli_ToolPinNumber tool;
257 return tool.OwnCorrect(anent);
258 }
259 case 17 : {
260 DeclareAndCast(IGESAppli_PipingFlow,anent,ent);
261 if (anent.IsNull()) break;
262 IGESAppli_ToolPipingFlow tool;
263 return tool.OwnCorrect(anent);
264 }
265 case 18 : {
266 DeclareAndCast(IGESAppli_ReferenceDesignator,anent,ent);
267 if (anent.IsNull()) break;
268 IGESAppli_ToolReferenceDesignator tool;
269 return tool.OwnCorrect(anent);
270 }
271 case 19 : {
272 DeclareAndCast(IGESAppli_RegionRestriction,anent,ent);
273 if (anent.IsNull()) break;
274 IGESAppli_ToolRegionRestriction tool;
275 return tool.OwnCorrect(anent);
276 }
277 default : break;
278 }
279 return Standard_False;
280}