0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / IGESAppli / IGESAppli_ToolElementResults.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// UNFINISHED & UNSTARTED
24#include <IGESAppli_ToolElementResults.ixx>
25#include <IGESData_ParamCursor.hxx>
26#include <TColStd_HArray1OfReal.hxx>
27#include <TColStd_HArray1OfInteger.hxx>
28#include <IGESBasic_HArray1OfHArray1OfReal.hxx>
29#include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
30#include <IGESAppli_FiniteElement.hxx>
31#include <IGESAppli_HArray1OfFiniteElement.hxx>
32#include <IGESDimen_GeneralNote.hxx>
33#include <IGESData_Dump.hxx>
34#include <Interface_Macros.hxx>
35#include <stdio.h>
36
37
38IGESAppli_ToolElementResults::IGESAppli_ToolElementResults () { }
39
40
41void IGESAppli_ToolElementResults::ReadOwnParams
42 (const Handle(IGESAppli_ElementResults)& ent,
43 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
44{
45 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
46 Standard_Integer num = 0;
47 Handle(IGESDimen_GeneralNote) aNote;
48 Standard_Integer aSubcaseNumber = 0;
49 Standard_Real aTime = 0;
50 Standard_Integer nv = 0;
51 Standard_Integer aResultReportFlag = 0;
52 Handle(TColStd_HArray1OfInteger) allElementIdentifiers;
53 Handle(IGESAppli_HArray1OfFiniteElement) allElements;
54 Handle(TColStd_HArray1OfInteger) allElementTopologyType;
55 Handle(TColStd_HArray1OfInteger) allNbLayers;
56 Handle(TColStd_HArray1OfInteger) allDataLayerFlag;
57 Handle(TColStd_HArray1OfInteger) allNbResultDataLocs;
58 Handle(IGESBasic_HArray1OfHArray1OfInteger) allResultDataLoc;
59 Handle(IGESBasic_HArray1OfHArray1OfReal) allResultData;
60
61 //szv#4:S4163:12Mar99 `st=` not needed
62 PR.ReadEntity(IR, PR.Current(), "General Note", STANDARD_TYPE(IGESDimen_GeneralNote), aNote);
63 PR.ReadInteger(PR.Current(), "Subcase Number", aSubcaseNumber);
64 PR.ReadReal(PR.Current(), "Time", aTime);
65 PR.ReadInteger(PR.Current(), "Number of Result Values", nv);
66 PR.ReadInteger(PR.Current(), "Result Report Flag", aResultReportFlag);
67 PR.ReadInteger(PR.Current(), "Number of Finite Elements", num);
68
69 if (num > 0) {
70 allElementIdentifiers = new TColStd_HArray1OfInteger(1, num);
71 allElements = new IGESAppli_HArray1OfFiniteElement(1, num);
72 allElementTopologyType = new TColStd_HArray1OfInteger(1, num);
73 allNbLayers = new TColStd_HArray1OfInteger(1, num);
74 allDataLayerFlag = new TColStd_HArray1OfInteger(1, num);
75 allNbResultDataLocs = new TColStd_HArray1OfInteger(1, num);
76 allResultDataLoc = new IGESBasic_HArray1OfHArray1OfInteger(1, num);
77 allResultData = new IGESBasic_HArray1OfHArray1OfReal(1, num);
78// ?? WHAT ABOUT FILLING ?
79 }
80 else PR.AddFail("Number of Finite Elements: Not Positive");
81
82 for (Standard_Integer nume = 1; nume <= num; nume ++) {
83 Standard_Integer ival, nl, nrl, numv;
84 ival = nl = nrl = numv = 0;
85 Handle(IGESAppli_FiniteElement) aFEM;
86 Handle(TColStd_HArray1OfInteger) rdrl;
87 Handle(TColStd_HArray1OfReal) vres;
88 //szv#4:S4163:12Mar99 moved in if
89 if (PR.ReadInteger (PR.Current(), "FEM Element Identifier", ival))
90 allElementIdentifiers->SetValue(nume,ival);
91 if (PR.ReadEntity (IR,PR.Current(), "FEM Element Entity", STANDARD_TYPE(IGESAppli_FiniteElement), aFEM))
92 allElements->SetValue (nume,aFEM);
93 if (PR.ReadInteger (PR.Current(), "FEM Element Topology Type", ival))
94 allElementTopologyType->SetValue (nume,ival);
95 if (PR.ReadInteger (PR.Current(), "Nb. of layers", nl))
96 allNbLayers->SetValue (nume,nl);
97 if (PR.ReadInteger (PR.Current(), "Data Layer Flag", ival))
98 allDataLayerFlag->SetValue (nume,ival);
99 if (PR.ReadInteger (PR.Current(), "Nb. of result data locations", nrl))
100 allNbResultDataLocs->SetValue (nume,nrl);
101 if (PR.ReadInts (PR.CurrentList(nrl), "Result data locations", rdrl))
102 allResultDataLoc->SetValue (nume,rdrl);
103 PR.ReadInteger (PR.Current(), "Nb. of result data locations", numv); //szv#4:S4163:12Mar99 `st=` not needed
104 if (PR.ReadReals (PR.CurrentList(numv), "Result Data", vres))
105 allResultData->SetValue(nume,vres);
106 }
107
108 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
109 ent->Init(aNote, aSubcaseNumber, aTime, nv, aResultReportFlag,
110 allElementIdentifiers, allElements, allElementTopologyType,
111 allNbLayers, allDataLayerFlag, allNbResultDataLocs,
112 allResultDataLoc, allResultData);
113}
114
115void IGESAppli_ToolElementResults::WriteOwnParams
116 (const Handle(IGESAppli_ElementResults)& ent, IGESData_IGESWriter& IW) const
117{
118 Standard_Integer i,j; Standard_Integer num = ent->NbElements();
119 IW.Send(ent->Note());
120 IW.Send(ent->SubCaseNumber());
121 IW.Send(ent->Time());
122 IW.Send(ent->NbResultValues());
123 IW.Send(ent->ResultReportFlag());
124 IW.Send(num);
125 for ( i = 1; i <= num; i++ ) {
126 Standard_Integer nl = ent->NbLayers(i);
127 Standard_Integer nrl = ent->NbResultDataLocs(i);
128 Standard_Integer numv = ent->NbResults(i);
129 IW.Send(ent->ElementIdentifier(i));
130 IW.Send(ent->Element(i));
131 IW.Send(ent->ElementTopologyType(i));
132 IW.Send(nl);
133 IW.Send(ent->DataLayerFlag(i));
134 IW.Send(nrl);
135 for (j = 1; j <= nrl; j ++) IW.Send(ent->ResultDataLoc(i,j));
136 IW.Send(numv);
137 for (j = 1; j <= numv; j ++) IW.Send(ent->ResultData(i,j));
138 }
139}
140
141void IGESAppli_ToolElementResults::OwnShared
142 (const Handle(IGESAppli_ElementResults)& ent, Interface_EntityIterator& iter) const
143{
144 Standard_Integer i; Standard_Integer num = ent->NbElements();
145 iter.GetOneItem(ent->Note());
146 for ( i = 1; i <= num; i++ )
147 iter.GetOneItem(ent->Element(i));
148}
149
150void IGESAppli_ToolElementResults::OwnCopy
151 (const Handle(IGESAppli_ElementResults)& another,
152 const Handle(IGESAppli_ElementResults)& ent, Interface_CopyTool& TC) const
153{
154 Standard_Integer i,j;
155 Standard_Integer num = another->NbElements();
156 DeclareAndCast(IGESDimen_GeneralNote,aNote,TC.Transferred(another->Note()));
157 Standard_Integer aSubcaseNumber = another->SubCaseNumber();
158 Standard_Real aTime = another->Time();
159 Standard_Integer nv = another->NbResultValues();
160 Standard_Integer aResultReportFlag = another->ResultReportFlag();
161
162 Handle(TColStd_HArray1OfInteger) allElementIdentifiers;
163 Handle(IGESAppli_HArray1OfFiniteElement) allElements;
164 Handle(TColStd_HArray1OfInteger) allElementTopologyType;
165 Handle(TColStd_HArray1OfInteger) allNbLayers;
166 Handle(TColStd_HArray1OfInteger) allDataLayerFlag;
167 Handle(TColStd_HArray1OfInteger) allNbResultDataLocs;
168 Handle(IGESBasic_HArray1OfHArray1OfInteger) allResultDataLoc;
169 Handle(IGESBasic_HArray1OfHArray1OfReal) allResultData;
170 if (num > 0) {
171 allElementIdentifiers = new TColStd_HArray1OfInteger(1, num);
172 allElements = new IGESAppli_HArray1OfFiniteElement(1, num);
173 allElementTopologyType = new TColStd_HArray1OfInteger(1, num);
174 allNbLayers = new TColStd_HArray1OfInteger(1, num);
175 allDataLayerFlag = new TColStd_HArray1OfInteger(1, num);
176 allNbResultDataLocs = new TColStd_HArray1OfInteger(1, num);
177 allResultDataLoc = new IGESBasic_HArray1OfHArray1OfInteger(1, num);
178 allResultData = new IGESBasic_HArray1OfHArray1OfReal(1, num);
179 }
180 for (i = 1; i <= num; i ++) {
181 Standard_Integer nl,nrl,numv;
182 allElementIdentifiers->SetValue(i,another->ElementIdentifier(i));
183 allElements->SetValue
184 (i,GetCasted(IGESAppli_FiniteElement,TC.Transferred(another->Element(i))));
185 allElementTopologyType->SetValue(i,another->ElementTopologyType(i));
186 nl = another->NbLayers(i);
187 allNbLayers->SetValue(i,nl);
188 allDataLayerFlag->SetValue(i,another->DataLayerFlag(i));
189 nrl = another->NbResultDataLocs(i);
190 allNbResultDataLocs->SetValue(i,nrl);
191 Handle(TColStd_HArray1OfInteger) rdrl = new TColStd_HArray1OfInteger(1,nrl);
192 allResultDataLoc->SetValue(i,rdrl);
193 for (j = 1; j <= nrl; j ++) rdrl->SetValue(j,another->ResultDataLoc(i,j));
194 numv = another->NbResults(i);
195 Handle(TColStd_HArray1OfReal) vres = new TColStd_HArray1OfReal(1,numv);
196 for (j = 1; j <= numv; j ++) vres->SetValue(j,another->ResultData(i,j));
197 allResultData->SetValue(i,vres);
198 }
199 ent->Init
200 (aNote, aSubcaseNumber, aTime, nv, aResultReportFlag,
201 allElementIdentifiers, allElements, allElementTopologyType,
202 allNbLayers, allDataLayerFlag, allNbResultDataLocs,
203 allResultDataLoc, allResultData);
204 ent->SetFormNumber(another->FormNumber());
205}
206
207
208IGESData_DirChecker IGESAppli_ToolElementResults::DirChecker
209 (const Handle(IGESAppli_ElementResults)& /* ent */) const
210{
211 IGESData_DirChecker DC(148, 0, 34);
212 DC.Structure(IGESData_DefVoid);
213 DC.GraphicsIgnored();
214 DC.LineFont(IGESData_DefVoid);
215 DC.LineWeight(IGESData_DefVoid);
216 DC.Color(IGESData_DefAny);
217 DC.BlankStatusIgnored();
218 DC.UseFlagRequired(3);
219 DC.HierarchyStatusIgnored();
220 return DC;
221}
222
223void IGESAppli_ToolElementResults::OwnCheck
224 (const Handle(IGESAppli_ElementResults)& ent,
225 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
226 // UNFINISHED
227{
228 Standard_Integer rrf = ent->ResultReportFlag();
229 if (rrf < 0 || rrf > 3) ach->AddFail("Result Report Flag not in [0-3]");
230 Standard_Integer nv = ent->NbResultValues();
231 Standard_Boolean OK = Standard_True;
232 switch (ent->FormNumber()) {
233 case 0 : if (nv < 0) OK = Standard_False; break;
234 case 1 : if (nv != 1) OK = Standard_False; break;
235 case 2 : if (nv != 1) OK = Standard_False; break;
236 case 3 : if (nv != 3) OK = Standard_False; break;
237 case 4 : if (nv != 6) OK = Standard_False; break;
238 case 5 : if (nv != 3) OK = Standard_False; break;
239 case 6 : if (nv != 3) OK = Standard_False; break;
240 case 7 : if (nv != 3) OK = Standard_False; break;
241 case 8 : if (nv != 3) OK = Standard_False; break;
242 case 9 : if (nv != 3) OK = Standard_False; break;
243 case 10 : if (nv != 1) OK = Standard_False; break;
244 case 11 : if (nv != 1) OK = Standard_False; break;
245 case 12 : if (nv != 3) OK = Standard_False; break;
246 case 13 : if (nv != 1) OK = Standard_False; break;
247 case 14 : if (nv != 1) OK = Standard_False; break;
248 case 15 : if (nv != 3) OK = Standard_False; break;
249 case 16 : if (nv != 1) OK = Standard_False; break;
250 case 17 : if (nv != 3) OK = Standard_False; break;
251 case 18 : if (nv != 3) OK = Standard_False; break;
252 case 19 : if (nv != 3) OK = Standard_False; break;
253 case 20 : if (nv != 3) OK = Standard_False; break;
254 case 21 : if (nv != 3) OK = Standard_False; break;
255 case 22 : if (nv != 3) OK = Standard_False; break;
256 case 23 : if (nv != 6) OK = Standard_False; break;
257 case 24 : if (nv != 6) OK = Standard_False; break;
258 case 25 : if (nv != 6) OK = Standard_False; break;
259 case 26 : if (nv != 6) OK = Standard_False; break;
260 case 27 : if (nv != 6) OK = Standard_False; break;
261 case 28 : if (nv != 6) OK = Standard_False; break;
262 case 29 : if (nv != 9) OK = Standard_False; break;
263 case 30 : if (nv != 9) OK = Standard_False; break;
264 case 31 : if (nv != 9) OK = Standard_False; break;
265 case 32 : if (nv != 9) OK = Standard_False; break;
266 case 33 : if (nv != 9) OK = Standard_False; break;
267 case 34 : if (nv != 9) OK = Standard_False; break;
268 default : ach->AddFail("Incorrect Form Number"); break;
269 }
270 if (!OK) ach->AddFail
271 ("Incorrect count of real values in array V for FEM node");
272 Standard_Integer ne = ent->NbElements();
273 for (Standard_Integer i = 1; i <= ne; i ++) {
274 char mess[100];
275 Standard_Integer dlf = ent->DataLayerFlag(i);
276 Standard_Integer nl = ent->NbLayers(i);
277 Standard_Integer nrl = ent->NbResultDataLocs(i);
278 if (dlf < 0 || dlf > 4)
279 ach->AddFail("One of the Data Layer Flags not in [0-4]");
280 if (dlf < 4 && ent->NbLayers(i) != 1) {
281 sprintf(mess,"Nb. of Layers n0.%d not ONE while Data Layer Flag is in [0-3]",i);
282 ach->AddFail(mess);
283 }
284 if (rrf == 1 || rrf == 2)
285 if (nrl != 1 || ent->ResultDataLoc(i,1) != 0) {
286 sprintf(mess,"Result Data Locs n0.%d incorrect for Result Report = 1 or 2",i);
287 ach->AddFail(mess);
288 }
289 if (ent->NbResults(i) != (nv*nl*nrl)) {
290 sprintf(mess,"Nb. of results for Element n0.%d incorrect, should be %d",
291 i,nv*nl*nrl);
292 ach->AddFail(mess);
293 }
294 }
295}
296
297void IGESAppli_ToolElementResults::OwnDump
298 (const Handle(IGESAppli_ElementResults)& ent, const IGESData_IGESDumper& dumper,
299 const Handle(Message_Messenger)& S, const Standard_Integer level) const // UNFINISHED
300{
301 Standard_Integer sublevel = (level > 4) ? 1 : 0;
302 S << "IGESAppli_ElementResults" << endl;
303 S << "General Note : ";
304 dumper.Dump(ent->Note(),S, sublevel);
305 S << endl;
306 S << "Subcase Number : " << ent->SubCaseNumber() << endl;
307 S << "Time : " << ent->Time() << endl;
308 S << "Number of Result Values : " << ent->NbResultValues() << endl;
309 S << "Result Report Flag : " << ent->ResultReportFlag() << endl;
310 S << "Element Identifiers : ";
311 IGESData_DumpVals(S ,level,1, ent->NbElements(),ent->ElementIdentifier);
312 S << endl << "Elements : ";
313 IGESData_DumpEntities(S,dumper ,level,1, ent->NbElements(),ent->Element);
314 S << endl << "Element Topology Types : ";
315 IGESData_DumpVals(S ,level,1, ent->NbElements(),ent->ElementTopologyType);
316 S << endl << "Numbers of Layers : ";
317 IGESData_DumpVals(S ,level,1, ent->NbElements(),ent->NbLayers);
318 S << endl << "Data Layer Flags : ";
319 IGESData_DumpVals(S ,level,1, ent->NbElements(),ent->DataLayerFlag);
320 S << endl << "Numbers of Result Data Locations : ";
321 IGESData_DumpVals(S ,level,1, ent->NbElements(),ent->NbResultDataLocs);
322 S << endl << "Result Data Locations : "; S << " TO BE DONE ";
323
324// ?? A VERIFIER DE PRES, pas du tout sur que ce soit bon
325// cf aussi Write et Copy
326 if (level <= 4) S << " [ ask level > 4 for more, > 5 for complete ]" << endl;
327 else {
328 Standard_Integer i;// svv Jan 10 2000 : porting on DEC
329 for (i = 1; i <= ent->NbElements(); i ++) {
330 Standard_Integer nloc = ent->NbResultDataLocs(i);
331 S << " ["<<i<<":NbLoc="<<nloc<<"]:";
332 for (Standard_Integer j = 1; j <= nloc; j ++)
333 S << " " << ent->ResultDataLoc (i,j);
334 S << endl;
335 }
336 S << "Result Data : ";
337
338 for (i = 1; i <= ent->NbElements(); i ++) {
339 Standard_Integer nres = ent->NbResults(i);
340 S << " ["<<i<<":NbRes="<<nres<<"]:";
341 if (level <= 5) S << " [ ask level > 5 for complete Data ]" << endl;
342 else {
343 for (Standard_Integer j = 1; j <= nres; j ++)
344 S << " " << ent->ResultData(i,j); // ?? is it all ?? UNFINISHED
345 }
346 }
347 }
348}