Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
b311480e | 4 | // |
d5f74e42 | 5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
9 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
b311480e | 13 | |
7fd59977 | 14 | // abv 09.04.99 S4136: eliminate parameter step.readaccept.void |
15 | // sln 04,10.2001. BUC61003. Prevent exception which may occur during reading of complex entity (if entity's items are not in alphabetical order) | |
42cf5bc1 | 16 | |
17 | #include <Interface_Check.hxx> | |
7fd59977 | 18 | #include <Interface_FileParameter.hxx> |
42cf5bc1 | 19 | #include <Interface_HArray1OfHAsciiString.hxx> |
20 | #include <Interface_Macros.hxx> | |
7fd59977 | 21 | #include <Interface_ParamList.hxx> |
7fd59977 | 22 | #include <Interface_Static.hxx> |
42cf5bc1 | 23 | #include <Message.hxx> |
24 | #include <Message_Messenger.hxx> | |
25 | #include <Standard_Transient.hxx> | |
26 | #include <Standard_Type.hxx> | |
27 | #include <StepData_EnumTool.hxx> | |
28 | #include <StepData_ESDescr.hxx> | |
29 | #include <StepData_Field.hxx> | |
30 | #include <StepData_FieldList.hxx> | |
31 | #include <StepData_PDescr.hxx> | |
32 | #include <StepData_SelectArrReal.hxx> | |
33 | #include <StepData_SelectInt.hxx> | |
7fd59977 | 34 | #include <StepData_SelectMember.hxx> |
35 | #include <StepData_SelectNamed.hxx> | |
36 | #include <StepData_SelectReal.hxx> | |
42cf5bc1 | 37 | #include <StepData_SelectType.hxx> |
38 | #include <StepData_StepModel.hxx> | |
39 | #include <StepData_StepReaderData.hxx> | |
40 | #include <TCollection_AsciiString.hxx> | |
41 | #include <TCollection_HAsciiString.hxx> | |
42 | #include <TColStd_Array1OfInteger.hxx> | |
43 | #include <TColStd_HArray1OfInteger.hxx> | |
44 | #include <TColStd_HArray1OfReal.hxx> | |
45 | #include <TColStd_HArray1OfTransient.hxx> | |
7fd59977 | 46 | #include <TColStd_HSequenceOfReal.hxx> |
42cf5bc1 | 47 | #include <TColStd_IndexedMapOfInteger.hxx> |
48 | #include <TColStd_SequenceOfInteger.hxx> | |
7fd59977 | 49 | |
50 | #include <stdio.h> | |
e119b6c3 | 51 | IMPLEMENT_STANDARD_RTTIEXT(StepData_StepReaderData, Interface_FileReaderData) |
92efcf78 | 52 | |
7fd59977 | 53 | // Le Header est constitue d entites analogues dans leur principe a celles |
54 | // du Data, a ceci pres qu elles sont sans identifieur, et ne peuvent ni | |
55 | // referencer, ni etre referencees (que ce soit avec Header ou avec Data) | |
56 | // Ainsi, dans StepReaderData, le Header est constitue des "thenbhead" 1res Entites | |
7fd59977 | 57 | // ######################################################################### |
58 | // .... Creation et Acces de base aux donnees atomiques du fichier .... | |
7fd59977 | 59 | typedef TCollection_HAsciiString String; |
7fd59977 | 60 | static char txtmes[200]; // plus commode que redeclarer partout |
61 | ||
62 | ||
63 | static Standard_Boolean initstr = Standard_False; | |
64 | ||
65 | #define Maxlst 64 | |
66 | //static TCollection_AsciiString subl[Maxlst]; // Maxlst : minimum 10 | |
67 | ||
68 | static Standard_Integer acceptvoid = 0; | |
69 | ||
70 | // ---------- Fonctions Utilitaires ---------- | |
71 | ||
72 | //======================================================================= | |
73 | //function : CleanText | |
74 | //purpose : | |
75 | //======================================================================= | |
e119b6c3 | 76 | static void CleanText(const Handle(TCollection_HAsciiString)& val) |
7fd59977 | 77 | { |
78 | Standard_Integer n = val->Length(); // avant reduction | |
79 | val->Remove(n); | |
80 | val->Remove(1); | |
e119b6c3 | 81 | // Ne pas oublier de traiter les caracteres speciaux |
82 | for (Standard_Integer i = n - 2; i > 0; i--) { | |
7fd59977 | 83 | char uncar = val->Value(i); |
84 | if (uncar == '\n') | |
85 | { val->Remove(i); if (i < n-2) uncar = val->Value(i); } | |
e119b6c3 | 86 | if (uncar == '\'' && i < n - 2) { |
87 | if (val->Value(i + 1) == '\'') { val->Remove(i + 1); continue; } | |
7fd59977 | 88 | } |
e119b6c3 | 89 | if (uncar == '\\' && i < n - 2) { |
90 | if (val->Value(i + 1) == '\\') { val->Remove(i + 1); continue; } | |
7fd59977 | 91 | } |
e119b6c3 | 92 | else if (uncar == '\\' && i < n - 3) { |
93 | if (val->Value(i + 2) == '\\') { | |
94 | if (val->Value(i + 1) == 'N') | |
7fd59977 | 95 | { val->SetValue(i,'\n'); val->Remove(i+1,2); continue; } |
e119b6c3 | 96 | if (val->Value(i + 1) == 'T') |
7fd59977 | 97 | { val->SetValue(i,'\t'); val->Remove(i+1,2); continue; } |
e119b6c3 | 98 | } |
7fd59977 | 99 | } |
100 | } | |
101 | } | |
7fd59977 | 102 | |
103 | // ------------- METHODES ------------- | |
104 | ||
105 | //======================================================================= | |
106 | //function : StepData_StepReaderData | |
107 | //purpose : | |
108 | //======================================================================= | |
109 | ||
110 | StepData_StepReaderData::StepData_StepReaderData | |
e119b6c3 | 111 | (const Standard_Integer nbheader, const Standard_Integer nbtotal, |
112 | const Standard_Integer nbpar) | |
113 | : Interface_FileReaderData(nbtotal, nbpar), theidents(1, nbtotal), | |
114 | thetypes(1, nbtotal) //, themults (1,nbtotal) | |
7fd59977 | 115 | { |
e119b6c3 | 116 | // char textnum[10]; |
7fd59977 | 117 | thenbscop = 0; thenbents = 0; thelastn = 0; thenbhead = nbheader; |
118 | //themults.Init(0); | |
119 | thecheck = new Interface_Check; | |
e119b6c3 | 120 | //:S4136 acceptvoid = Interface_Static::IVal("step.readaccept.void"); |
7fd59977 | 121 | if (initstr) return; |
122 | //for (Standard_Integer i = 0; i < Maxlst; i ++) { | |
123 | // sprintf(textnum,"$%d",i+1); | |
124 | // subl[i].AssignCat(textnum); | |
125 | //} | |
126 | initstr = Standard_True; | |
127 | } | |
128 | ||
129 | ||
130 | //======================================================================= | |
131 | //function : SetRecord | |
132 | //purpose : | |
133 | //======================================================================= | |
134 | ||
e119b6c3 | 135 | void StepData_StepReaderData::SetRecord(const Standard_Integer num, |
136 | const Standard_CString ident, | |
137 | const Standard_CString type, | |
138 | const Standard_Integer /* nbpar */) | |
7fd59977 | 139 | { |
140 | Standard_Integer numlst; | |
e119b6c3 | 141 | /* |
142 | if (strcmp(type,"/ * (SUB) * /") == 0) { // defini dans recfile.pc | |
143 | thetypes.SetValue (num,sublist); | |
144 | } else { | |
145 | thenbents ++; // total de termes propres du fichier | |
146 | thetypes.SetValue(num,TCollection_AsciiString(type)); | |
147 | // if (strcmp(ident,"SCOPE") != 0) thenbscop ++; // ?? a verifier | |
148 | } | |
149 | */ | |
150 | if (type[0] != '(') thenbents++; // total de termes propres du fichier | |
151 | ||
7fd59977 | 152 | //thetypes.ChangeValue(num).SetValue(1,type); gka memory |
153 | //============================================ | |
154 | Standard_Integer index = 0; | |
155 | TCollection_AsciiString strtype(type); | |
e119b6c3 | 156 | if (thenametypes.Contains(type)) |
7fd59977 | 157 | index = thenametypes.FindIndex(strtype); |
158 | else index = thenametypes.Add(strtype); | |
159 | thetypes.ChangeValue(num) = index; | |
160 | //=========================================== | |
e119b6c3 | 161 | |
7fd59977 | 162 | if (ident[0] == '$') { |
163 | if (strlen(ident) > 2) numlst = atoi(&ident[1]); | |
164 | else numlst = ident[1] - 48; | |
165 | if (thelastn < numlst) thelastn = numlst; // plus fort n0 de sous-liste | |
e119b6c3 | 166 | theidents.SetValue(num, -2 - numlst); |
7fd59977 | 167 | } else if (ident[0] == '#') { |
168 | numlst = atoi(&ident[1]); | |
e119b6c3 | 169 | theidents.SetValue(num, numlst); |
7fd59977 | 170 | if (numlst == 0 && num > thenbhead) { |
e119b6c3 | 171 | // Header, ou bien Type Complexe ... |
172 | // Si Type Complexe, retrouver Type Precedent (on considere que c est rare) | |
173 | // On chaine le type precedent sur le suivant | |
174 | // VERIFICATION que les types sont en ordre alphabetique | |
175 | for (Standard_Integer prev = num - 1; prev > thenbhead; prev--) { | |
176 | if (theidents(prev) >= 0) { | |
177 | ||
178 | //themults.SetValue(prev,num); | |
179 | themults.Bind(prev, num); | |
180 | if (thenametypes.FindKey(thetypes.Value(num)).IsLess(thenametypes.FindKey(thetypes.Value(prev)))) { | |
181 | // Warning: components in complex entity are not in alphabetical order. | |
182 | TCollection_AsciiString errm("Complex Type incorrect : "); | |
183 | errm.AssignCat(thenametypes.FindKey(thetypes.Value(prev))); | |
184 | errm.AssignCat(" / "); | |
185 | errm.AssignCat(thenametypes.FindKey(thetypes.Value(num))); | |
186 | errm.AssignCat(" ... "); | |
5bbe7380 | 187 | #ifdef OCCT_DEBUG |
e119b6c3 | 188 | while (theidents(prev) <= 0) { |
189 | prev--; if (prev <= 0) break; | |
190 | } | |
191 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
192 | sout << " *** Error on Record " << num << " (on " << NbRecords() | |
193 | << " -> " << num * 100 / NbRecords() << " % in File) ***"; | |
194 | if (prev > 0) sout << " Ident #" << theidents(prev); | |
195 | sout << "\n" << errm << endl; | |
5bbe7380 | 196 | #endif |
e119b6c3 | 197 | thecheck->AddWarning(errm.ToCString(), "Complex Type incorrect : "); |
198 | } | |
199 | break; | |
200 | } | |
7fd59977 | 201 | } |
202 | } | |
203 | } | |
e119b6c3 | 204 | else if (!strcmp(ident, "SCOPE")) { |
205 | theidents.SetValue(num, -1); // SCOPE | |
206 | thenbscop++; | |
7fd59977 | 207 | } |
e119b6c3 | 208 | else if (!strcmp(ident, "ENDSCOPE")) theidents.SetValue(num, -2); // ENDSCOPE |
7fd59977 | 209 | // Reste 0 |
210 | ||
211 | // InitParams(num); | |
212 | } | |
213 | ||
214 | ||
215 | //======================================================================= | |
216 | //function : AddStepParam | |
217 | //purpose : | |
218 | //======================================================================= | |
219 | ||
e119b6c3 | 220 | void StepData_StepReaderData::AddStepParam(const Standard_Integer num, |
221 | const Standard_CString aval, | |
222 | const Interface_ParamType atype, | |
223 | const Standard_Integer nument) | |
7fd59977 | 224 | { |
225 | if (atype == Interface_ParamSub) { | |
226 | Standard_Integer numid = 0; | |
227 | if (aval[2] != '\0') { | |
228 | numid = atoi(&aval[1]); | |
e119b6c3 | 229 | // if (numid <= Maxlst) Interface_FileReaderData::AddParam |
230 | // (num,subl[numid-1].ToCString(),atype,numid); | |
231 | Interface_FileReaderData::AddParam(num, aval, atype, numid); | |
7fd59977 | 232 | } else { |
e119b6c3 | 233 | char *numlstchar = (char *)(aval + 1); |
7fd59977 | 234 | numid = (*numlstchar) - 48; // -48 ('0') -1 (adresse [] depuis 0) |
235 | // Interface_FileReaderData::AddParam (num,subl[numid].ToCString(),atype,numid); | |
e119b6c3 | 236 | Interface_FileReaderData::AddParam(num, aval, atype, numid); |
7fd59977 | 237 | } |
238 | } else if (atype == Interface_ParamIdent) { | |
239 | Standard_Integer numid = atoi(&aval[1]); | |
e119b6c3 | 240 | Interface_FileReaderData::AddParam(num, aval, atype, numid); |
7fd59977 | 241 | } else { |
e119b6c3 | 242 | Interface_FileReaderData::AddParam(num, aval, atype, nument); |
7fd59977 | 243 | } |
244 | ||
e119b6c3 | 245 | // Interface_FileReaderData::AddParam (num,parval,atype,numid); |
7fd59977 | 246 | } |
247 | ||
248 | ||
249 | //======================================================================= | |
250 | //function : RecordType | |
251 | //purpose : | |
252 | //======================================================================= | |
253 | ||
254 | const TCollection_AsciiString& StepData_StepReaderData::RecordType | |
e119b6c3 | 255 | (const Standard_Integer num) const |
7fd59977 | 256 | { |
e119b6c3 | 257 | return thenametypes.FindKey(thetypes.Value(num)); |
7fd59977 | 258 | } |
259 | ||
260 | ||
261 | //======================================================================= | |
262 | //function : CType | |
263 | //purpose : | |
264 | //======================================================================= | |
265 | ||
266 | Standard_CString StepData_StepReaderData::CType(const Standard_Integer num) const | |
267 | { | |
268 | return thenametypes.FindKey(thetypes.Value(num)).ToCString(); | |
269 | } | |
270 | ||
271 | ||
272 | //======================================================================= | |
273 | //function : RecordIdent | |
274 | //purpose : | |
275 | //======================================================================= | |
276 | ||
e119b6c3 | 277 | Standard_Integer StepData_StepReaderData::RecordIdent(const Standard_Integer num) const |
7fd59977 | 278 | { |
279 | return theidents(num); | |
280 | } | |
281 | ||
282 | ||
283 | // ######################################################################## | |
284 | // .... Aides a la lecture des parametres, adaptees a STEP .... | |
285 | ||
286 | ||
287 | //======================================================================= | |
288 | //function : SubListNumber | |
289 | //purpose : | |
290 | //======================================================================= | |
291 | ||
e119b6c3 | 292 | Standard_Integer StepData_StepReaderData::SubListNumber(const Standard_Integer num, |
293 | const Standard_Integer nump, | |
294 | const Standard_Boolean aslast) const | |
7fd59977 | 295 | { |
296 | if (nump == 0 || nump > NbParams(num)) return 0; | |
e119b6c3 | 297 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 298 | if (FP.ParamType() != Interface_ParamSub) return 0; |
e119b6c3 | 299 | if (aslast) { if (nump != NbParams(num)) return 0; } |
7fd59977 | 300 | return FP.EntityNumber(); |
301 | } | |
302 | ||
303 | ||
304 | //======================================================================= | |
305 | //function : IsComplex | |
306 | //purpose : | |
307 | //======================================================================= | |
308 | ||
309 | Standard_Boolean StepData_StepReaderData::IsComplex(const Standard_Integer num) const | |
310 | { | |
311 | //return (themults(num) != 0); | |
312 | return themults.IsBound(num); | |
313 | } | |
314 | ||
315 | ||
316 | //======================================================================= | |
317 | //function : ComplexType | |
318 | //purpose : | |
319 | //======================================================================= | |
320 | ||
321 | void StepData_StepReaderData::ComplexType(const Standard_Integer num, | |
e119b6c3 | 322 | TColStd_SequenceOfAsciiString& types) const |
7fd59977 | 323 | { |
324 | if (theidents(num) < 0) return; | |
325 | for (Standard_Integer i = num; i > 0; i = NextForComplex(i)) { | |
326 | types.Append(RecordType(i)); | |
327 | } | |
328 | } | |
329 | ||
330 | ||
331 | //======================================================================= | |
332 | //function : NextForComplex | |
333 | //purpose : | |
334 | //======================================================================= | |
335 | ||
336 | Standard_Integer StepData_StepReaderData::NextForComplex | |
e119b6c3 | 337 | (const Standard_Integer num) const |
7fd59977 | 338 | { |
e119b6c3 | 339 | Standard_Integer next = 0; |
340 | if (themults.IsBound(num)) | |
7fd59977 | 341 | next = themults.Find(num); |
342 | return next; | |
343 | } | |
344 | ||
7fd59977 | 345 | //======================================================================= |
346 | //function : NamedForComplex | |
347 | //purpose : | |
348 | //======================================================================= | |
349 | ||
350 | Standard_Boolean StepData_StepReaderData::NamedForComplex | |
e119b6c3 | 351 | (const Standard_CString name, const Standard_Integer num0, |
352 | Standard_Integer& num, Handle(Interface_Check)& ach) const | |
7fd59977 | 353 | { |
354 | //Standard_Boolean stat = Standard_True; | |
355 | Standard_Integer n = (num <= 0 ? num0 : NextForComplex(num)); | |
356 | // sln 04,10.2001. BUC61003. if(n==0) the next function is not called in order to avoid exception | |
e119b6c3 | 357 | if ((n != 0) && (!strcmp(RecordType(n).ToCString(), name))) |
7fd59977 | 358 | { num = n; return Standard_True; } |
e119b6c3 | 359 | |
360 | if (n == 0) /*stat =*/ NamedForComplex(name, num0, n, ach); // on a rembobine | |
7fd59977 | 361 | // Pas dans l ordre alphabetique : boucler |
362 | Handle(String) errmess = new String("Parameter n0.%d (%s) not a LIST"); | |
e119b6c3 | 363 | sprintf(txtmes, errmess->ToCString(), num0, name); |
7fd59977 | 364 | for (n = num0; n > 0; n = NextForComplex(n)) { |
e119b6c3 | 365 | if (!strcmp(RecordType(n).ToCString(), name)) { |
7fd59977 | 366 | num = n; |
367 | errmess = new String("Complex Record n0.%d, member type %s not in alphabetic order"); | |
e119b6c3 | 368 | sprintf(txtmes, errmess->ToCString(), num0, name); |
369 | ach->AddWarning(txtmes, errmess->ToCString()); | |
7fd59977 | 370 | return Standard_False; |
371 | } | |
372 | } | |
373 | num = 0; | |
374 | errmess = new String("Complex Record n0.%d, member type %s not found"); | |
e119b6c3 | 375 | sprintf(txtmes, errmess->ToCString(), num0, name); |
376 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 377 | return Standard_False; |
378 | } | |
379 | ||
a7197ef3 | 380 | //======================================================================= |
381 | //function : NamedForComplex | |
382 | //purpose : | |
383 | //======================================================================= | |
384 | ||
385 | Standard_Boolean StepData_StepReaderData::NamedForComplex | |
e119b6c3 | 386 | (const Standard_CString theName, const Standard_CString theShortName, |
387 | const Standard_Integer num0, Standard_Integer& num, | |
388 | Handle(Interface_Check)& ach) const | |
a7197ef3 | 389 | { |
390 | Standard_Integer n = (num <= 0 ? num0 : NextForComplex(num)); | |
e119b6c3 | 391 | |
392 | if ((n != 0) && (!strcmp(RecordType(n).ToCString(), theName) || | |
393 | !strcmp(RecordType(n).ToCString(), theShortName))) | |
2c25cc04 | 394 | { |
395 | num = n; | |
396 | return Standard_True; | |
397 | } | |
e119b6c3 | 398 | |
a7197ef3 | 399 | //entities are not in alphabetical order |
400 | Handle(String) errmess = new String("Parameter n0.%d (%s) not a LIST"); | |
e119b6c3 | 401 | sprintf(txtmes, errmess->ToCString(), num0, theName); |
2c25cc04 | 402 | for (n = num0; n > 0; n = NextForComplex(n)) |
403 | { | |
e119b6c3 | 404 | if (!strcmp(RecordType(n).ToCString(), theName) || |
405 | !strcmp(RecordType(n).ToCString(), theShortName)) | |
2c25cc04 | 406 | { |
a7197ef3 | 407 | num = n; |
408 | errmess = new String("Complex Record n0.%d, member type %s not in alphabetic order"); | |
e119b6c3 | 409 | sprintf(txtmes, errmess->ToCString(), num0, theName); |
410 | ach->AddWarning(txtmes, errmess->ToCString()); | |
a7197ef3 | 411 | return Standard_False; |
412 | } | |
413 | } | |
414 | num = 0; | |
415 | errmess = new String("Complex Record n0.%d, member type %s not found"); | |
e119b6c3 | 416 | sprintf(txtmes, errmess->ToCString(), num0, theName); |
417 | ach->AddFail(txtmes, errmess->ToCString()); | |
a7197ef3 | 418 | return Standard_False; |
419 | } | |
420 | ||
7fd59977 | 421 | // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## |
422 | ||
423 | ||
424 | //======================================================================= | |
425 | //function : CheckNbParams | |
426 | //purpose : | |
427 | //======================================================================= | |
428 | ||
429 | Standard_Boolean StepData_StepReaderData::CheckNbParams(const Standard_Integer num, | |
e119b6c3 | 430 | const Standard_Integer nbreq, |
431 | Handle(Interface_Check)& ach, | |
432 | const Standard_CString mess) const | |
7fd59977 | 433 | { |
434 | if (NbParams(num) == nbreq) return Standard_True; | |
435 | Handle(String) errmess; | |
436 | if (mess[0] == '\0') errmess = new String("Count of Parameters is not %d"); | |
437 | else errmess = new String("Count of Parameters is not %d for %s"); | |
e119b6c3 | 438 | sprintf(txtmes, errmess->ToCString(), nbreq, mess); |
439 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 440 | return Standard_False; |
441 | } | |
442 | ||
443 | ||
444 | //======================================================================= | |
445 | //function : ReadSubList | |
446 | //purpose : | |
447 | //======================================================================= | |
448 | ||
449 | Standard_Boolean StepData_StepReaderData::ReadSubList(const Standard_Integer num, | |
e119b6c3 | 450 | const Standard_Integer nump, |
451 | const Standard_CString mess, | |
452 | Handle(Interface_Check)& ach, | |
453 | Standard_Integer& numsub, | |
454 | const Standard_Boolean optional, | |
455 | const Standard_Integer /* lenmin */, | |
456 | const Standard_Integer /* lenmax */) const | |
7fd59977 | 457 | { |
e119b6c3 | 458 | numsub = SubListNumber(num, nump, Standard_False); |
0df4bbd6 | 459 | if (numsub > 0) |
460 | { | |
461 | return (NbParams(numsub) > 0); | |
462 | } | |
e119b6c3 | 463 | // Si optionel indefini, on passe l eponge |
7fd59977 | 464 | numsub = 0; |
e119b6c3 | 465 | Standard_Boolean isvoid = (Param(num, nump).ParamType() == Interface_ParamVoid); |
7fd59977 | 466 | if (isvoid && optional) return Standard_False; |
467 | ||
468 | Handle(String) errmess = new String("Parameter n0.%d (%s) not a LIST"); | |
e119b6c3 | 469 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
470 | if (acceptvoid && isvoid) ach->AddWarning(txtmes, errmess->ToCString()); | |
471 | else { ach->AddFail(txtmes, errmess->ToCString()); return Standard_False; } | |
7fd59977 | 472 | return Standard_True; |
473 | } | |
474 | ||
475 | ||
476 | // ... Facilites pour LateBinding | |
477 | ||
478 | ||
479 | //======================================================================= | |
480 | //function : ReadSub | |
481 | //purpose : | |
482 | //======================================================================= | |
483 | ||
484 | Standard_Integer StepData_StepReaderData::ReadSub(const Standard_Integer numsub, | |
e119b6c3 | 485 | const Standard_CString mess, |
486 | Handle(Interface_Check)& ach, | |
487 | const Handle(StepData_PDescr)& descr, | |
488 | Handle(Standard_Transient)& val) const | |
7fd59977 | 489 | { |
490 | Standard_Integer nbp = NbParams(numsub); | |
491 | if (nbp == 0) return 0; // liste vide = Handle Null | |
e119b6c3 | 492 | const TCollection_AsciiString& rectyp = RecordType(numsub); |
7fd59977 | 493 | if (nbp == 1 && rectyp.ToCString()[0] != '(') { |
494 | // c est un type avec un parametre -> SelectNamed | |
495 | // cf ReadSelect mais ici, on est deja sur le contenu du parametre | |
496 | Handle(StepData_SelectNamed) sn = new StepData_SelectNamed; | |
497 | val = sn; | |
e119b6c3 | 498 | sn->SetName(rectyp.ToCString()); |
aa00364d | 499 | Handle(Standard_Transient) aSN = sn; |
e119b6c3 | 500 | if (ReadAny(numsub, 1, mess, ach, descr, aSN)) return sn->Kind(); |
7fd59977 | 501 | else return 0; |
502 | } | |
503 | ||
504 | // cas courant : faire un HArray1 de ... de ... de quoi au fait | |
e119b6c3 | 505 | const Interface_FileParameter& FP0 = Param(numsub, 1); |
7fd59977 | 506 | Interface_ParamType FT, FT0 = FP0.ParamType(); |
507 | Standard_CString str = FP0.CValue(); | |
508 | Handle(TColStd_HArray1OfTransient) htr; | |
509 | Handle(TColStd_HArray1OfInteger) hin; | |
510 | Handle(TColStd_HArray1OfReal) hre; | |
511 | Handle(Interface_HArray1OfHAsciiString) hst; | |
512 | Standard_Integer kod = 0; | |
513 | switch (FT0) { | |
e119b6c3 | 514 | case Interface_ParamMisc: return -1; |
515 | case Interface_ParamInteger: kod = 1; break; | |
516 | case Interface_ParamReal: kod = 5; break; | |
517 | case Interface_ParamIdent: kod = 7; break; | |
518 | case Interface_ParamVoid: kod = 0; break; | |
519 | case Interface_ParamText: kod = 6; break; | |
520 | case Interface_ParamEnum: kod = 4; break; // a confirmer(logical) | |
521 | /* kod = 4; | |
522 | if ( str[0] == '.' && str[2] == '.' && str[3] == '\0' && | |
523 | (str[1] == 'T' || str[1] == 'F' || str[1] == 'U') ) kod = 3; | |
524 | break; */ // svv #2 | |
525 | case Interface_ParamLogical: return -1; | |
526 | case Interface_ParamSub: kod = 0; break; | |
527 | case Interface_ParamHexa: return -1; | |
528 | case Interface_ParamBinary: return -1; | |
529 | default: return -1; | |
7fd59977 | 530 | } |
e119b6c3 | 531 | if (kod == 1 || kod == 3) { hin = new TColStd_HArray1OfInteger(1, nbp); val = hin; } |
532 | else if (kod == 5) { hre = new TColStd_HArray1OfReal(1, nbp); val = hre; } | |
533 | else if (kod == 6) { hst = new Interface_HArray1OfHAsciiString(1, nbp); val = hst; } | |
534 | else { htr = new TColStd_HArray1OfTransient(1, nbp); val = htr; } | |
535 | // Attention : si type variable, faudra changer son fusil d epaule -> htr | |
536 | ||
537 | for (Standard_Integer ip = 1; ip <= nbp; ip++) { | |
538 | const Interface_FileParameter& FP = Param(numsub, ip); | |
7fd59977 | 539 | str = FP.CValue(); |
e119b6c3 | 540 | FT = FP.ParamType(); |
7fd59977 | 541 | switch (kod) { |
e119b6c3 | 542 | case 1: { |
543 | if (FT != Interface_ParamInteger) { kod = 0; break; } | |
544 | hin->SetValue(ip, atoi(str)); break; | |
545 | } | |
546 | case 2: | |
547 | case 3: { | |
548 | if (FT != Interface_ParamEnum) { kod = 0; break; } | |
549 | if (!strcmp(str, ".F.")) hin->SetValue(ip, 0); | |
550 | else if (!strcmp(str, ".T.")) hin->SetValue(ip, 1); | |
551 | else if (!strcmp(str, ".U.")) hin->SetValue(ip, 2); | |
552 | else kod = 0; | |
553 | break; | |
554 | } | |
555 | case 4: { | |
556 | if (FT != Interface_ParamEnum) { kod = 0; break; } | |
557 | Handle(StepData_SelectNamed) sn = new StepData_SelectNamed; | |
558 | sn->SetEnum(-1, str); | |
559 | htr->SetValue(ip, sn); break; | |
560 | } | |
561 | case 5: { | |
562 | if (FT != Interface_ParamReal) { kod = 0; break; } | |
563 | hre->SetValue(ip, Interface_FileReaderData::Fastof(str)); break; | |
564 | } | |
565 | case 6: { | |
566 | if (FT != Interface_ParamText) { kod = 0; break; } | |
567 | Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str); | |
568 | CleanText(txt); hst->SetValue(ip, txt); break; | |
569 | } | |
570 | case 7: { | |
571 | Handle(Standard_Transient) ent = BoundEntity(FP.EntityNumber()); | |
572 | htr->SetValue(ip, ent); break; | |
7fd59977 | 573 | } |
e119b6c3 | 574 | default: break; |
575 | } | |
576 | // Restent les autres cas ... tout est possible. cf le type du Param | |
7fd59977 | 577 | if (kod > 0) continue; |
e119b6c3 | 578 | // Il faut passer au transient ... |
7fd59977 | 579 | if (htr.IsNull()) { |
e119b6c3 | 580 | htr = new TColStd_HArray1OfTransient(1, nbp); val = htr; |
581 | Standard_Integer jp; | |
7fd59977 | 582 | if (!hin.IsNull()) { |
e119b6c3 | 583 | for (jp = 1; jp < ip; jp++) { |
584 | Handle(StepData_SelectInt) sin = new StepData_SelectInt; | |
585 | sin->SetInt(hin->Value(jp)); | |
586 | htr->SetValue(jp, sin); | |
587 | } | |
7fd59977 | 588 | } |
589 | if (!hre.IsNull()) { | |
e119b6c3 | 590 | for (jp = 1; jp < ip; jp++) { |
591 | Handle(StepData_SelectReal) sre = new StepData_SelectReal; | |
592 | sre->SetReal(hre->Value(jp)); | |
593 | htr->SetValue(jp, sre); | |
594 | } | |
7fd59977 | 595 | } |
596 | if (!hst.IsNull()) { | |
e119b6c3 | 597 | for (jp = 1; jp < ip; jp++) { |
598 | htr->SetValue(jp, hst->Value(jp)); | |
599 | } | |
7fd59977 | 600 | } |
601 | } | |
e119b6c3 | 602 | // A present, faut y aller : lire le champ et le mettre en place |
603 | // Ce qui suit ressemble fortement a ReadAny ... | |
7fd59977 | 604 | |
605 | switch (FT) { | |
e119b6c3 | 606 | case Interface_ParamMisc: break; |
607 | case Interface_ParamInteger: { | |
7fd59977 | 608 | Handle(StepData_SelectInt) sin = new StepData_SelectInt; |
e119b6c3 | 609 | sin->SetInteger(atoi(str)); |
610 | htr->SetValue(ip, sin); break; | |
7fd59977 | 611 | } |
e119b6c3 | 612 | case Interface_ParamReal: { |
7fd59977 | 613 | Handle(StepData_SelectReal) sre = new StepData_SelectReal; |
e119b6c3 | 614 | sre->SetReal(Interface_FileReaderData::Fastof(str)); break; |
7fd59977 | 615 | //htr->SetValue (ip,sre); break; svv #2: unreachable |
616 | } | |
e119b6c3 | 617 | case Interface_ParamIdent: htr->SetValue(ip, BoundEntity(FP.EntityNumber())); break; |
618 | case Interface_ParamVoid: break; | |
619 | case Interface_ParamEnum: { | |
7fd59977 | 620 | Handle(StepData_SelectInt) sin; |
621 | Handle(StepData_SelectNamed) sna; | |
622 | Standard_Integer logic = -1; | |
e119b6c3 | 623 | // PTV 16.09.2000 |
624 | // set the default value of StepData_Logical | |
7fd59977 | 625 | StepData_Logical slog = StepData_LUnknown; |
e119b6c3 | 626 | if (str[0] == '.' && str[2] == '.' && str[3] == '\0') { |
627 | if (str[1] == 'F') { slog = StepData_LFalse; logic = 0; } | |
628 | else if (str[1] == 'T') { slog = StepData_LTrue; logic = 1; } | |
629 | else if (str[1] == 'U') { slog = StepData_LUnknown; logic = 2; } | |
7fd59977 | 630 | } |
631 | if (logic >= 0) | |
632 | { sin = new StepData_SelectInt; sin->SetLogical(slog); htr->SetValue(ip,sin); } | |
633 | else { sna = new StepData_SelectNamed; | |
634 | sna->SetEnum (logic,str); htr->SetValue (ip,sna); } | |
635 | break; | |
636 | } | |
e119b6c3 | 637 | case Interface_ParamLogical: break; |
638 | case Interface_ParamText: { | |
7fd59977 | 639 | Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str); |
e119b6c3 | 640 | CleanText(txt); htr->SetValue(ip, txt); break; |
7fd59977 | 641 | } |
e119b6c3 | 642 | case Interface_ParamSub: { |
7fd59977 | 643 | Handle(Standard_Transient) sub; |
644 | Standard_Integer nent = FP.EntityNumber(); | |
e119b6c3 | 645 | Standard_Integer kind = ReadSub(nent, mess, ach, descr, sub); if (kind < 0) break; |
646 | htr->SetValue(ip, sub); break; | |
7fd59977 | 647 | } |
e119b6c3 | 648 | case Interface_ParamHexa: break; |
649 | case Interface_ParamBinary: break; | |
650 | default: break; | |
7fd59977 | 651 | } |
652 | return -1; | |
653 | } | |
654 | return 8; // pour Any | |
655 | } | |
656 | ||
657 | ||
658 | //======================================================================= | |
659 | //function : ReadMember | |
660 | //purpose : | |
661 | //======================================================================= | |
662 | ||
663 | Standard_Boolean StepData_StepReaderData::ReadMember(const Standard_Integer num, | |
e119b6c3 | 664 | const Standard_Integer nump, |
665 | const Standard_CString mess, | |
666 | Handle(Interface_Check)& ach, | |
667 | Handle(StepData_SelectMember)& val) const | |
7fd59977 | 668 | { |
669 | Handle(Standard_Transient) v = val; | |
670 | Handle(StepData_PDescr) nuldescr; | |
aa00364d | 671 | if (v.IsNull()) |
672 | { | |
e119b6c3 | 673 | return ReadAny(num, nump, mess, ach, nuldescr, v) && |
674 | !(val = Handle(StepData_SelectMember)::DownCast(v)).IsNull(); | |
aa00364d | 675 | } |
e119b6c3 | 676 | Standard_Boolean res = ReadAny(num, nump, mess, ach, nuldescr, v); |
7fd59977 | 677 | if (v == val) return res; |
678 | // changement -> refus | |
679 | Handle(String) errmess = | |
680 | new String("Parameter n0.%d (%s) : does not match SELECT clause"); | |
e119b6c3 | 681 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
682 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 683 | return Standard_False; |
684 | } | |
685 | ||
686 | ||
687 | //======================================================================= | |
688 | //function : ReadField | |
689 | //purpose : | |
690 | //======================================================================= | |
691 | ||
692 | Standard_Boolean StepData_StepReaderData::ReadField(const Standard_Integer num, | |
e119b6c3 | 693 | const Standard_Integer nump, |
694 | const Standard_CString mess, | |
695 | Handle(Interface_Check)& ach, | |
696 | const Handle(StepData_PDescr)& descr, | |
697 | StepData_Field& fild) const | |
7fd59977 | 698 | { |
e119b6c3 | 699 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 700 | Standard_CString str = FP.CValue(); |
701 | Standard_Boolean OK = Standard_True; | |
702 | Standard_Integer nent, kind; | |
703 | Handle(TCollection_HAsciiString) txt; | |
704 | Handle(Standard_Transient) sub; | |
705 | Interface_ParamType FT = FP.ParamType(); | |
706 | switch (FT) { | |
e119b6c3 | 707 | case Interface_ParamMisc: OK = Standard_False; break; |
708 | case Interface_ParamInteger: fild.SetInteger(atoi(str)); break; | |
709 | case Interface_ParamReal: | |
710 | fild.SetReal(Interface_FileReaderData::Fastof(str)); break; | |
711 | case Interface_ParamIdent: | |
712 | nent = FP.EntityNumber(); | |
713 | if (nent > 0) fild.SetEntity(BoundEntity(nent)); | |
714 | break; | |
715 | case Interface_ParamVoid: break; | |
716 | case Interface_ParamText: | |
717 | txt = new TCollection_HAsciiString(str); | |
718 | CleanText(txt); fild.Set(txt); break; | |
719 | case Interface_ParamEnum: | |
720 | if (!strcmp(str, ".T.")) fild.SetLogical(StepData_LTrue); | |
721 | else if (!strcmp(str, ".F.")) fild.SetLogical(StepData_LFalse); | |
722 | else if (!strcmp(str, ".U.")) fild.SetLogical(StepData_LUnknown); | |
723 | else fild.SetEnum(-1, str); | |
724 | break; | |
725 | case Interface_ParamLogical: OK = Standard_False; break; | |
726 | case Interface_ParamSub: | |
727 | nent = FP.EntityNumber(); | |
728 | kind = ReadSub(nent, mess, ach, descr, sub); if (kind < 0) break; | |
729 | fild.Clear(kind); fild.Set(sub); break; | |
730 | case Interface_ParamHexa: OK = Standard_False; break; | |
731 | case Interface_ParamBinary: OK = Standard_False; break; | |
732 | default: OK = Standard_False; break; | |
7fd59977 | 733 | } |
734 | ||
735 | if (!OK) { | |
e119b6c3 | 736 | if (!strcmp(str, "*")) fild.SetDerived(); |
7fd59977 | 737 | } |
738 | return Standard_True; | |
739 | } | |
740 | ||
741 | ||
742 | //======================================================================= | |
743 | //function : ReadList | |
744 | //purpose : | |
745 | //======================================================================= | |
746 | ||
747 | Standard_Boolean StepData_StepReaderData::ReadList(const Standard_Integer num, | |
e119b6c3 | 748 | Handle(Interface_Check)& ach, |
749 | const Handle(StepData_ESDescr)& descr, | |
750 | StepData_FieldList& list) const | |
7fd59977 | 751 | { |
752 | // controler nbs egaux | |
e119b6c3 | 753 | Standard_Integer i, nb = list.NbFields(); |
754 | if (!CheckNbParams(num, nb, ach, descr->TypeName())) return Standard_False; | |
755 | for (i = 1; i <= nb; i++) { | |
7fd59977 | 756 | Handle(StepData_PDescr) pde = descr->Field(i); |
757 | StepData_Field& fild = list.CField(i); | |
e119b6c3 | 758 | ReadField(num, i, pde->Name(), ach, pde, fild); |
7fd59977 | 759 | } |
760 | return Standard_True; | |
761 | } | |
762 | ||
763 | ||
764 | //======================================================================= | |
765 | //function : ReadAny | |
766 | //purpose : | |
767 | //======================================================================= | |
768 | ||
769 | Standard_Boolean StepData_StepReaderData::ReadAny(const Standard_Integer num, | |
e119b6c3 | 770 | const Standard_Integer nump, |
771 | const Standard_CString mess, | |
772 | Handle(Interface_Check)& ach, | |
773 | const Handle(StepData_PDescr)& descr, | |
774 | Handle(Standard_Transient)& val) const | |
7fd59977 | 775 | { |
e119b6c3 | 776 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 777 | Standard_CString str = FP.CValue(); |
e119b6c3 | 778 | Interface_ParamType FT = FP.ParamType(); |
7fd59977 | 779 | |
e119b6c3 | 780 | // A present, faut y aller : lire le champ et le mettre en place |
7fd59977 | 781 | switch (FT) { |
e119b6c3 | 782 | case Interface_ParamMisc: break; |
783 | case Interface_ParamInteger: { | |
784 | if (!val.IsNull()) { | |
785 | DeclareAndCast(StepData_SelectMember, sm, val); | |
786 | sm->SetInteger(atoi(str)); | |
7fd59977 | 787 | return Standard_True; |
788 | } | |
e119b6c3 | 789 | Handle(StepData_SelectInt) sin = new StepData_SelectInt; |
790 | sin->SetInteger(atoi(str)); | |
791 | val = sin; | |
792 | return Standard_True; | |
793 | } | |
794 | case Interface_ParamReal: { | |
795 | if (!val.IsNull()) { | |
796 | DeclareAndCast(StepData_SelectMember, sm, val); | |
797 | sm->SetReal(Interface_FileReaderData::Fastof(str)); | |
7fd59977 | 798 | return Standard_True; |
799 | } | |
e119b6c3 | 800 | Handle(StepData_SelectReal) sre = new StepData_SelectReal; |
801 | sre->SetReal(Interface_FileReaderData::Fastof(str)); | |
802 | val = sre; | |
803 | return Standard_True; | |
804 | } | |
805 | case Interface_ParamIdent: { | |
806 | Standard_Integer nent = FP.EntityNumber(); | |
807 | if (nent > 0) val = BoundEntity(nent); | |
808 | return (!val.IsNull()); | |
809 | } | |
810 | case Interface_ParamVoid: break; | |
811 | case Interface_ParamEnum: { | |
812 | Handle(StepData_SelectMember) sm; | |
813 | if (!val.IsNull()) sm = GetCasted(StepData_SelectMember, val); | |
814 | Handle(StepData_SelectInt) sin; | |
815 | Handle(StepData_SelectNamed) sna; | |
816 | Standard_Integer logic = -1; | |
817 | ||
818 | // PTV 16.09.2000 | |
819 | // set the default value of StepData_Logical | |
820 | StepData_Logical slog = StepData_LUnknown; | |
821 | if (str[0] == '.' && str[2] == '.' && str[3] == '\0') { | |
822 | if (str[1] == 'F') { slog = StepData_LFalse; logic = 0; } | |
823 | else if (str[1] == 'T') { slog = StepData_LTrue; logic = 1; } | |
824 | else if (str[1] == 'U') { slog = StepData_LUnknown; logic = 2; } | |
7fd59977 | 825 | } |
e119b6c3 | 826 | if (logic >= 0) { |
827 | if (!sm.IsNull()) sm->SetLogical(slog); | |
7fd59977 | 828 | else { |
e119b6c3 | 829 | sin = new StepData_SelectInt; val = sin; |
830 | sin->SetLogical(slog); | |
831 | } | |
7fd59977 | 832 | } |
e119b6c3 | 833 | else { |
834 | if (!sm.IsNull()) sm->SetEnum(logic, str); | |
835 | else { | |
836 | sna = new StepData_SelectNamed; val = sna; // Named sans nom... | |
837 | sna->SetEnum(logic, str); | |
7fd59977 | 838 | } |
e119b6c3 | 839 | } // -> Select general |
840 | return Standard_True; | |
841 | } | |
842 | case Interface_ParamLogical: break; | |
843 | case Interface_ParamText: { | |
844 | Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str); | |
845 | CleanText(txt); | |
846 | ||
847 | // PDN May 2000: for reading SOURCE_ITEM (external references) | |
848 | if (!val.IsNull()) { | |
849 | DeclareAndCast(StepData_SelectMember, sm, val); | |
850 | sm->SetString(txt->ToCString()); | |
7fd59977 | 851 | return Standard_True; |
852 | } | |
e119b6c3 | 853 | |
854 | val = txt; | |
855 | return Standard_True; | |
856 | } | |
857 | case Interface_ParamSub: { | |
858 | Standard_Integer numsub = SubListNumber(num, nump, Standard_False); | |
859 | Standard_Integer nbp = NbParams(numsub); | |
860 | if (nbp == 0) return Standard_False; // liste vide = Handle Null | |
861 | const TCollection_AsciiString& rectyp = RecordType(numsub); | |
862 | if (nbp == 1 && rectyp.ToCString()[0] != '(') { | |
863 | // SelectNamed because Field !!! | |
864 | // skl 15.01.2003 (for members with array of real) | |
865 | DeclareAndCast(StepData_SelectArrReal, sma, val); | |
866 | if (!sma.IsNull()) { | |
867 | Standard_Integer numsub2 = SubListNumber(numsub, 1, Standard_False); | |
868 | Standard_Integer nbp2 = NbParams(numsub2); | |
869 | if (nbp2 > 1) { | |
870 | if (Param(numsub2, 1).ParamType() == Interface_ParamReal) { | |
871 | if (!sma->SetName(rectyp.ToCString())) return Standard_False; | |
872 | Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal; | |
873 | for (Standard_Integer i = 1; i <= nbp2; i++) { | |
874 | if (Param(numsub2, i).ParamType() != Interface_ParamReal) continue; | |
875 | Handle(Standard_Transient) asr = new StepData_SelectReal; | |
876 | if (!ReadAny(numsub2, i, mess, ach, descr, asr)) continue; | |
877 | Handle(StepData_SelectReal) sm1 = Handle(StepData_SelectReal)::DownCast(asr); | |
878 | if (!sm1.IsNull()) | |
879 | aSeq->Append(sm1->Real()); | |
880 | } | |
881 | Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1, aSeq->Length()); | |
882 | for (Standard_Integer nr = 1; nr <= aSeq->Length(); nr++) { | |
883 | anArr->SetValue(nr, aSeq->Value(nr)); | |
7fd59977 | 884 | } |
e119b6c3 | 885 | sma->SetArrReal(anArr); |
886 | return Standard_True; | |
7fd59977 | 887 | } |
888 | } | |
7fd59977 | 889 | } |
e119b6c3 | 890 | DeclareAndCast(StepData_SelectMember, sm, val); |
891 | if (sm.IsNull()) { | |
892 | sm = new StepData_SelectNamed; | |
893 | val = sm; | |
894 | } | |
895 | if (!sm->SetName(rectyp.ToCString())) return Standard_False; // loupe | |
896 | return ReadAny(numsub, 1, mess, ach, descr, val); | |
7fd59977 | 897 | } |
e119b6c3 | 898 | } |
899 | default: break; | |
7fd59977 | 900 | } |
901 | return Standard_False; | |
902 | } | |
903 | ||
904 | ||
905 | // .... | |
906 | ||
907 | ||
908 | //======================================================================= | |
909 | //function : ReadXY | |
910 | //purpose : | |
911 | //======================================================================= | |
912 | ||
913 | Standard_Boolean StepData_StepReaderData::ReadXY(const Standard_Integer num, | |
e119b6c3 | 914 | const Standard_Integer nump, |
915 | const Standard_CString mess, | |
916 | Handle(Interface_Check)& ach, | |
917 | Standard_Real& X, Standard_Real& Y) const | |
7fd59977 | 918 | { |
919 | Handle(String) errmess; // Null si pas d erreur | |
e119b6c3 | 920 | Standard_Integer numsub = SubListNumber(num, nump, Standard_False); |
7fd59977 | 921 | if (numsub != 0) { |
922 | if (NbParams(numsub) == 2) { | |
e119b6c3 | 923 | const Interface_FileParameter& FPX = Param(numsub, 1); |
7fd59977 | 924 | if (FPX.ParamType() == Interface_ParamReal) X = |
e119b6c3 | 925 | Interface_FileReaderData::Fastof(FPX.CValue()); |
7fd59977 | 926 | else errmess = new String("Parameter n0.%d (%s) : (X,Y) X not a Real"); |
927 | ||
e119b6c3 | 928 | const Interface_FileParameter& FPY = Param(numsub, 2); |
929 | if (FPY.ParamType() == Interface_ParamReal) Y = | |
930 | Interface_FileReaderData::Fastof(FPY.CValue()); | |
7fd59977 | 931 | else errmess = new String("Parameter n0.%d (%s) : (X,Y) Y not a Real"); |
932 | ||
933 | } | |
934 | else errmess = new String("Parameter n0.%d (%s) : (X,Y) has not 2 params"); | |
935 | } | |
936 | else errmess = new String("Parameter n0.%d (%s) : (X,Y) not a SubList"); | |
937 | ||
938 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 939 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
940 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 941 | return Standard_False; |
942 | } | |
943 | ||
944 | ||
945 | //======================================================================= | |
946 | //function : ReadXYZ | |
947 | //purpose : | |
948 | //======================================================================= | |
949 | ||
950 | Standard_Boolean StepData_StepReaderData::ReadXYZ(const Standard_Integer num, | |
e119b6c3 | 951 | const Standard_Integer nump, |
952 | const Standard_CString mess, | |
953 | Handle(Interface_Check)& ach, | |
954 | Standard_Real& X, Standard_Real& Y, | |
955 | Standard_Real& Z) const | |
7fd59977 | 956 | { |
957 | Handle(String) errmess; // Null si pas d erreur | |
e119b6c3 | 958 | Standard_Integer numsub = SubListNumber(num, nump, Standard_False); |
7fd59977 | 959 | if (numsub != 0) { |
960 | if (NbParams(numsub) == 3) { | |
e119b6c3 | 961 | const Interface_FileParameter& FPX = Param(numsub, 1); |
7fd59977 | 962 | if (FPX.ParamType() == Interface_ParamReal) X = |
e119b6c3 | 963 | Interface_FileReaderData::Fastof(FPX.CValue()); |
7fd59977 | 964 | else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) X not a Real"); |
965 | ||
e119b6c3 | 966 | const Interface_FileParameter& FPY = Param(numsub, 2); |
7fd59977 | 967 | if (FPY.ParamType() == Interface_ParamReal) Y = |
e119b6c3 | 968 | Interface_FileReaderData::Fastof(FPY.CValue()); |
7fd59977 | 969 | else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) Y not a Real"); |
970 | ||
e119b6c3 | 971 | const Interface_FileParameter& FPZ = Param(numsub, 3); |
7fd59977 | 972 | if (FPZ.ParamType() == Interface_ParamReal) Z = |
e119b6c3 | 973 | Interface_FileReaderData::Fastof(FPZ.CValue()); |
7fd59977 | 974 | else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) Z not a Real"); |
975 | ||
976 | } | |
977 | else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) has not 3 params"); | |
978 | } | |
979 | else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) not a SubList"); | |
980 | ||
981 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 982 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
983 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 984 | return Standard_False; |
985 | } | |
986 | ||
987 | ||
988 | //======================================================================= | |
989 | //function : ReadReal | |
990 | //purpose : | |
991 | //======================================================================= | |
992 | ||
993 | Standard_Boolean StepData_StepReaderData::ReadReal(const Standard_Integer num, | |
e119b6c3 | 994 | const Standard_Integer nump, |
995 | const Standard_CString mess, | |
996 | Handle(Interface_Check)& ach, | |
997 | Standard_Real& val) const | |
7fd59977 | 998 | { |
999 | Handle(String) errmess; // Null si pas d erreur | |
1000 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1001 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1002 | if (FP.ParamType() == Interface_ParamReal) val = |
1003 | Interface_FileReaderData::Fastof(FP.CValue()); | |
1004 | else errmess = new String("Parameter n0.%d (%s) not a Real"); | |
1005 | } | |
1006 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1007 | ||
1008 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1009 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1010 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1011 | return Standard_False; |
1012 | } | |
1013 | ||
1014 | ||
1015 | // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## | |
1016 | ||
1017 | ||
1018 | //======================================================================= | |
1019 | //function : ReadEntity | |
1020 | //purpose : | |
1021 | //======================================================================= | |
1022 | ||
1023 | Standard_Boolean StepData_StepReaderData::ReadEntity(const Standard_Integer num, | |
e119b6c3 | 1024 | const Standard_Integer nump, |
1025 | const Standard_CString mess, | |
1026 | Handle(Interface_Check)& ach, | |
1027 | const Handle(Standard_Type)& atype, | |
1028 | Handle(Standard_Transient)& ent) const | |
7fd59977 | 1029 | { |
1030 | Handle(String) errmess; // Null si pas d erreur | |
1031 | Standard_Boolean warn = Standard_False; | |
1032 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1033 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1034 | Standard_Integer nent = FP.EntityNumber(); |
1035 | if (FP.ParamType() == Interface_ParamIdent) { | |
1036 | warn = (acceptvoid > 0); | |
1037 | if (nent > 0) { | |
e119b6c3 | 1038 | Handle(Standard_Transient) entent = BoundEntity(nent); |
1039 | if (entent.IsNull() || !entent->IsKind(atype)) | |
1040 | errmess = new String("Parameter n0.%d (%s) : Entity has illegal type"); | |
1041 | else ent = entent; | |
7fd59977 | 1042 | } |
1043 | else errmess = new String("Parameter n0.%d (%s) : Unresolved reference"); | |
1044 | } | |
1045 | else { | |
1046 | if (acceptvoid && FP.ParamType() == Interface_ParamVoid) warn = Standard_True; | |
1047 | errmess = new String("Parameter n0.%d (%s) not an Entity"); | |
1048 | } | |
1049 | } | |
1050 | else { | |
1051 | warn = (acceptvoid > 0); | |
1052 | errmess = new String("Parameter n0.%d (%s) absent"); | |
1053 | } | |
1054 | ||
1055 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1056 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1057 | if (warn) ach->AddWarning(txtmes, errmess->ToCString()); | |
1058 | else ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1059 | return Standard_False; |
1060 | } | |
1061 | ||
1062 | ||
1063 | //======================================================================= | |
1064 | //function : ReadEntity | |
1065 | //purpose : | |
1066 | //======================================================================= | |
1067 | ||
1068 | Standard_Boolean StepData_StepReaderData::ReadEntity(const Standard_Integer num, | |
e119b6c3 | 1069 | const Standard_Integer nump, |
1070 | const Standard_CString mess, | |
1071 | Handle(Interface_Check)& ach, | |
1072 | StepData_SelectType& sel) const | |
7fd59977 | 1073 | { |
1074 | Handle(String) errmess; // Null si pas d erreur | |
1075 | Standard_Boolean warn = Standard_False; | |
1076 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1077 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1078 | Standard_Integer nent = FP.EntityNumber(); |
1079 | if (FP.ParamType() == Interface_ParamIdent) { | |
1080 | warn = (acceptvoid > 0); | |
1081 | if (nent > 0) { | |
e119b6c3 | 1082 | Handle(Standard_Transient) entent = BoundEntity(nent); |
1083 | if (!sel.Matches(entent)) | |
1084 | errmess = new String("Parameter n0.%d (%s) : Entity has illegal type"); | |
1085 | else | |
7fd59977 | 1086 | sel.SetValue(entent); |
1087 | } | |
1088 | else | |
1089 | errmess = new String("Parameter n0.%d (%s) : Unresolved reference"); | |
1090 | } | |
1091 | else if (FP.ParamType() == Interface_ParamVoid) { | |
1092 | if (acceptvoid) warn = Standard_True; | |
1093 | errmess = new String("Parameter n0.%d (%s) not an Entity"); | |
1094 | } | |
1095 | else { | |
1096 | // Cas restant : on s interesse en fait au SelectMember ... | |
1097 | Handle(Standard_Transient) sm = sel.NewMember(); | |
1098 | // SelectMember qui assure ce role. Peut etre specialise | |
e119b6c3 | 1099 | if (!ReadAny(num, nump, mess, ach, sel.Description(), sm)) |
1100 | errmess = new String("Parameter n0.%d (%s) : could not be read"); | |
7fd59977 | 1101 | if (!sel.Matches(sm)) |
e119b6c3 | 1102 | errmess = new String("Parameter n0.%d (%s) : illegal parameter type"); |
7fd59977 | 1103 | else |
1104 | sel.SetValue(sm); | |
1105 | } | |
1106 | } | |
1107 | else { | |
1108 | warn = (acceptvoid > 0); | |
1109 | errmess = new String("Parameter n0.%d (%s) absent"); | |
1110 | } | |
1111 | ||
1112 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1113 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1114 | if (warn) ach->AddWarning(txtmes, errmess->ToCString()); | |
1115 | else ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1116 | return Standard_False; |
1117 | } | |
1118 | ||
1119 | ||
1120 | // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## | |
1121 | ||
1122 | ||
1123 | //======================================================================= | |
1124 | //function : ReadInteger | |
1125 | //purpose : | |
1126 | //======================================================================= | |
1127 | ||
1128 | Standard_Boolean StepData_StepReaderData::ReadInteger(const Standard_Integer num, | |
e119b6c3 | 1129 | const Standard_Integer nump, |
1130 | const Standard_CString mess, | |
1131 | Handle(Interface_Check)& ach, | |
1132 | Standard_Integer& val) const | |
7fd59977 | 1133 | { |
1134 | Handle(String) errmess; // Null si pas d erreur | |
1135 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1136 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1137 | if (FP.ParamType() == Interface_ParamInteger) val = atoi(FP.CValue()); |
1138 | else errmess = new String("Parameter n0.%d (%s) not an Integer"); | |
1139 | } | |
1140 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1141 | ||
1142 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1143 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1144 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1145 | return Standard_False; |
1146 | } | |
1147 | ||
1148 | ||
1149 | //======================================================================= | |
1150 | //function : ReadBoolean | |
1151 | //purpose : | |
1152 | //======================================================================= | |
1153 | ||
1154 | Standard_Boolean StepData_StepReaderData::ReadBoolean(const Standard_Integer num, | |
e119b6c3 | 1155 | const Standard_Integer nump, |
1156 | const Standard_CString mess, | |
1157 | Handle(Interface_Check)& ach, | |
1158 | Standard_Boolean& flag) const | |
7fd59977 | 1159 | { |
e119b6c3 | 1160 | flag = Standard_True; |
7fd59977 | 1161 | Handle(String) errmess; // Null si pas d erreur |
1162 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1163 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1164 | if (FP.ParamType() == Interface_ParamEnum) { |
1165 | Standard_CString txt = FP.CValue(); | |
e119b6c3 | 1166 | if (!strcmp(txt, ".T.")) flag = Standard_True; |
1167 | else if (!strcmp(txt, ".F.")) flag = Standard_False; | |
1168 | else errmess = new String("Parameter n0.%d (%s) : Incorrect Boolean Value. It was set to true"); | |
7fd59977 | 1169 | } |
e119b6c3 | 1170 | else errmess = new String("Parameter n0.%d (%s) not a Boolean. It was set to true"); |
7fd59977 | 1171 | } |
e119b6c3 | 1172 | else errmess = new String("Parameter n0.%d (%s) absent.It was set to true"); |
7fd59977 | 1173 | |
1174 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1175 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1176 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1177 | return Standard_False; |
1178 | } | |
1179 | ||
1180 | ||
1181 | //======================================================================= | |
1182 | //function : ReadLogical | |
1183 | //purpose : | |
1184 | //======================================================================= | |
1185 | ||
1186 | Standard_Boolean StepData_StepReaderData::ReadLogical(const Standard_Integer num, | |
e119b6c3 | 1187 | const Standard_Integer nump, |
1188 | const Standard_CString mess, | |
1189 | Handle(Interface_Check)& ach, | |
1190 | StepData_Logical& flag) const | |
7fd59977 | 1191 | { |
1192 | Handle(String) errmess; // Null si pas d erreur | |
1193 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1194 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1195 | if (FP.ParamType() == Interface_ParamEnum) { |
1196 | Standard_CString txt = FP.CValue(); | |
e119b6c3 | 1197 | if (!strcmp(txt, ".T.")) flag = StepData_LTrue; |
1198 | else if (!strcmp(txt, ".F.")) flag = StepData_LFalse; | |
1199 | else if (!strcmp(txt, ".U.")) flag = StepData_LUnknown; | |
7fd59977 | 1200 | else errmess = new String("Parameter n0.%d (%s) : Incorrect Logical Value"); |
1201 | } | |
1202 | else errmess = new String("Parameter n0.%d (%s) not a Logical"); | |
1203 | } | |
1204 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1205 | ||
1206 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1207 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1208 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1209 | return Standard_False; |
1210 | } | |
1211 | ||
1212 | ||
1213 | //======================================================================= | |
1214 | //function : ReadString | |
1215 | //purpose : | |
1216 | //======================================================================= | |
1217 | ||
1218 | Standard_Boolean StepData_StepReaderData::ReadString(const Standard_Integer num, | |
e119b6c3 | 1219 | const Standard_Integer nump, |
1220 | const Standard_CString mess, | |
1221 | Handle(Interface_Check)& ach, | |
1222 | Handle(TCollection_HAsciiString)& val) const | |
7fd59977 | 1223 | { |
1224 | Handle(String) errmess; // Null si pas d erreur | |
1225 | Standard_Boolean warn = Standard_False; | |
1226 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1227 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1228 | if (FP.ParamType() == Interface_ParamText) { |
1229 | /*Standard_CString anStr = FP.CValue(); | |
1230 | if(strlen(anStr) < 3) | |
1231 | val = new TCollection_HAsciiString(""); | |
1232 | else { | |
1233 | val = new TCollection_HAsciiString(FP.CValue()); | |
1234 | CleanText (val); | |
1235 | }*/ | |
1236 | val = new TCollection_HAsciiString(FP.CValue()); | |
e119b6c3 | 1237 | CleanText(val); |
7fd59977 | 1238 | } else { |
1239 | if (acceptvoid && FP.ParamType() == Interface_ParamVoid) warn = Standard_True; | |
1240 | errmess = new String("Parameter n0.%d (%s) not a quoted String"); | |
1241 | } | |
1242 | } | |
1243 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1244 | ||
1245 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1246 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1247 | if (warn) ach->AddWarning(txtmes, errmess->ToCString()); | |
1248 | else ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1249 | return Standard_False; |
1250 | } | |
1251 | ||
1252 | ||
1253 | //======================================================================= | |
1254 | //function : ReadEnumParam | |
1255 | //purpose : | |
1256 | //======================================================================= | |
1257 | ||
1258 | Standard_Boolean StepData_StepReaderData::ReadEnumParam(const Standard_Integer num, | |
e119b6c3 | 1259 | const Standard_Integer nump, |
1260 | const Standard_CString mess, | |
1261 | Handle(Interface_Check)& ach, | |
1262 | Standard_CString& text) const | |
7fd59977 | 1263 | { |
1264 | Handle(String) errmess; // Null si pas d erreur | |
1265 | Standard_Boolean warn = Standard_False; | |
1266 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1267 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1268 | if (FP.ParamType() == Interface_ParamEnum) { |
1269 | text = FP.CValue(); | |
1270 | warn = (acceptvoid > 0); | |
1271 | } else if (FP.ParamType() == Interface_ParamVoid) { | |
1272 | errmess = | |
e119b6c3 | 1273 | new String("Parameter n0.%d (%s) : Undefined Enumeration not allowed"); |
7fd59977 | 1274 | warn = (acceptvoid > 0); |
1275 | } | |
1276 | else errmess = new String("Parameter n0.%d (%s) not an Enumeration"); | |
1277 | } | |
1278 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1279 | ||
1280 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1281 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1282 | if (warn) ach->AddWarning(txtmes, errmess->ToCString()); | |
1283 | else ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1284 | return Standard_False; |
1285 | } | |
1286 | ||
1287 | ||
1288 | //======================================================================= | |
1289 | //function : FailEnumValue | |
1290 | //purpose : | |
1291 | //======================================================================= | |
1292 | ||
1293 | void StepData_StepReaderData::FailEnumValue(const Standard_Integer /* num */, | |
e119b6c3 | 1294 | const Standard_Integer nump, |
1295 | const Standard_CString mess, | |
1296 | Handle(Interface_Check)& ach) const | |
7fd59977 | 1297 | { |
1298 | Handle(String) errmess = | |
1299 | new String("Parameter n0.%d (%s) : Incorrect Enumeration Value"); | |
e119b6c3 | 1300 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1301 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1302 | } |
1303 | ||
1304 | ||
1305 | //======================================================================= | |
1306 | //function : ReadEnum | |
1307 | //purpose : | |
1308 | //======================================================================= | |
1309 | ||
1310 | Standard_Boolean StepData_StepReaderData::ReadEnum(const Standard_Integer num, | |
e119b6c3 | 1311 | const Standard_Integer nump, |
1312 | const Standard_CString mess, | |
1313 | Handle(Interface_Check)& ach, | |
1314 | const StepData_EnumTool& enumtool, | |
1315 | Standard_Integer& val) const | |
7fd59977 | 1316 | { |
e119b6c3 | 1317 | // reprendre avec ReadEnumParam ? |
7fd59977 | 1318 | Handle(String) errmess; // Null si pas d erreur |
1319 | Standard_Boolean warn = Standard_False; | |
1320 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1321 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1322 | if (FP.ParamType() == Interface_ParamEnum) { |
e119b6c3 | 1323 | val = enumtool.Value(FP.CValue()); |
7fd59977 | 1324 | if (val >= 0) return Standard_True; |
1325 | else errmess = new String("Parameter n0.%d (%s) : Incorrect Enumeration Value"); | |
1326 | warn = (acceptvoid > 0); | |
1327 | } | |
1328 | else if (FP.ParamType() == Interface_ParamVoid) { | |
1329 | val = enumtool.NullValue(); | |
1330 | if (val < 0) errmess = | |
e119b6c3 | 1331 | new String("Parameter n0.%d (%s) : Undefined Enumeration not allowed"); |
7fd59977 | 1332 | warn = (acceptvoid > 0); |
1333 | } | |
1334 | else errmess = new String("Parameter n0.%d (%s) not an Enumeration"); | |
1335 | } | |
1336 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1337 | ||
1338 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1339 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
7fd59977 | 1340 | if (warn) |
e119b6c3 | 1341 | ach->AddWarning(txtmes, errmess->ToCString()); |
1342 | else | |
1343 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1344 | return Standard_False; |
1345 | } | |
1346 | ||
1347 | ||
1348 | //======================================================================= | |
1349 | //function : ReadTypedParam | |
1350 | //purpose : | |
1351 | //======================================================================= | |
1352 | ||
1353 | Standard_Boolean StepData_StepReaderData::ReadTypedParam(const Standard_Integer num, | |
e119b6c3 | 1354 | const Standard_Integer nump, |
1355 | const Standard_Boolean mustbetyped, | |
1356 | const Standard_CString mess, | |
1357 | Handle(Interface_Check)& ach, | |
1358 | Standard_Integer& numr, | |
1359 | Standard_Integer& numrp, | |
1360 | TCollection_AsciiString& typ) const | |
7fd59977 | 1361 | { |
1362 | Handle(String) errmess; // Null si pas d erreur | |
1363 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1364 | const Interface_FileParameter& FP = Param(num, nump); |
7fd59977 | 1365 | if (FP.ParamType() != Interface_ParamSub) { |
1366 | // Pas une sous-liste : OK si admis | |
1367 | numr = num; numrp = nump; typ.Clear(); | |
1368 | if (mustbetyped) { | |
e119b6c3 | 1369 | errmess = new String("Parameter n0.%d (%s) : single, not typed"); |
1370 | sprintf(txtmes, errmess->ToCString(), nump, mess); | |
1371 | ach->AddFail(txtmes, errmess->ToCString()); | |
1372 | return Standard_False; | |
7fd59977 | 1373 | } |
1374 | return Standard_True; | |
1375 | } | |
1376 | numr = FP.EntityNumber(); numrp = 1; | |
1377 | if (NbParams(numr) != 1) errmess = | |
1378 | new String("Parameter n0.%d (%s) : SubList, not typed"); | |
1379 | typ = RecordType(numr); | |
1380 | } | |
1381 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1382 | ||
1383 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1384 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1385 | ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1386 | return Standard_False; |
1387 | } | |
1388 | ||
1389 | ||
1390 | //======================================================================= | |
1391 | //function : CheckDerived | |
1392 | //purpose : | |
1393 | //======================================================================= | |
1394 | ||
1395 | Standard_Boolean StepData_StepReaderData::CheckDerived(const Standard_Integer num, | |
e119b6c3 | 1396 | const Standard_Integer nump, |
1397 | const Standard_CString mess, | |
1398 | Handle(Interface_Check)& ach, | |
1399 | const Standard_Boolean errstat) const | |
7fd59977 | 1400 | { |
1401 | Handle(String) errmess; // Null si pas d erreur | |
1402 | Standard_Boolean warn = !errstat; | |
1403 | if (nump > 0 && nump <= NbParams(num)) { | |
e119b6c3 | 1404 | if (!strcmp(Param(num, nump).CValue(), "*")) return Standard_True; |
7fd59977 | 1405 | else errmess = new String("Parameter n0.%d (%s) not Derived"); |
1406 | if (acceptvoid) warn = Standard_True; | |
1407 | } | |
1408 | else errmess = new String("Parameter n0.%d (%s) absent"); | |
1409 | ||
1410 | if (errmess.IsNull()) return Standard_True; | |
e119b6c3 | 1411 | sprintf(txtmes, errmess->ToCString(), nump, mess); |
1412 | if (warn) ach->AddWarning(txtmes, errmess->ToCString()); | |
1413 | else ach->AddFail(txtmes, errmess->ToCString()); | |
7fd59977 | 1414 | return Standard_False; |
1415 | } | |
1416 | ||
1417 | ||
1418 | // ######################################################################### | |
1419 | // .... Methodes specifiques (demandees par FileReaderData) .... // | |
1420 | ||
1421 | ||
1422 | //======================================================================= | |
1423 | //function : NbEntities | |
1424 | //purpose : | |
1425 | //======================================================================= | |
1426 | ||
e119b6c3 | 1427 | Standard_Integer StepData_StepReaderData::NbEntities() const // redefined |
7fd59977 | 1428 | { |
1429 | return thenbents; | |
1430 | } | |
1431 | ||
1432 | ||
1433 | //======================================================================= | |
1434 | //function : FindNextRecord | |
1435 | //purpose : | |
1436 | //======================================================================= | |
1437 | ||
1438 | Standard_Integer StepData_StepReaderData::FindNextRecord | |
e119b6c3 | 1439 | (const Standard_Integer num) const |
7fd59977 | 1440 | { |
1441 | // retourne, sur un numero d enregistrement donne (par num), le suivant qui | |
1442 | // definit une entite, ou 0 si c est fini : | |
1443 | // passe le Header (nbhend premiers records) et | |
1444 | // saute les enregistrements SCOPE et ENDSCOPE et les SOUS-LISTES | |
1445 | ||
e119b6c3 | 1446 | if (num < 0) return 0; |
1447 | Standard_Integer num1 = num + 1; if (num == 0) num1 = thenbhead + 1; | |
1448 | Standard_Integer max = NbRecords(); | |
7fd59977 | 1449 | |
e119b6c3 | 1450 | while (num1 <= max) { |
7fd59977 | 1451 | if (theidents(num1) > 0) return num1; |
1452 | ||
1453 | // SCOPE,ENDSCOPE et Sous-Liste ont un identifieur fictif: -1,-2 respectivement | |
1454 | // et SUBLIST ont un negatif. Seule une vraie entite a un Ident positif | |
e119b6c3 | 1455 | num1++; |
7fd59977 | 1456 | } |
1457 | return 0; | |
1458 | } | |
1459 | ||
1460 | ||
1461 | //======================================================================= | |
1462 | //function : FindEntityNumber | |
1463 | //purpose : | |
1464 | //======================================================================= | |
1465 | ||
1466 | Standard_Integer StepData_StepReaderData::FindEntityNumber(const Standard_Integer num, | |
e119b6c3 | 1467 | const Standard_Integer id) const |
7fd59977 | 1468 | { |
1469 | // Soit un "Id" : recherche dans les Parametres de type Ident de <num>, | |
1470 | // si un d eux designe #Id justement. Si oui, retourne son EntityNumber | |
1471 | if (num == 0) return 0; | |
1472 | Standard_Integer nb = NbParams(num); | |
e119b6c3 | 1473 | for (Standard_Integer i = 1; i <= nb; i++) { |
1474 | const Interface_FileParameter& FP = Param(num, i); | |
7fd59977 | 1475 | if (FP.ParamType() != Interface_ParamIdent) continue; |
e119b6c3 | 1476 | Standard_Integer ixp = atoi(&FP.CValue()[1]); |
7fd59977 | 1477 | if (ixp == id) return FP.EntityNumber(); |
1478 | } | |
1479 | return 0; // ici, pas trouve | |
1480 | } | |
1481 | ||
1482 | ||
1483 | // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## | |
1484 | // .... La fonction qui suit merite une attention speciale .... | |
1485 | ||
1486 | ||
1487 | // Cette methode precharge les EntityNumbers dans les Params : ils designent | |
1488 | // les Entites proprement dites dans la liste lue par BoundEntity | |
1489 | // Interet : adresse de meme les sous-listes (Num->no record dans le Direc) | |
1490 | // resultat exploite par ParamEntity et ParamNumber | |
1491 | ||
1492 | // En l absence de SCOPE, ou si les "ident" sont strictement ordonnes, a coup | |
1493 | // sur ils ne sont pas dupliques, on peut utiliser une IndexedMap en toute | |
1494 | // confiance. Sinon, il faut balayer dans le fichier, mais avec les SCOPES | |
1495 | // cela va beaucoup plus vite (s ils sont assez gros) : on s y retrouve. | |
1496 | ||
1497 | // Pour la recherche par balayage, On opere en plusieurs etapes | |
1498 | // Avant toute chose, le chargement a deja fait une preparation : les idents | |
1499 | // (Entity, SubList) sont deja en entiers (rapidite de lecture), en particulier | |
1500 | // dans les EntityNumber : ainsi, on lit cet ident, on le traite, et on remet | |
1501 | // a la place un vrai numero de Record | |
1502 | // | |
1503 | // D abord, on passe le directory en table d entiers, sous-listes expurgees | |
1504 | // en // , table inverse vers cette table, car les sous-listes peuvent par | |
1505 | // contre designer des objets ... | |
1506 | ||
1507 | // Pour les sous-listes, on exploite leur mode de construction : elles sont | |
1508 | // enregistrees AVANT d etre referencees. Un tableau "subn" note donc pour | |
1509 | // chaque numero de sous-liste (relatif a une entite qui suit, et reference | |
1510 | // par elle ou une autre sous-liste qui suit egalement), son n0 de record | |
1511 | // REMARQUE : ceci marche aussi pour le Header, traite par l occasion | |
1512 | ||
1513 | ||
1514 | //======================================================================= | |
1515 | //function : SetEntityNumbers | |
1516 | //purpose : | |
1517 | //======================================================================= | |
1518 | ||
1519 | void StepData_StepReaderData::SetEntityNumbers(const Standard_Boolean withmap) | |
1520 | { | |
1521 | Handle(Message_Messenger) sout = Message::DefaultMessenger(); | |
e119b6c3 | 1522 | // Passe initiale : Resolution directe par Map |
1523 | // si tout passe (pas de collision), OK. Sinon, autres passes a prevoir | |
1524 | // On resoud du meme coup les sous-listes | |
1525 | Standard_Integer nbdirec = NbRecords(); | |
1d37eeb6 | 1526 | TColStd_Array1OfInteger subn(0, thelastn); |
7fd59977 | 1527 | |
1528 | Standard_Boolean pbmap = Standard_False; // au moins un conflit | |
1529 | Standard_Integer nbmap = 0; | |
1530 | TColStd_IndexedMapOfInteger imap(thenbents); | |
1d37eeb6 | 1531 | TColStd_Array1OfInteger indm(0, nbdirec); // Index Map -> Record Number (seulement si map) |
7fd59977 | 1532 | |
1533 | Standard_Integer num; // svv Jan11 2000 : porting on DEC | |
e119b6c3 | 1534 | for (num = 1; num <= nbdirec; num++) { |
7fd59977 | 1535 | Standard_Integer ident = theidents(num); |
1536 | if (ident > 0) { // Ident normal -> Map ? | |
1537 | // Map : si Recouvrement, l inhiber. Sinon, noter index | |
1538 | Standard_Integer indmap = imap.Add(ident); | |
1539 | if (indmap <= nbmap) { | |
e119b6c3 | 1540 | indmap = imap.FindIndex(ident); // plus sur |
1541 | indm(indmap) = -1; // Map -> pb | |
1542 | pbmap = Standard_True; | |
1543 | // pbmap signifie qu une autre passe sera necessaire ... | |
7fd59977 | 1544 | } else { |
e119b6c3 | 1545 | nbmap = indmap; |
1546 | indm(indmap) = num; // Map ->ident | |
7fd59977 | 1547 | } |
1548 | } | |
1549 | } | |
1550 | ||
e119b6c3 | 1551 | for (num = 1; num <= nbdirec; num++) { |
7fd59977 | 1552 | Standard_Integer ident = theidents(num); |
e119b6c3 | 1553 | if (ident < -2) subn(-(ident + 2)) = num; // toujours a jour ... |
1554 | ||
1555 | Standard_Integer nba = NbParams(num); | |
1556 | Standard_Integer nda = (num == 1 ? 0 : ParamFirstRank(num - 1)); | |
1557 | ||
1558 | for (Standard_Integer na = nba; na > 0; na--) { | |
1559 | // On traite : les sous-listes (sf subn), les idents (si Map dit OK ...) | |
1560 | Interface_FileParameter& FP = ChangeParameter(nda + na); | |
1561 | // Interface_FileParameter& FP = ChangeParam (num,na); | |
7fd59977 | 1562 | Interface_ParamType letype = FP.ParamType(); |
1563 | if (letype == Interface_ParamSub) { | |
e119b6c3 | 1564 | Standard_Integer numsub = FP.EntityNumber(); |
1565 | if (numsub > thelastn) { | |
1566 | sout << "Bad Sub.N0, Record " << num << " Param " << na << ":$" << numsub << endl; | |
1567 | continue; | |
1568 | } | |
1d37eeb6 | 1569 | FP.SetEntityNumber(subn(numsub)); |
7fd59977 | 1570 | } else if (letype == Interface_ParamIdent) { |
e119b6c3 | 1571 | Standard_Integer id = FP.EntityNumber(); |
1572 | Standard_Integer indmap = imap.FindIndex(id); | |
1573 | if (indmap > 0) { // la map a trouve | |
1574 | Standard_Integer num0 = indm(indmap); | |
1575 | if (num0 > 0) FP.SetEntityNumber(num0); // ET VOILA, on a resolu | |
1576 | else FP.SetEntityNumber(-id); // CONFLIT -> faudra resoudre ... | |
7fd59977 | 1577 | } else { // NON RESOLU, si pas pbmap, le dire |
e119b6c3 | 1578 | FP.SetEntityNumber(-id); |
1579 | if (pbmap) continue; // pbmap : on se retrouvera | |
1580 | char failmess[100]; | |
1581 | // ... Construire le Check ... | |
1582 | sprintf(failmess, | |
1583 | "Unresolved Reference, Ent.Id.#%d Param.n0 %d (Id.#%d)", | |
1584 | ident, na, id); | |
1585 | thecheck->AddFail(failmess, "Unresolved Reference"); | |
1586 | // ... Et sortir message un peu plus complet | |
1587 | sout << "*** ERR StepReaderData *** Pour Entite #" << ident | |
1588 | << "\n Type:" << RecordType(num) | |
1589 | << " Param.n0 " << na << ": #" << id << " Non trouve" << endl; | |
1590 | } // FIN Mapping | |
7fd59977 | 1591 | } // FIN Traitement Reference |
1592 | } // FIN Boucle Parametres | |
1593 | } // FIN Boucle Repertoires | |
1594 | ||
7fd59977 | 1595 | if (!pbmap) { |
1d37eeb6 | 1596 | return; |
7fd59977 | 1597 | } |
1598 | sout << " -- 2nd pass required --"; | |
1599 | ||
e119b6c3 | 1600 | Standard_Integer nbseq = thenbents + 2 * thenbscop; |
1d37eeb6 D |
1601 | TColStd_Array1OfInteger inds(0, nbseq); // n0 Record/Entite |
1602 | TColStd_Array1OfInteger indi(0, nbseq); // Idents/scopes | |
1603 | TColStd_Array1OfInteger indr(0, nbdirec); // inverse de nds | |
1604 | Handle(TColStd_HArray1OfInteger) indx; // pour EXPORT (silya) | |
7fd59977 | 1605 | |
1606 | imap.Clear(); | |
1607 | Standard_Boolean iamap = withmap; // (par defaut True) | |
1608 | nbmap = 0; | |
1609 | ||
1610 | TColStd_SequenceOfInteger scopile; // chainage des scopes note par pile | |
e119b6c3 | 1611 | Standard_Integer nr = 0; |
1612 | for (num = 1; num <= nbdirec; num++) { | |
7fd59977 | 1613 | Standard_Integer ident = theidents(num); |
1614 | if (ident < -2) { // SOUS-LISTE (cas le plus courant) | |
1d37eeb6 | 1615 | indr(num) = nr + 1; // recherche basee sur nr (objet qui suit) |
7fd59977 | 1616 | } else if (ident >= 0) { // Ident normal |
e119b6c3 | 1617 | nr++; inds(nr) = num; indi(nr) = ident; indr(num) = nr; |
7fd59977 | 1618 | if (ident > 0) { // et non (iamap && ident > 0) |
1619 | // Map : si Recouvrement, l inhiber. Sinon, noter index | |
e119b6c3 | 1620 | Standard_Integer indmap = imap.Add(ident); |
1621 | if (indmap <= nbmap) { | |
1622 | Standard_Boolean errorscope = Standard_False; | |
1623 | indmap = imap.FindIndex(ident); // plus sur | |
1624 | pbmap = Standard_True; | |
1625 | if (thenbscop == 0) errorscope = Standard_True; | |
1626 | // Numeros identiques alors quilnya pas de SCOPE ? ERREUR ! | |
1627 | // (Bien sur, silya des SCOPES, on passe au travers, mais bon...) | |
1628 | else { | |
1629 | // Silya des SCOPES, tachons d y voir de plus pres pour signaler un probleme | |
1630 | // Erreur si MEME groupe SCOPE | |
1631 | // ATTENTION, on recherche, non dans tous les records, mais dans les records | |
1632 | // CHAINES, cf nr et non num (pas de sous-liste, chainage scope-endscope) | |
1633 | Standard_Integer fromscope = nr; | |
1634 | Standard_Integer toscope = indm(indmap); | |
1635 | if (toscope < 0) toscope = -toscope; | |
1636 | for (;;) { | |
1637 | fromscope--; // iteration de base | |
1638 | if (fromscope <= toscope) { | |
1639 | errorscope = Standard_True; // BANG, on est dessus | |
1640 | break; | |
1641 | } | |
1642 | Standard_Integer idtest = indi(fromscope); | |
1643 | if (idtest >= 0) continue; // le suivant (enfin, le precedent) | |
1644 | if (idtest == -1) break; // pas meme niveau, donc c est OK | |
1645 | if (idtest == -3) { | |
1646 | fromscope = inds(fromscope); | |
1647 | if (fromscope < toscope) break; // on sort, pas en meme niveau | |
1648 | } | |
1649 | } | |
1650 | } | |
1651 | if (errorscope) { | |
1652 | // On est dedans : le signaler | |
1653 | char ligne[80]; | |
1654 | sprintf(ligne, "Ident defined SEVERAL TIMES : #%d", ident); | |
1655 | thecheck->AddFail(ligne, "Ident defined SEVERAL TIMES : #%d"); | |
1656 | sout << "StepReaderData:SetEntityNumbers, " << ligne << endl; | |
1657 | } | |
1658 | if (indm(indmap) > 0) indm(indmap) = -indm(indmap); // Pas pour Map | |
1659 | // Cas Normal pour la Map | |
7fd59977 | 1660 | } else { |
1661 | nbmap = indmap; | |
1d37eeb6 | 1662 | indm(indmap) = nr; // Map ->(indm)->inds |
7fd59977 | 1663 | } |
1664 | } | |
1665 | } else if (ident == -1) { // SCOPE | |
1d37eeb6 | 1666 | nr ++; inds(nr) = num; indi(nr) = -1; indr(num) = 0; |
7fd59977 | 1667 | scopile.Append(nr) ; |
1668 | } else if (ident == -2) { // ENDSCOPE | |
1669 | Standard_Integer nscop = scopile.Last() ; // chainage SCOPE-ENDSCOPE | |
1670 | scopile.Remove(scopile.Length()) ; | |
1d37eeb6 | 1671 | nr ++; inds(nr) = nscop; indi(nr) = -3; indr(num) = 0; inds(nscop) = nr; |
7fd59977 | 1672 | if (NbParams(num) > 0) { |
1673 | // EXPORT : traitement special greffe sur celui de SCOPE (sans le perturber) | |
1d37eeb6 D |
1674 | if (indx.IsNull()) { |
1675 | indx = new TColStd_HArray1OfInteger(0, nbseq); | |
1676 | for (Standard_Integer ixp = 0; ixp <= nbseq; ixp ++) indx->ChangeValue(ixp) = 0; | |
7fd59977 | 1677 | } |
1d37eeb6 | 1678 | indx->ChangeValue(nr) = num; indx->ChangeValue(nscop) = num; |
7fd59977 | 1679 | } |
1680 | } else if (ident == 0) { // HEADER | |
1d37eeb6 | 1681 | indr(num) = 0; |
7fd59977 | 1682 | } |
1683 | } | |
1684 | ||
e119b6c3 | 1685 | // .. Resolution des EXPORT, silyena et silya besoin .. |
1686 | // Pour chaque valeur de EXPORT qui n a pas ete resolue par la MAP, | |
1687 | // determiner sa position locale par recherche en arriere depuis ENDSCOPE | |
1d37eeb6 | 1688 | if ((!iamap || pbmap) && !indx.IsNull()) { |
e119b6c3 | 1689 | for (nr = 0; nr <= nbseq; nr++) { |
1d37eeb6 D |
1690 | if (indx->Value(nr) == 0 && indi(nr) != -3) continue; // ENDSCOPE + EXPORT |
1691 | num = indx->Value(nr); | |
7fd59977 | 1692 | Standard_Integer nba = NbParams(num); |
e119b6c3 | 1693 | for (Standard_Integer na = 1; na <= nba; na++) { |
1694 | Interface_FileParameter& FP = ChangeParam(num, na); | |
1695 | if (FP.ParamType() != Interface_ParamIdent) continue; | |
1696 | Standard_Integer id = -FP.EntityNumber(); | |
1697 | if (id < 0) continue; // deja resolu en tete | |
1698 | /* if (imap.Contains(id)) { et voila | |
1699 | FP.SetEntityNumber(indm(imap.FindIndex(id))); | |
1700 | continue; | |
1701 | } */ | |
1702 | ||
1703 | // Recherche du Id demande : si EXPORT imbrique, deja resolu mais il faut | |
1704 | // regarder ! (inutile par contre d aller y voir : c est deja fait, car | |
1705 | // un EXPORT imbrique a ete traite AVANT celui qui imbrique) | |
1706 | Standard_Integer n0 = nr - 1; | |
1707 | if (indi(n0) == -3) n0--; // si on suit juste un ENDSCOPE | |
1708 | while (n0 > 0) { | |
1709 | Standard_Integer irec = indi(n0); | |
1710 | if (irec == id) { // trouve | |
1711 | FP.SetEntityNumber(inds(n0)); | |
1712 | break; | |
1713 | } | |
1714 | if (irec == -1) break; // SCOPE : fin de ce SCOPE/ENDSCOPE | |
1715 | if (irec == -3) { | |
1716 | // gare a EXPORT : si un EXPORT detient Id, noter son Numero deja calcule | |
1717 | // Attention : Id a lire depuis CValue car EntityNumber deja resolu | |
1718 | Standard_Integer nok = FindEntityNumber(indx->Value(n0), id); | |
1719 | if (nok > 0) { | |
1720 | FP.SetEntityNumber(nok); | |
1721 | break; | |
1722 | } | |
1723 | n0 = inds(n0); // ENDSCOPE ou EXPORT infructueux : le sauter | |
1724 | } // fin traitement sur un ENDSCOPE ou EXPORT | |
1725 | n0--; | |
1726 | } // fin resolution d un Parametre EXPORT | |
7fd59977 | 1727 | } // fin resolution de la liste d un EXPORT |
1728 | } // fin bouclage sur les EXPORT | |
1729 | } | |
1730 | ||
e119b6c3 | 1731 | // Exploitation de la table : bouclage porte sur la table |
7fd59977 | 1732 | |
e119b6c3 | 1733 | // Traitement des sous-listes : se fait dans la foulee, par gestion d une pile |
1734 | // basee sur la constitution des sous-listes | |
7fd59977 | 1735 | Standard_Integer maxsubpil = 30; // pile simulee avec un Array : tres fort |
1736 | Handle(TColStd_HArray1OfInteger) subpile = // ... gagne de la memoire ... | |
e119b6c3 | 1737 | new TColStd_HArray1OfInteger(1, maxsubpil); |
7fd59977 | 1738 | Standard_Integer nbsubpil = 0; // ... et tellement plus rapide ! |
1739 | ||
e119b6c3 | 1740 | for (num = 1; num <= nbdirec; num++) { |
1d37eeb6 | 1741 | nr = indr(num); |
7fd59977 | 1742 | if (nr == 0) continue; // pas un objet ou une sous-liste |
e119b6c3 | 1743 | Standard_Integer nba = NbParams(num); |
1744 | for (Standard_Integer na = nba; na > 0; na--) { | |
1745 | // On lit depuis la fin : cela permet de traiter les sous-listes dans la foulee | |
1746 | // Sinon, on devrait noter qu il y a eu des sous-listes et reprendre ensuite | |
7fd59977 | 1747 | |
e119b6c3 | 1748 | Interface_FileParameter& FP = ChangeParam(num, na); |
7fd59977 | 1749 | Interface_ParamType letype = FP.ParamType(); |
1750 | if (letype == Interface_ParamSub) { | |
e119b6c3 | 1751 | // parametre type sous-liste : numero de la sous-liste lu par depilement |
7fd59977 | 1752 | FP.SetEntityNumber(subpile->Value(nbsubpil)); |
e119b6c3 | 1753 | nbsubpil--; // subpile->Remove(nbsubpil); |
7fd59977 | 1754 | |
1755 | } else if (letype == Interface_ParamIdent) { | |
e119b6c3 | 1756 | // parametre type ident (reference une entite) : chercher ident demande |
1757 | Standard_Integer id = -FP.EntityNumber(); | |
1758 | if (id < 0) continue; // deja resolu en tete | |
1759 | ||
1760 | // Voila : on va chercher id dans ndi; algorithme de balayage | |
1761 | Standard_Integer pass, sens, nok, n0, irec; pass = sens = nok = 0; | |
1762 | if (!iamap) pass = 1; // si map non disponible | |
1763 | while (pass < 3) { | |
1764 | pass++; | |
1765 | // MAP disponible | |
1766 | if (pass == 1) { // MAP DISPONIBLE | |
1767 | Standard_Integer indmap = imap.FindIndex(id); | |
1768 | if (indmap > 0) { // la map a trouve | |
1769 | nok = indm(indmap); | |
1770 | if (nok < 0) continue; // CONFLIT -> faut resoudre ... | |
1771 | break; | |
1772 | } | |
1773 | else continue; | |
1774 | } | |
1775 | // 1re Passe : REMONTEE -> Debut fichier | |
1776 | if (sens == 0 && nr > 1) { | |
1777 | n0 = nr - 1; | |
1778 | if (indi(n0) == -3) n0--; // si on suit juste un ENDSCOPE | |
1779 | while (n0 > 0) { | |
1d37eeb6 | 1780 | irec = indi(n0); |
e119b6c3 | 1781 | if (irec == id) { // trouve |
1782 | nok = n0; break; | |
1783 | } | |
1784 | // ENDSCOPE : Attention a EXPORT sinon sauter | |
7fd59977 | 1785 | if (irec == -3) { |
e119b6c3 | 1786 | if (indx.IsNull()) n0 = inds(n0); |
1787 | else { | |
1788 | // EXPORT, il faut regarder | |
1789 | nok = FindEntityNumber(indx->Value(n0), id); | |
1790 | if (nok > 0) break; | |
1791 | n0 = inds(n0); // ENDSCOPE : le sauter | |
1792 | } | |
1793 | } | |
1794 | n0--; | |
7fd59977 | 1795 | } |
e119b6c3 | 1796 | // 2me Passe : DESCENTE -> Fin fichier |
7fd59977 | 1797 | } else if (nr < nbseq) { // descente -> fin fichier |
e119b6c3 | 1798 | n0 = nr + 1; |
7fd59977 | 1799 | while (n0 <= nbseq) { |
1d37eeb6 | 1800 | irec = indi(n0); |
e119b6c3 | 1801 | if (irec == id) { // trouve |
1802 | nok = n0; break; | |
1803 | } | |
1804 | // SCOPE : Attention a EXPORT sinon sauter | |
7fd59977 | 1805 | if (irec == -1) { |
e119b6c3 | 1806 | if (indx.IsNull()) n0 = inds(n0); |
1807 | else { | |
1808 | // EXPORT, il faut regarder | |
1809 | nok = FindEntityNumber(indx->Value(n0), id); | |
1810 | if (nok > 0) break; | |
1811 | n0 = inds(n0); // SCOPE : le sauter | |
1812 | } | |
1813 | } | |
1814 | n0++; | |
7fd59977 | 1815 | } |
1816 | } | |
e119b6c3 | 1817 | if (nok > 0) break; |
1818 | sens = 1 - sens; // passe suivante | |
1819 | } | |
1820 | // ici on a nok, numero trouve | |
1821 | if (nok > 0) { | |
1d37eeb6 | 1822 | Standard_Integer num0 = inds(nok); |
7fd59977 | 1823 | FP.SetEntityNumber(num0); // ET VOILA, on a resolu |
1824 | ||
1825 | // pas trouve : le signaler | |
1826 | } else { | |
e119b6c3 | 1827 | // Alimenter le Check ... Pour cela, determiner n0 Entite et Ident |
1828 | char failmess[100]; | |
1829 | Standard_Integer nument = 0; | |
1830 | Standard_Integer n0ent; // svv Jan11 2000 : porting on DEC | |
1831 | for (n0ent = 1; n0ent <= nr; n0ent++) { | |
1832 | if (indi(n0ent) > 0) nument++; | |
1833 | } | |
1834 | Standard_Integer ident = RecordIdent(num); | |
1835 | if (ident < 0) { | |
1836 | for (n0ent = num + 1; n0ent <= nbdirec; n0ent++) { | |
1837 | ident = RecordIdent(n0ent); if (ident > 0) break; | |
1838 | } | |
1839 | } | |
1840 | // ... Construire le Check ... | |
1841 | sprintf(failmess, | |
1842 | "Unresolved Reference, Ent.n0 %d (Id.#%d) Param.n0 %d (Id.#%d)", | |
1843 | nument, ident, na, id); | |
1844 | thecheck->AddFail(failmess, "Unresolved Reference"); | |
1845 | // ... Et sortir message un peu plus complet | |
1846 | sout << "*** ERR StepReaderData *** Pour Entite " << nument | |
1847 | << ", a " << (nr * 100) / nbseq << "% de DATA : #" << ident | |
1848 | << "\n Type:" << RecordType(num) | |
1849 | << " Param.n0 " << na << ": #" << id << " Non trouve" << endl; | |
1850 | FP.SetEntityNumber(0); // -> Reference non resolue | |
7fd59977 | 1851 | } |
1852 | } | |
1853 | } | |
e119b6c3 | 1854 | // Si ce record est lui-meme une sous-liste, empiler ! |
1d37eeb6 | 1855 | if (inds(nr) != num) { |
7fd59977 | 1856 | if (nbsubpil >= maxsubpil) { |
e119b6c3 | 1857 | maxsubpil = maxsubpil + 30; |
1858 | Handle(TColStd_HArray1OfInteger) newsubpil = | |
1859 | new TColStd_HArray1OfInteger(1, maxsubpil); | |
1860 | for (Standard_Integer bidpil = 1; bidpil <= maxsubpil - 30; bidpil++) | |
1861 | newsubpil->SetValue(bidpil, subpile->Value(bidpil)); | |
1862 | subpile = newsubpil; | |
7fd59977 | 1863 | } |
e119b6c3 | 1864 | nbsubpil++; |
1865 | subpile->SetValue(nbsubpil, num); // Append(num); | |
7fd59977 | 1866 | } |
1867 | } | |
7fd59977 | 1868 | } |
1869 | ||
1870 | ||
1871 | // ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## | |
1872 | // .... Gestion du Header : Preparation, lecture .... | |
1873 | ||
1874 | ||
1875 | //======================================================================= | |
1876 | //function : FindNextHeaderRecord | |
1877 | //purpose : | |
1878 | //======================================================================= | |
1879 | ||
1880 | Standard_Integer StepData_StepReaderData::FindNextHeaderRecord | |
e119b6c3 | 1881 | (const Standard_Integer num) const |
7fd59977 | 1882 | { |
e119b6c3 | 1883 | // retourne, sur un numero d enregistrement donne (par num), le suivant qui |
1884 | // definit une entite, ou 0 si c est fini : | |
1885 | // Opere comme FindNextRecord mais ne balaie que le Header | |
7fd59977 | 1886 | |
e119b6c3 | 1887 | if (num < 0) return 0; |
1888 | Standard_Integer num1 = num + 1; | |
7fd59977 | 1889 | Standard_Integer max = thenbhead; |
1890 | ||
e119b6c3 | 1891 | while (num1 <= max) { |
1892 | // SCOPE,ENDSCOPE et Sous-Liste ont un identifieur negatif | |
1893 | // Ne retenir que les Idents positifs ou nuls (nul : pas d Ident dans Header) | |
1894 | if (RecordIdent(num1) >= 0) return num1; | |
1895 | num1++; | |
7fd59977 | 1896 | } |
1897 | return 0; | |
1898 | } | |
1899 | ||
1900 | ||
1901 | //======================================================================= | |
1902 | //function : PrepareHeader | |
1903 | //purpose : | |
1904 | //======================================================================= | |
1905 | ||
e119b6c3 | 1906 | void StepData_StepReaderData::PrepareHeader() |
7fd59977 | 1907 | { |
e119b6c3 | 1908 | // Resolution des references : ne concerne que les sous-listes |
1909 | // deja faite par SetEntityNumbers donc pas de souci a se faire | |
1910 | ||
1911 | /* | |
1912 | // Algorithme repris et adapte de SetEntityNumbers | |
1913 | // Traitement des sous-listes : se fait dans la foulee, par gestion d une pile | |
1914 | // basee sur la constitution des sous-listes | |
1915 | TColStd_SequenceOfInteger subpile; | |
1916 | Standard_Integer nbsubpil = 0; // profondeur de pile mais plus rapide ... | |
1917 | ||
1918 | for (Standard_Integer num = 1 ; num <= thenbhead ; num ++) { | |
1919 | Standard_Integer nba = NbParams(num) ; | |
1920 | for (Standard_Integer na = nba ; na > 0 ; na --) { | |
1921 | .. On lit depuis la fin : cela permet de traiter les sous-listes dans la foulee | |
1922 | .. Sinon, on devrait noter qu il y a eu des sous-listes et reprendre ensuite | |
1923 | ||
1924 | Interface_FileParameter& FP = ChangeParam(num,na); | |
1925 | Interface_ParamType letype = FP.ParamType(); | |
1926 | if (letype == Interface_ParamSub) { | |
1927 | .. parametre type sous-liste : numero de la sous-liste lu par depilement | |
1928 | FP.SetEntityNumber(subpile.Last()); | |
1929 | .. .. SetParam(num,na,FP); | |
1930 | subpile.Remove(nbsubpil); | |
1931 | nbsubpil --; | |
1932 | } | |
1933 | } | |
1934 | .. Si c est une sous-liste, empiler | |
1935 | if (RecordIdent(num) < -2) { | |
1936 | subpile.Append(num); | |
1937 | nbsubpil ++; | |
7fd59977 | 1938 | } |
1939 | } | |
e119b6c3 | 1940 | */ |
7fd59977 | 1941 | } |
1942 | ||
1943 | ||
1944 | //======================================================================= | |
1945 | //function : GlobalCheck | |
1946 | //purpose : | |
1947 | //======================================================================= | |
1948 | ||
e119b6c3 | 1949 | const Handle(Interface_Check) StepData_StepReaderData::GlobalCheck() const |
7fd59977 | 1950 | { |
1951 | return thecheck; | |
1952 | } |