0024171: Eliminate CLang compiler warning -Wreorder
[occt.git] / src / IGESDefs / IGESDefs_ToolGenericData.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_ToolGenericData.ixx>
24#include <IGESData_ParamCursor.hxx>
25#include <IGESData_IGESEntity.hxx>
26#include <TColStd_HArray1OfTransient.hxx>
27#include <TColStd_HArray1OfInteger.hxx>
28#include <TCollection_HAsciiString.hxx>
29#include <TColStd_HArray1OfReal.hxx>
30#include <IGESData_HArray1OfIGESEntity.hxx>
31#include <Interface_HArray1OfHAsciiString.hxx>
32#include <Interface_Macros.hxx>
33#include <IGESData_Dump.hxx>
34
35
36IGESDefs_ToolGenericData::IGESDefs_ToolGenericData () { }
37
38
39void IGESDefs_ToolGenericData::ReadOwnParams
40 (const Handle(IGESDefs_GenericData)& ent,
41 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
42{
43 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
44 Standard_Integer i, num;
45 Standard_Integer tempNbPropVal;
46 Handle(TCollection_HAsciiString) tempName;
47 Handle(TColStd_HArray1OfInteger) tempTypes;
48 Handle(TColStd_HArray1OfTransient) tempValues;
49
50 PR.ReadInteger(PR.Current(), "Number of property values", tempNbPropVal); //szv#4:S4163:12Mar99 `st=` not needed
51
52 PR.ReadText(PR.Current(), "Property Name", tempName); //szv#4:S4163:12Mar99 `st=` not needed
53
54 Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of TYPE/VALUEs", num);
55 if (st && num > 0)
56 {
57 tempTypes = new TColStd_HArray1OfInteger(1, num);
58 tempValues = new TColStd_HArray1OfTransient(1, num);
59 }
60 else PR.AddFail("Number of TYPE/VALUEs: Not Positive");
61
62 if (!tempTypes.IsNull() && !tempValues.IsNull())
63 for ( i = 1; i <= num; i++ )
64 {
65 Standard_Integer tempTyp;
66 PR.ReadInteger(PR.Current(), "Type code", tempTyp); //szv#4:S4163:12Mar99 `st=` not needed
67 tempTypes->SetValue(i, tempTyp);
68 switch (tempTyp)
69 {
70 case 0: // No value
71 PR.SetCurrentNumber(PR.CurrentNumber()+1);
72 break;
73 case 1: // Integer
74 {
75 Handle(TColStd_HArray1OfInteger) tempObj;
76 //st = PR.ReadInts(PR.CurrentList(1), "Integer value", tempObj); //szv#4:S4163:12Mar99 moved in if
77 if (PR.ReadInts(PR.CurrentList(1), "Integer value", tempObj))
78 tempValues->SetValue(i, tempObj);
79 }
80 break;
81 case 2: // Real
82 {
83 Handle(TColStd_HArray1OfReal) tempObj;
84 //st = PR.ReadReals(PR.CurrentList(1), "Real value", tempObj); //szv#4:S4163:12Mar99 moved in if
85 if (PR.ReadReals(PR.CurrentList(1), "Real value", tempObj))
86 tempValues->SetValue(i, tempObj);
87 }
88 break;
89 case 3: // Character string
90 {
91 Handle(TCollection_HAsciiString) tempObj;
92 //st = PR.ReadText(PR.Current(), "String value", tempObj); //szv#4:S4163:12Mar99 moved in if
93 if (PR.ReadText(PR.Current(), "String value", tempObj))
94 tempValues->SetValue(i, tempObj);
95 }
96 break;
97 case 4: // Pointer
98 {
99 Handle(IGESData_IGESEntity) tempEntity;
100 //st = PR.ReadEntity(IR, PR.Current(), "Entity value", tempEntity); //szv#4:S4163:12Mar99 moved in if
101 if (PR.ReadEntity(IR, PR.Current(), "Entity value", tempEntity))
102 tempValues->SetValue(i, tempEntity);
103 }
104 break;
105 case 5: // Not used
106 PR.SetCurrentNumber(PR.CurrentNumber()+1);
107 break;
108 case 6: // Logical
109 {
110 Handle(TColStd_HArray1OfInteger) tempObj = new TColStd_HArray1OfInteger(1, 1);
111 Standard_Boolean tempBool;
112 //st = PR.ReadBoolean(PR.Current(), "Boolean value", tempBool); //szv#4:S4163:12Mar99 moved in if
113 if (PR.ReadBoolean(PR.Current(), "Boolean value", tempBool)) {
114 tempObj->SetValue(1, (tempBool ? 1 : 0));
115 tempValues->SetValue(i, tempObj);
116 }
117 }
118 break;
119 }
120 }
121
122 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
123 ent->Init (tempNbPropVal, tempName, tempTypes, tempValues);
124}
125
126void IGESDefs_ToolGenericData::WriteOwnParams
127 (const Handle(IGESDefs_GenericData)& ent, IGESData_IGESWriter& IW) const
128{
129 Standard_Integer i, num;
130 IW.Send(ent->NbPropertyValues());
131 IW.Send(ent->Name());
132 IW.Send(ent->NbTypeValuePairs());
133 for ( num = ent->NbTypeValuePairs(), i = 1; i <= num; i++ )
134 {
135 IW.Send(ent->Type(i));
136 switch (ent->Type(i))
137 {
138 case 0 : IW.SendVoid(); break;
139 case 1 : IW.Send(ent->ValueAsInteger(i)); break;
140 case 2 : IW.Send(ent->ValueAsReal(i)); break;
141 case 3 : IW.Send(ent->ValueAsString(i)); break;
142 case 4 : IW.Send(ent->ValueAsEntity(i)); break;
143 case 5 : IW.SendVoid(); break;
144 case 6 : IW.SendBoolean(ent->ValueAsLogical(i)); break;
145 default : break;
146 }
147 }
148}
149
150void IGESDefs_ToolGenericData::OwnShared
151 (const Handle(IGESDefs_GenericData)& ent, Interface_EntityIterator& iter) const
152{
153 Standard_Integer i, num;
154 for ( num = ent->NbTypeValuePairs(), i = 1; i <= num; i++ )
155 {
156 if (ent->Type(i) == 4)
157 iter.GetOneItem(ent->ValueAsEntity(i));
158 }
159}
160
161void IGESDefs_ToolGenericData::OwnCopy
162 (const Handle(IGESDefs_GenericData)& another,
163 const Handle(IGESDefs_GenericData)& ent, Interface_CopyTool& TC) const
164{
165 Standard_Integer num = another->NbTypeValuePairs();
166 Standard_Integer tempNbPropVal = another->NbPropertyValues();
167 Handle(TCollection_HAsciiString) tempName =
168 new TCollection_HAsciiString(another->Name());
169 Handle(TColStd_HArray1OfInteger) tempTypes =
170 new TColStd_HArray1OfInteger(1, num);
171 Handle(TColStd_HArray1OfTransient) tempValues =
172 new TColStd_HArray1OfTransient(1, num);
173
174 for (Standard_Integer i = 1; i <= num; i++)
175 {
176 tempTypes->SetValue(i, another->Type(i));
177 switch (another->Type(i))
178 {
179 case 0: // No value
180 break;
181 case 1: // Integer
182 {
183 Handle(TColStd_HArray1OfInteger) tempObj =
184 new TColStd_HArray1OfInteger(1,1);
185 tempObj->SetValue(1,another->ValueAsInteger(i));
186 tempValues->SetValue(i, tempObj);
187 }
188 break;
189 case 2: // Real
190 {
191 Handle(TColStd_HArray1OfReal) tempObj =
192 new TColStd_HArray1OfReal(1,1);
193 tempObj->SetValue(1,another->ValueAsReal(i));
194 tempValues->SetValue(i, tempObj);
195 }
196 break;
197 case 3: // Character string
198 {
199 tempValues->SetValue
200 (i, new TCollection_HAsciiString(another->ValueAsString(i)));
201 }
202 break;
203 case 4: // Pointer
204 {
205 DeclareAndCast(IGESData_IGESEntity, tempObj,
206 TC.Transferred(another->ValueAsEntity(i)));
207 tempValues->SetValue(i, tempObj);
208 }
209 break;
210 case 5: // Not used
211 break;
212 case 6: // Logical
213 {
214 Handle(TColStd_HArray1OfInteger) tempObj =
215 new TColStd_HArray1OfInteger(1,1);
216 tempObj->SetValue(1, (another->ValueAsLogical(i) ? 1 : 0) );
217 tempValues->SetValue(i, tempObj);
218 }
219 break;
220 }
221 }
222 ent->Init (tempNbPropVal, tempName, tempTypes, tempValues);
223}
224
225IGESData_DirChecker IGESDefs_ToolGenericData::DirChecker
226 (const Handle(IGESDefs_GenericData)& /* ent */ ) const
227{
228 IGESData_DirChecker DC(406, 27);
229 DC.Structure(IGESData_DefVoid);
230 DC.GraphicsIgnored();
231 DC.LineFont(IGESData_DefVoid);
232 DC.LineWeight(IGESData_DefVoid);
233 DC.Color(IGESData_DefVoid);
234 DC.BlankStatusIgnored();
235 DC.SubordinateStatusRequired(1);
236 DC.UseFlagRequired(2);
237 DC.HierarchyStatusIgnored();
238 return DC;
239}
240
241void IGESDefs_ToolGenericData::OwnCheck
242 (const Handle(IGESDefs_GenericData)& ent,
243 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
244{
245 if (ent->NbPropertyValues() != ent->NbTypeValuePairs()*2 + 2)
246 ach->AddFail("Nb. of Property Values not consistent with Nb. of Type/value Pairs");
247}
248
249void IGESDefs_ToolGenericData::OwnDump
250 (const Handle(IGESDefs_GenericData)& ent, const IGESData_IGESDumper& dumper,
251 const Handle(Message_Messenger)& S, const Standard_Integer level) const
252{
253 S << "IGESDefs_GenericData" << endl;
254 S << "Number of property values : " << ent->NbPropertyValues() << endl;
255 S << "Property Name : ";
256 IGESData_DumpString(S,ent->Name());
257 S << endl;
258 switch (level)
259 {
260 case 4:
261 S << "Types : " << endl;
262 S << "Values : " << "Count = " << ent->NbTypeValuePairs() << endl;
263 S << " [ as level > 4 for content ]" << endl;
264 break;
265 case 5:
266 case 6:
267 {
268 Standard_Integer i, num;
269 S << "Types & Values : " << endl;
270 for ( num = ent->NbTypeValuePairs(), i = 1; i <= num; i++ )
271 {
272 S << "[" << i << "]: ";
273 S << "Type : " << ent->Type(i);
274 switch (ent->Type(i)) {
275 case 0 : S << " (Void)"; break;
276 case 1 : S << " Integer, Value : " << ent->ValueAsInteger(i);
277 break;
278 case 2 : S << " Real , Value : " << ent->ValueAsReal(i);
279 break;
280 case 3 : S << " String , Value : ";
281 IGESData_DumpString(S,ent->ValueAsString(i)); break;
282 case 4 : S << " Entity , Value : ";
283 dumper.Dump(ent->ValueAsEntity(i),S,level-1); break;
284 case 5 : S << " (Not used)"; break;
285 case 6 : S << " Logical, Value : "
286 << (ent->ValueAsLogical(i) ? "True" : "False"); break;
287 default : break;
288 }
289 S << endl;
290 }
291 }
292 }
293 S << endl;
294}