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