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