1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <IGESData_DirChecker.hxx>
16 #include <IGESData_IGESEntity.hxx>
17 #include <IGESDefs_AssociativityDef.hxx>
18 #include <IGESDefs_AttributeDef.hxx>
19 #include <IGESDefs_AttributeTable.hxx>
20 #include <IGESDefs_GeneralModule.hxx>
21 #include <IGESDefs_GenericData.hxx>
22 #include <IGESDefs_MacroDef.hxx>
23 #include <IGESDefs_TabularData.hxx>
24 #include <IGESDefs_ToolAssociativityDef.hxx>
25 #include <IGESDefs_ToolAttributeDef.hxx>
26 #include <IGESDefs_ToolAttributeTable.hxx>
27 #include <IGESDefs_ToolGenericData.hxx>
28 #include <IGESDefs_ToolMacroDef.hxx>
29 #include <IGESDefs_ToolTabularData.hxx>
30 #include <IGESDefs_ToolUnitsData.hxx>
31 #include <IGESDefs_UnitsData.hxx>
32 #include <Interface_Category.hxx>
33 #include <Interface_Check.hxx>
34 #include <Interface_CopyTool.hxx>
35 #include <Interface_EntityIterator.hxx>
36 #include <Interface_Macros.hxx>
37 #include <Interface_ShareTool.hxx>
38 #include <Standard_Transient.hxx>
39 #include <Standard_Type.hxx>
41 IMPLEMENT_STANDARD_RTTIEXT(IGESDefs_GeneralModule,IGESData_GeneralModule)
43 // Each Module is attached to a Protocol : it must interprete Case Numbers
44 // (arguments <CN> of various methods) in accordance to values returned by
45 // the method TypeNumber from this Protocol
46 IGESDefs_GeneralModule::IGESDefs_GeneralModule () { }
49 void IGESDefs_GeneralModule::OwnSharedCase
50 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
51 Interface_EntityIterator& iter) const
55 DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
56 if (anent.IsNull()) return;
57 IGESDefs_ToolAssociativityDef tool;
58 tool.OwnShared(anent,iter);
62 DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
63 if (anent.IsNull()) return;
64 IGESDefs_ToolAttributeDef tool;
65 tool.OwnShared(anent,iter);
69 DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
70 if (anent.IsNull()) return;
71 IGESDefs_ToolAttributeTable tool;
72 tool.OwnShared(anent,iter);
76 DeclareAndCast(IGESDefs_GenericData,anent,ent);
77 if (anent.IsNull()) return;
78 IGESDefs_ToolGenericData tool;
79 tool.OwnShared(anent,iter);
83 DeclareAndCast(IGESDefs_MacroDef,anent,ent);
84 if (anent.IsNull()) return;
85 IGESDefs_ToolMacroDef tool;
86 tool.OwnShared(anent,iter);
90 DeclareAndCast(IGESDefs_TabularData,anent,ent);
91 if (anent.IsNull()) return;
92 IGESDefs_ToolTabularData tool;
93 tool.OwnShared(anent,iter);
97 DeclareAndCast(IGESDefs_UnitsData,anent,ent);
98 if (anent.IsNull()) return;
99 IGESDefs_ToolUnitsData tool;
100 tool.OwnShared(anent,iter);
108 IGESData_DirChecker IGESDefs_GeneralModule::DirChecker
109 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent) const
113 DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
114 if (anent.IsNull()) break;
115 IGESDefs_ToolAssociativityDef tool;
116 return tool.DirChecker(anent);
119 DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
120 if (anent.IsNull()) break;
121 IGESDefs_ToolAttributeDef tool;
122 return tool.DirChecker(anent);
125 DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
126 if (anent.IsNull()) break;
127 IGESDefs_ToolAttributeTable tool;
128 return tool.DirChecker(anent);
131 DeclareAndCast(IGESDefs_GenericData,anent,ent);
132 if (anent.IsNull()) break;
133 IGESDefs_ToolGenericData tool;
134 return tool.DirChecker(anent);
137 DeclareAndCast(IGESDefs_MacroDef,anent,ent);
138 if (anent.IsNull()) break;
139 IGESDefs_ToolMacroDef tool;
140 return tool.DirChecker(anent);
143 DeclareAndCast(IGESDefs_TabularData,anent,ent);
144 if (anent.IsNull()) break;
145 IGESDefs_ToolTabularData tool;
146 return tool.DirChecker(anent);
149 DeclareAndCast(IGESDefs_UnitsData,anent,ent);
150 if (anent.IsNull()) break;
151 IGESDefs_ToolUnitsData tool;
152 return tool.DirChecker(anent);
156 return IGESData_DirChecker(); // by default, no specific criterium
160 void IGESDefs_GeneralModule::OwnCheckCase
161 (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
162 const Interface_ShareTool& shares, Handle(Interface_Check)& ach) const
166 DeclareAndCast(IGESDefs_AssociativityDef,anent,ent);
167 if (anent.IsNull()) return;
168 IGESDefs_ToolAssociativityDef tool;
169 tool.OwnCheck(anent,shares,ach);
173 DeclareAndCast(IGESDefs_AttributeDef,anent,ent);
174 if (anent.IsNull()) return;
175 IGESDefs_ToolAttributeDef tool;
176 tool.OwnCheck(anent,shares,ach);
180 DeclareAndCast(IGESDefs_AttributeTable,anent,ent);
181 if (anent.IsNull()) return;
182 IGESDefs_ToolAttributeTable tool;
183 tool.OwnCheck(anent,shares,ach);
187 DeclareAndCast(IGESDefs_GenericData,anent,ent);
188 if (anent.IsNull()) return;
189 IGESDefs_ToolGenericData tool;
190 tool.OwnCheck(anent,shares,ach);
194 DeclareAndCast(IGESDefs_MacroDef,anent,ent);
195 if (anent.IsNull()) return;
196 IGESDefs_ToolMacroDef tool;
197 tool.OwnCheck(anent,shares,ach);
201 DeclareAndCast(IGESDefs_TabularData,anent,ent);
202 if (anent.IsNull()) return;
203 IGESDefs_ToolTabularData tool;
204 tool.OwnCheck(anent,shares,ach);
208 DeclareAndCast(IGESDefs_UnitsData,anent,ent);
209 if (anent.IsNull()) return;
210 IGESDefs_ToolUnitsData tool;
211 tool.OwnCheck(anent,shares,ach);
219 Standard_Boolean IGESDefs_GeneralModule::NewVoid
220 (const Standard_Integer CN, Handle(Standard_Transient)& ent) const
223 case 1 : ent = new IGESDefs_AssociativityDef; break;
224 case 2 : ent = new IGESDefs_AttributeDef; break;
225 case 3 : ent = new IGESDefs_AttributeTable; break;
226 case 4 : ent = new IGESDefs_GenericData; break;
227 case 5 : ent = new IGESDefs_MacroDef; break;
228 case 6 : ent = new IGESDefs_TabularData; break;
229 case 7 : ent = new IGESDefs_UnitsData; break;
230 default : return Standard_False; // by default, Failure on Recognize
232 return Standard_True;
236 void IGESDefs_GeneralModule::OwnCopyCase
237 (const Standard_Integer CN,
238 const Handle(IGESData_IGESEntity)& entfrom,
239 const Handle(IGESData_IGESEntity)& entto,
240 Interface_CopyTool& TC) const
244 DeclareAndCast(IGESDefs_AssociativityDef,enfr,entfrom);
245 DeclareAndCast(IGESDefs_AssociativityDef,ento,entto);
246 IGESDefs_ToolAssociativityDef tool;
247 tool.OwnCopy(enfr,ento,TC);
251 DeclareAndCast(IGESDefs_AttributeDef,enfr,entfrom);
252 DeclareAndCast(IGESDefs_AttributeDef,ento,entto);
253 IGESDefs_ToolAttributeDef tool;
254 tool.OwnCopy(enfr,ento,TC);
258 DeclareAndCast(IGESDefs_AttributeTable,enfr,entfrom);
259 DeclareAndCast(IGESDefs_AttributeTable,ento,entto);
260 IGESDefs_ToolAttributeTable tool;
261 tool.OwnCopy(enfr,ento,TC);
265 DeclareAndCast(IGESDefs_GenericData,enfr,entfrom);
266 DeclareAndCast(IGESDefs_GenericData,ento,entto);
267 IGESDefs_ToolGenericData tool;
268 tool.OwnCopy(enfr,ento,TC);
272 DeclareAndCast(IGESDefs_MacroDef,enfr,entfrom);
273 DeclareAndCast(IGESDefs_MacroDef,ento,entto);
274 IGESDefs_ToolMacroDef tool;
275 tool.OwnCopy(enfr,ento,TC);
279 DeclareAndCast(IGESDefs_TabularData,enfr,entfrom);
280 DeclareAndCast(IGESDefs_TabularData,ento,entto);
281 IGESDefs_ToolTabularData tool;
282 tool.OwnCopy(enfr,ento,TC);
286 DeclareAndCast(IGESDefs_UnitsData,enfr,entfrom);
287 DeclareAndCast(IGESDefs_UnitsData,ento,entto);
288 IGESDefs_ToolUnitsData tool;
289 tool.OwnCopy(enfr,ento,TC);
297 Standard_Integer IGESDefs_GeneralModule::CategoryNumber
298 (const Standard_Integer /*CN*/, const Handle(Standard_Transient)& /*ent*/,
299 const Interface_ShareTool& ) const
301 return Interface_Category::Number("Auxiliary");