0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / IGESDefs / IGESDefs_ToolAttributeTable.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
7fd59977 9//
b311480e 10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
7fd59977 12//
b311480e 13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
20//--------------------------------------------------------------------
7fd59977 21//--------------------------------------------------------------------
22
23#include <IGESDefs_ToolAttributeTable.ixx>
24#include <IGESData_ParamCursor.hxx>
25#include <IGESDefs_AttributeDef.hxx>
26#include <TColStd_HArray2OfTransient.hxx>
27#include <TColStd_HArray1OfReal.hxx>
28#include <TColStd_HArray1OfInteger.hxx>
29#include <Interface_HArray1OfHAsciiString.hxx>
30#include <IGESData_HArray1OfIGESEntity.hxx>
31#include <TCollection_HAsciiString.hxx>
32#include <Interface_Macros.hxx>
33#include <IGESData_Dump.hxx>
34
35
36IGESDefs_ToolAttributeTable::IGESDefs_ToolAttributeTable () { }
37
38
39void IGESDefs_ToolAttributeTable::ReadOwnParams
40 (const Handle(IGESDefs_AttributeTable)& ent,
41 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
42{
43 Standard_Integer nr = 1;
44 Standard_Integer j;
45 Standard_Boolean st = Standard_True;
46
47 Handle(IGESDefs_AttributeDef) ab = ent->Definition(); // formerly loaded
48 Handle(TColStd_HArray2OfTransient) list2;
49 if (ab.IsNull()) {
50 PR.AddFail("No Attribute Definition as Structure");
51 return;
52 }
53 Standard_Integer na = ab->NbAttributes();
54
55 if (ent->FormNumber() == 1)
56 st = PR.ReadInteger(PR.Current(),"No. of rows",nr);
57 if (st) list2 = new TColStd_HArray2OfTransient(1,na,1,nr);
58
59// AttributeDef repeated once (Form 0) or <nr> times (Form 1)
60 for (Standard_Integer k = 1; k <= nr; k ++)
61 {
62 for (Standard_Integer i = 1; i <= na; i ++)
63 {
64 Standard_Integer avc = ab->AttributeValueCount(i);
65 Standard_Integer atype = ab->AttributeValueDataType(i);
66 switch (atype)
67 {
68 case 0 :
69 for (j = 1; j <= avc; j ++)
70 PR.SetCurrentNumber(PR.CurrentNumber() + 1); // skip
71 break;
72 case 1 : {
73 Handle(TColStd_HArray1OfInteger) attrInt = new TColStd_HArray1OfInteger(1,avc);
74 list2->SetValue(i,k,attrInt);
75 Standard_Integer item;
76 for (j = 1; j <= avc; j ++) {
77 //st = PR.ReadInteger(PR.Current(),"Value",item); //szv#4:S4163:12Mar99 moved in if
78 if (PR.ReadInteger(PR.Current(),"Value",item))
79 attrInt->SetValue(j,item);
80 }
81 }
82 break;
83 case 2 : {
84 Handle(TColStd_HArray1OfReal) attrReal = new TColStd_HArray1OfReal(1,avc);
85 list2->SetValue(i,k,attrReal);
86 Standard_Real item;
87 for (j = 1; j <= avc; j ++) {
88 //st = PR.ReadReal(PR.Current(),"Value",item); //szv#4:S4163:12Mar99 moved in if
89 if (PR.ReadReal(PR.Current(),"Value",item))
90 attrReal->SetValue(j,item);
91 }
92 }
93 break;
94 case 3 : {
95 Handle(Interface_HArray1OfHAsciiString) attrStr = new Interface_HArray1OfHAsciiString(1,avc);
96 list2->SetValue(i,k,attrStr);
97 Handle(TCollection_HAsciiString) item;
98 for (j = 1; j <= avc; j ++) {
99 //st = PR.ReadText(PR.Current(),"Value",item); //szv#4:S4163:12Mar99 moved in if
100 if (PR.ReadText(PR.Current(),"Value",item))
101 attrStr->SetValue(j,item);
102 }
103 }
104 break;
105 case 4 : {
106 Handle(IGESData_HArray1OfIGESEntity) attrEnt = new IGESData_HArray1OfIGESEntity(1,avc);
107 list2->SetValue(i,k,attrEnt);
108 Handle(IGESData_IGESEntity) item;
109 for (j = 1; j <= avc; j ++) {
110 //st = PR.ReadEntity(IR,PR.Current(),"Value",item); //szv#4:S4163:12Mar99 moved in if
111 if (PR.ReadEntity(IR,PR.Current(),"Value",item))
112 attrEnt->SetValue(j,item);
113 }
114 }
115 break;
116 case 5 :
117 for (j = 1; j <= avc; j ++)
118 PR.SetCurrentNumber(PR.CurrentNumber() + 1); // skip
119 break;
120 case 6 : { // Here item takes value 0 or 1
121 Handle(TColStd_HArray1OfInteger) attrInt = new TColStd_HArray1OfInteger(1,avc);
122 list2->SetValue(i,k,attrInt);
123 Standard_Integer item;
124 for (j = 1; j <= avc; j ++) {
125 //st = PR.ReadInteger(PR.Current(),"Value",item); //szv#4:S4163:12Mar99 moved in if
126 if (PR.ReadInteger(PR.Current(),"Value",item))
127 attrInt->SetValue(j,item);
128 }
129 }
130 break;
131 default : break;
132 }
133 }
134 }
135 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
136 ent->Init(list2);
137}
138
139void IGESDefs_ToolAttributeTable::WriteOwnParams
140 (const Handle(IGESDefs_AttributeTable)& ent, IGESData_IGESWriter& IW) const
141{
142 Handle(IGESDefs_AttributeDef) ab = ent->Definition();
143
144 Standard_Integer nr = ent->NbRows();
145 Standard_Integer na = ent->NbAttributes();
146 if (ent->FormNumber() == 1) IW.Send(nr);
147 for (Standard_Integer k = 1; k <= nr; k ++)
148 {
149 for (Standard_Integer i = 1; i <= na; i ++)
150 {
151 Standard_Integer count = ab->AttributeValueCount(i);
152 for (Standard_Integer j = 1;j <= count; j++)
153 {
154 switch(ab->AttributeValueDataType(i))
155 {
156 case 0 : IW.SendVoid(); break;
157 case 1 : IW.Send(ent->AttributeAsInteger(i,k,j)); break;
158 case 2 : IW.Send(ent->AttributeAsReal (i,k,j)); break;
159 case 3 : IW.Send(ent->AttributeAsString (i,k,j)); break;
160 case 4 : IW.Send(ent->AttributeAsEntity (i,k,j)); break;
161 case 5 : IW.SendVoid(); break;
162 case 6 : IW.SendBoolean(ent->AttributeAsLogical(i,k,j)); break;
163 default : break;
164 }
165 }
166 }
167 }
168}
169
170void IGESDefs_ToolAttributeTable::OwnShared
171 (const Handle(IGESDefs_AttributeTable)& ent, Interface_EntityIterator& iter) const
172{
173 Handle(IGESDefs_AttributeDef) ab = ent->Definition();
174 Standard_Integer na = ent->NbAttributes();
175 Standard_Integer nr = ent->NbRows();
176 for (Standard_Integer k = 1; k <= nr; k ++)
177 {
178 for (Standard_Integer i = 1; i <= na; i ++)
179 {
180 if (ab->AttributeValueDataType(i) != 4) continue;
181 Standard_Integer avc = ab->AttributeValueCount(i);
182 for (Standard_Integer j = 1; j <= avc; j ++)
183 iter.GetOneItem(ent->AttributeAsEntity(i,k,j));
184 }
185 }
186}
187
188void IGESDefs_ToolAttributeTable::OwnCopy
189 (const Handle(IGESDefs_AttributeTable)& another,
190 const Handle(IGESDefs_AttributeTable)& ent, Interface_CopyTool& TC) const
191{
192 Standard_Integer j = 1;
193 Handle(IGESDefs_AttributeDef) ab = another->Definition();
194 Standard_Integer na = another->NbAttributes();
195 Standard_Integer nr = another->NbRows();
196 Handle(TColStd_HArray2OfTransient) list2 =
197 new TColStd_HArray2OfTransient(1,na,1,nr);
198 for (Standard_Integer k = 1; k <= nr; k ++)
199 {
200 for (Standard_Integer i = 1; i <= na; i ++)
201 {
202 Standard_Integer avc = ab->AttributeValueCount(i);
203 Standard_Integer atype = ab->AttributeValueDataType(i);
204 switch (atype)
205 {
206 case 0 : //// list2->SetValue(i,k,NULL); par defaut
207 break;
208 case 1 : {
209 DeclareAndCast(TColStd_HArray1OfInteger,otherInt,
210 another->AttributeList(i,k));
211 Handle(TColStd_HArray1OfInteger) attrInt =
212 new TColStd_HArray1OfInteger (1,avc);
213 list2->SetValue(i,k,attrInt);
214 for (j = 1; j <= avc; j++)
215 attrInt->SetValue(j,otherInt->Value(j));
216 }
217 break;
218 case 2 : {
219 DeclareAndCast(TColStd_HArray1OfReal,otherReal,
220 another->AttributeList(i,k));
221 Handle(TColStd_HArray1OfReal) attrReal =
222 new TColStd_HArray1OfReal (1,avc);
223 list2->SetValue(i,k,attrReal);
224 for (j = 1; j <= avc; j++)
225 attrReal->SetValue(j,otherReal->Value(j));
226 }
227 break;
228 case 3 : {
229 DeclareAndCast(Interface_HArray1OfHAsciiString,otherStr,
230 another->AttributeList(i,k));
231 Handle(Interface_HArray1OfHAsciiString) attrStr =
232 new Interface_HArray1OfHAsciiString (1,avc);
233 list2->SetValue(i,k,attrStr);
234 for (j = 1; j <= avc; j++)
235 attrStr->SetValue
236 (j,new TCollection_HAsciiString(otherStr->Value(j)));
237 }
238 break;
239 case 4 : {
240 DeclareAndCast(IGESData_HArray1OfIGESEntity,otherEnt,
241 another->AttributeList(i,k));
242 Handle(IGESData_HArray1OfIGESEntity) attrEnt =
243 new IGESData_HArray1OfIGESEntity (1,avc);
244 list2->SetValue(i,k,attrEnt);
245 for (j = 1; j <= avc; j++)
246 attrEnt->SetValue(j,GetCasted(IGESData_IGESEntity,
247 TC.Transferred(otherEnt->Value(j))));
248 }
249 break;
250 case 5 : ///// list2->SetValue(i,k,NULL); par defaut
251 break;
252 case 6 :{ // Here item takes value 0 or 1
253 DeclareAndCast(TColStd_HArray1OfInteger,otherInt,
254 another->AttributeList(i,k));
255 Handle(TColStd_HArray1OfInteger) attrInt =
256 new TColStd_HArray1OfInteger (1,avc);
257 list2->SetValue(i,k,attrInt);
258 for (j = 1; j <= avc; j++)
259 attrInt->SetValue(j,otherInt->Value(j));
260 }
261 break;
262 default : break;
263 }
264 }
265 }
266 ent->Init(list2);
267}
268
269IGESData_DirChecker IGESDefs_ToolAttributeTable::DirChecker
270 (const Handle(IGESDefs_AttributeTable)& /* ent */ ) const
271{
272 IGESData_DirChecker DC(422,0,1);
273 DC.Structure(IGESData_DefReference);
274 DC.GraphicsIgnored();
275 DC.BlankStatusIgnored();
276 DC.HierarchyStatusIgnored();
277 return DC;
278}
279
280void IGESDefs_ToolAttributeTable::OwnCheck
281 (const Handle(IGESDefs_AttributeTable)& ent,
282 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
283{
284 if (ent->Definition().IsNull())
285 if (ent->HasStructure()) ach->AddFail
286 ("Structure in Directory Entry is not an Attribute Definition Table");
287 else ach->AddFail("No Attribute Definition defined");
288 if (ent->FormNumber() == 0 && ent->NbRows() != 1)
289 ach->AddFail("Form 0 with several Rows");
290 if (ent->NbAttributes() != ent->Definition()->NbAttributes())
291 ach->AddFail("Mismatch between Definition (Structure) and Content");
292}
293
294void IGESDefs_ToolAttributeTable::OwnDump
295 (const Handle(IGESDefs_AttributeTable)& ent, const IGESData_IGESDumper& dumper,
296 const Handle(Message_Messenger)& S, const Standard_Integer level) const
297{
298 S << "IGESDefs_AttributeTable" << endl;
299
300 Handle(IGESDefs_AttributeDef) ab = ent->Definition();
301
302 Standard_Integer na = ent->NbAttributes();
303 Standard_Integer nr = ent->NbRows();
304 if (ent->FormNumber() == 1)
305 S << "Number of Rows (i.e. complete sets of Attributes) : " << nr << endl;
306 else S << "One set of Attributes" << endl;
307 S << "Number of defined Attributes : " << na << endl;
308 if (level <= 4) S <<
309 " [ structure : see Structure in Directory Entry; content : level > 4 ]" <<endl;
310 else
311 for (Standard_Integer k = 1; k <= nr; k ++)
312 {
313 for (Standard_Integer i = 1; i <= na; i ++)
314 {
315 Standard_Integer avc = ab->AttributeValueCount(i);
316 S << "[At.no."<<i<<" Row:"<<k<<"]";
317 switch (ab->AttributeValueDataType(i)) {
318 case 0 : S << " (Void) "; break;
319 case 1 : S << " Integer"; break;
320 case 2 : S << " Real "; break;
321 case 3 : S << " String "; break;
322 case 4 : S << " Entity "; break;
323 case 5 : S << " (Not used)"; break;
324 case 6 : S << " Logical"; break;
325 default : break;
326 }
327 S << " :";
328 for (Standard_Integer j = 1;j <= avc; j++) {
329 S << " ";
330 switch(ab->AttributeValueDataType(i)) {
331 case 1 : S << ent->AttributeAsInteger(i,k,j); break;
332 case 2 : S << ent->AttributeAsReal (i,k,j); break;
333 case 3 : IGESData_DumpString(S,ent->AttributeAsString (i,k,j));
334 break;
335 case 4 : dumper.Dump(ent->AttributeAsEntity (i,k,j),S,level-5);
336 break;
337 case 6 : S << (ent->AttributeAsLogical(i,k,j) ? "True" : "False");
338 break;
339 default : break;
340 }
341 }
342 S << endl;
343 }
344 }
345 S << endl;
346}