b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | //pdn S4135 05.04.99 comment uninitialized Interface_Static::IVal("iges.convert.read"); |
19 | #include <IGESData_ParamReader.ixx> |
20 | #include <IGESData_IGESType.hxx> |
21 | #include <Interface_FileParameter.hxx> |
22 | #include <Interface_FileReaderData.hxx> |
23 | #include <Interface_Macros.hxx> |
24 | #include <Interface_Static.hxx> |
25 | #include <stdio.h> |
26 | #include <IGESData_Status.hxx> |
b311480e |
27 | |
7fd59977 |
28 | // MGE 03/08/98 |
29 | #include <Message_Msg.hxx> |
30 | |
31 | static Standard_Integer testconv = -1; // cf parametre de session |
32 | |
33 | // .... Gestion generale (etat, courant ...) .... |
34 | |
35 | |
36 | //======================================================================= |
37 | //function : IGESData_ParamReader |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | IGESData_ParamReader::IGESData_ParamReader(const Handle(Interface_ParamList)& list, |
42 | const Handle(Interface_Check)& ach, |
43 | const Standard_Integer base, |
44 | const Standard_Integer nbpar, |
45 | const Standard_Integer /*num*/) |
46 | { |
47 | Clear(); |
48 | theparams = list; thecheck = ach; thelast = Standard_True; |
49 | thebase = base; |
50 | thenbpar = (nbpar > 0 ? nbpar : list->Length()); |
51 | thenum = 0; |
52 | testconv = -1; |
53 | } |
54 | |
55 | |
56 | //======================================================================= |
57 | //function : EntityNumber |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | Standard_Integer IGESData_ParamReader::EntityNumber () const |
62 | { |
63 | return thenum; |
64 | } |
65 | |
66 | |
67 | //======================================================================= |
68 | //function : Clear |
69 | //purpose : |
70 | //======================================================================= |
71 | |
72 | void IGESData_ParamReader::Clear () |
73 | { |
74 | thecurr = 1; |
75 | thestage = IGESData_ReadOwn; |
76 | pbrealint=pbrealform=0; |
77 | } |
78 | |
79 | |
80 | //======================================================================= |
81 | //function : CurrentNumber |
82 | //purpose : |
83 | //======================================================================= |
84 | |
85 | Standard_Integer IGESData_ParamReader::CurrentNumber () const |
86 | { |
87 | return thecurr; |
88 | } |
89 | |
90 | |
91 | //======================================================================= |
92 | //function : SetCurrentNumber |
93 | //purpose : |
94 | //======================================================================= |
95 | |
96 | void IGESData_ParamReader::SetCurrentNumber (const Standard_Integer num) |
97 | { |
98 | //if (num <= NbParams() + 1) thecurr = num; // NbParams+1 : "fin d'objet" |
99 | //else thecurr = 0; |
100 | thecurr = num; |
101 | } |
102 | |
103 | |
104 | //======================================================================= |
105 | //function : Stage |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | IGESData_ReadStage IGESData_ParamReader::Stage () const |
110 | { |
111 | return thestage; |
112 | } |
113 | |
114 | |
115 | //======================================================================= |
116 | //function : NextStage |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | void IGESData_ParamReader::NextStage () |
121 | { |
122 | if (thestage != IGESData_ReadEnd) thestage = |
123 | (IGESData_ReadStage) (((long) thestage) + 1); |
124 | } |
125 | |
126 | |
127 | //======================================================================= |
128 | //function : EndAll |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | void IGESData_ParamReader::EndAll () |
133 | { |
134 | thestage = IGESData_ReadEnd; |
135 | } |
136 | |
137 | |
138 | // .... Acces de base aux parametres .... |
139 | |
140 | |
141 | //======================================================================= |
142 | //function : NbParams |
143 | //purpose : |
144 | //======================================================================= |
145 | |
146 | Standard_Integer IGESData_ParamReader::NbParams () const |
147 | { |
148 | return (thenbpar - 1); |
149 | } |
150 | |
151 | |
152 | //======================================================================= |
153 | //function : ParamType |
154 | //purpose : |
155 | //======================================================================= |
156 | |
157 | Interface_ParamType IGESData_ParamReader::ParamType |
158 | (const Standard_Integer num) const |
159 | { |
160 | return theparams->Value(num+thebase).ParamType(); |
161 | } |
162 | |
163 | |
164 | //======================================================================= |
165 | //function : ParamValue |
166 | //purpose : |
167 | //======================================================================= |
168 | |
169 | const Standard_CString IGESData_ParamReader::ParamValue |
170 | (const Standard_Integer num) const |
171 | { |
172 | return theparams->Value(num+thebase).CValue(); |
173 | } |
174 | |
175 | |
176 | //======================================================================= |
177 | //function : IsParamDefined |
178 | //purpose : |
179 | //======================================================================= |
180 | |
181 | Standard_Boolean IGESData_ParamReader::IsParamDefined |
182 | (const Standard_Integer num) const |
183 | { |
184 | if (num >= thenbpar) return Standard_False; |
185 | return (theparams->Value(num+thebase).ParamType() != Interface_ParamVoid); |
186 | } |
187 | |
188 | |
189 | //======================================================================= |
190 | //function : IsParamEntity |
191 | //purpose : |
192 | //======================================================================= |
193 | |
194 | Standard_Boolean IGESData_ParamReader::IsParamEntity |
195 | (const Standard_Integer num) const |
196 | { |
197 | return (ParamNumber(num) != 0); |
198 | } |
199 | |
200 | |
201 | //======================================================================= |
202 | //function : ParamNumber |
203 | //purpose : |
204 | //======================================================================= |
205 | |
206 | Standard_Integer IGESData_ParamReader::ParamNumber |
207 | (const Standard_Integer num) const |
208 | { |
209 | return theparams->Value(num+thebase).EntityNumber(); |
210 | } |
211 | |
212 | |
213 | //======================================================================= |
214 | //function : ParamEntity |
215 | //purpose : |
216 | //======================================================================= |
217 | |
218 | Handle(IGESData_IGESEntity) IGESData_ParamReader::ParamEntity |
219 | (const Handle(IGESData_IGESReaderData)& IR, const Standard_Integer num) |
220 | { |
221 | Standard_Integer n = ParamNumber(num); |
222 | if (n == 0) thecheck->AddFail("IGES ParamReader : ParamEntity, bad param"); |
223 | return GetCasted(IGESData_IGESEntity,IR->BoundEntity(n)); |
224 | } |
225 | |
226 | |
227 | // .... Assistance a la lecture .... |
228 | |
229 | // Les fonctions Read* offrent les services suivants : |
230 | // Gestion des erreurs : le Check est alimente, par Fail ou Corrected selon |
231 | // Si Fail, retour de fonction False (peut etre utile), sinon True |
232 | // En outre, un Status est gere (de type enum DataState) |
233 | // (peut etre interroge suite a appel Read* si retour True/False trop court) |
234 | // |
235 | // Gestion du pointeur courant (sur option, nais elle est mise par defaut) : |
236 | // Les parametres sont designes via un ParmCursor, qui peut etre fabrique par |
237 | // les methodes ad hoc Current et CurrentList, et qui peut demander a avancer |
238 | // le pointeur courant une fois la lecture faite |
239 | // En outre, pour un HArray1, on peut preciser index de depart |
240 | |
241 | |
242 | //======================================================================= |
243 | //function : Current |
244 | //purpose : |
245 | //======================================================================= |
246 | |
247 | IGESData_ParamCursor IGESData_ParamReader::Current () const |
248 | { |
249 | return IGESData_ParamCursor(thecurr); |
250 | } |
251 | |
252 | |
253 | //======================================================================= |
254 | //function : CurrentList |
255 | //purpose : |
256 | //======================================================================= |
257 | |
258 | IGESData_ParamCursor IGESData_ParamReader::CurrentList |
259 | (const Standard_Integer nb, const Standard_Integer size) const |
260 | { |
261 | return IGESData_ParamCursor(thecurr,nb,size); |
262 | } |
263 | |
264 | |
265 | // PrepareRead for MoniTool |
266 | |
267 | |
268 | //======================================================================= |
269 | //function : PrepareRead |
270 | //purpose : |
271 | //======================================================================= |
272 | |
273 | Standard_Boolean IGESData_ParamReader::PrepareRead |
274 | (const IGESData_ParamCursor& PC, const Standard_Boolean several, |
275 | const Standard_Integer size) |
276 | { |
277 | theindex = PC.Start(); |
278 | themaxind = PC.Limit(); |
279 | thenbitem = PC.Count(); |
280 | theitemsz = PC.ItemSize(); |
281 | theoffset = PC.Offset(); |
282 | thetermsz = PC.TermSize(); |
283 | if (!several && thenbitem > 1) { |
284 | // AddFail (mess," : List not allowed",""); |
285 | return Standard_False; |
286 | } |
287 | if (size > 1) { |
288 | if (thetermsz % size != 0) { |
289 | return Standard_False; |
290 | } |
291 | } |
292 | if (theindex <= 0 || (themaxind-1) > NbParams()) { |
293 | return Standard_False; |
294 | } |
295 | if (PC.Advance()) |
296 | SetCurrentNumber (themaxind); //themaxind : prochain index |
297 | thelast = Standard_True; |
298 | return Standard_True; |
299 | } |
300 | |
301 | |
302 | //======================================================================= |
303 | //function : PrepareRead |
304 | //purpose : |
305 | //======================================================================= |
306 | |
307 | Standard_Boolean IGESData_ParamReader::PrepareRead |
308 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
309 | const Standard_Boolean several, const Standard_Integer size) |
310 | { |
311 | theindex = PC.Start(); |
312 | themaxind = PC.Limit(); |
313 | thenbitem = PC.Count(); |
314 | theitemsz = PC.ItemSize(); |
315 | theoffset = PC.Offset(); |
316 | thetermsz = PC.TermSize(); |
317 | if (!several && thenbitem > 1) { |
318 | AddFail (mess," : List not allowed",""); |
319 | return Standard_False; |
320 | } |
321 | if (size > 1) { |
322 | if (thetermsz % size != 0) { |
323 | AddFail (mess," : term size mismatch",""); |
324 | return Standard_False; |
325 | } |
326 | } |
327 | if (theindex <= 0 || (themaxind-1) > NbParams()) { |
328 | if (thenbitem == 1) AddFail (mess," : Parameter number out of range",""); |
329 | //else AddFail (mess," : too many values to read" ,""); |
330 | else AddWarning (mess," : too many values to read" ,""); |
331 | return Standard_False; |
332 | } |
333 | if (PC.Advance()) SetCurrentNumber (themaxind); //themaxind : prochain index |
334 | thelast = Standard_True; |
335 | return Standard_True; |
336 | } |
337 | |
338 | |
339 | // theindex donne le debut de la lecture; tjrs cale sur debut d item |
340 | // thenbterm donne debut a lire dans l item |
341 | // Ainsi, l indice vrai est theindex + thenbterm |
342 | // thenbterm avance par +nb. Quand il a depasse thetermsz, item suivant |
343 | // theindex est lui-meme limite (critere d arret) a themaxind |
344 | |
345 | |
346 | //======================================================================= |
347 | //function : FirstRead |
348 | //purpose : |
349 | //======================================================================= |
350 | |
351 | Standard_Integer IGESData_ParamReader::FirstRead (const Standard_Integer nb) |
352 | { |
353 | theindex += theoffset; // On se cale d office sur le debut du terme a lire |
354 | Standard_Integer res = theindex; |
355 | thenbterm = nb; |
356 | if (thenbterm >= thetermsz) { |
357 | theindex += theitemsz; |
358 | thenbterm = 0; |
359 | } |
360 | return res; |
361 | } |
362 | |
363 | |
364 | //======================================================================= |
365 | //function : NextRead |
366 | //purpose : |
367 | //======================================================================= |
368 | |
369 | Standard_Integer IGESData_ParamReader::NextRead (const Standard_Integer nb) |
370 | { |
371 | Standard_Integer res = theindex; |
372 | if (theindex >= themaxind) res = 0; |
373 | thenbterm += nb; // Par Item : en lire thetermsz, puis item suivant |
374 | if (thenbterm >= thetermsz) { |
375 | theindex += theitemsz; |
376 | thenbterm = 0; |
377 | } |
378 | return res; |
379 | } |
380 | |
381 | |
382 | //======================================================================= |
383 | //function : DefinedElseSkip |
384 | //purpose : |
385 | //======================================================================= |
386 | |
387 | Standard_Boolean IGESData_ParamReader::DefinedElseSkip () |
388 | { |
389 | if (thecurr > NbParams()) return Standard_False; // Skip en butee |
390 | if (IsParamDefined(thecurr)) return Standard_True; // Defined |
391 | SetCurrentNumber (thecurr+1); // Skip |
392 | return Standard_False; |
393 | } |
394 | |
395 | |
396 | // ReadInteger for MoniTool |
397 | |
398 | //======================================================================= |
399 | //function : ReadInteger |
400 | //purpose : |
401 | //======================================================================= |
402 | |
403 | Standard_Boolean IGESData_ParamReader::ReadInteger (const IGESData_ParamCursor& PC, |
404 | Standard_Integer& val) |
405 | { |
406 | if (!PrepareRead(PC,Standard_False)) return Standard_False; |
407 | const Interface_FileParameter& FP = theparams->Value(theindex+thebase); |
408 | if (FP.ParamType() != Interface_ParamInteger) { |
409 | if (FP.ParamType() == Interface_ParamVoid){ |
410 | val = 0; |
411 | return Standard_True; |
412 | } // DEFAULT |
413 | return Standard_False; |
414 | } |
415 | val = atoi(FP.CValue()); |
416 | return Standard_True; |
417 | } |
418 | |
419 | |
420 | //======================================================================= |
421 | //function : ReadInteger |
422 | //purpose : |
423 | //======================================================================= |
424 | |
425 | Standard_Boolean IGESData_ParamReader::ReadInteger |
426 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
427 | Standard_Integer& val) |
428 | { |
429 | if (!PrepareRead(PC,mess,Standard_False)) return Standard_False; |
430 | const Interface_FileParameter& FP = theparams->Value(theindex+thebase); |
431 | if (FP.ParamType() != Interface_ParamInteger) { |
432 | if (FP.ParamType() == Interface_ParamVoid) |
433 | { val = 0; return Standard_True; } // DEFAULT |
434 | AddFail (mess," : not given as an Integer",""); |
435 | return Standard_False; |
436 | } |
437 | val = atoi(FP.CValue()); |
438 | return Standard_True; |
439 | } |
440 | |
441 | |
442 | // ReadBoolean for MoniTool |
443 | |
444 | //======================================================================= |
445 | //function : ReadBoolean |
446 | //purpose : |
447 | //======================================================================= |
448 | |
449 | Standard_Boolean IGESData_ParamReader::ReadBoolean |
450 | (const IGESData_ParamCursor& PC, const Message_Msg& amsg, |
451 | Standard_Boolean& val, const Standard_Boolean exact) |
452 | { |
453 | if (!PrepareRead(PC,Standard_False)) return Standard_False; |
454 | const Interface_FileParameter& FP = theparams->Value(theindex+thebase); |
455 | if (FP.ParamType() != Interface_ParamInteger) { |
456 | if (FP.ParamType() == Interface_ParamVoid) { |
457 | val = Standard_False; |
458 | return Standard_True; |
459 | } // DEFAULT |
460 | SendFail (amsg); |
461 | return Standard_False; |
462 | } |
463 | |
464 | // Un Booleen, c est 0/1. Mais on peut tolerer d autres valeurs |
465 | // On peut toujours consulter LastReadStatus apres la lecture pour etre sur |
466 | Standard_Integer flag = atoi (FP.CValue()); |
467 | if (flag != 0 && flag != 1) { |
468 | if (exact) { |
469 | SendFail (amsg); |
470 | thelast = Standard_True; |
471 | return Standard_False; |
472 | } |
473 | else { |
474 | SendWarning (amsg); |
475 | } |
476 | } |
477 | val = (flag > 0); |
478 | return Standard_True; |
479 | } |
480 | |
481 | |
482 | //======================================================================= |
483 | //function : ReadBoolean |
484 | //purpose : |
485 | //======================================================================= |
486 | |
487 | Standard_Boolean IGESData_ParamReader::ReadBoolean |
488 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
489 | Standard_Boolean& val, const Standard_Boolean exact) |
490 | { |
491 | if (!PrepareRead(PC,mess,Standard_False)) return Standard_False; |
492 | const Interface_FileParameter& FP = theparams->Value(theindex+thebase); |
493 | if (FP.ParamType() != Interface_ParamInteger) { |
494 | if (FP.ParamType() == Interface_ParamVoid) |
495 | { |
496 | val = Standard_False; |
497 | return Standard_True; |
498 | } // DEFAULT |
499 | AddFail (mess," : not an Integer (for Boolean)",""); |
500 | return Standard_False; |
501 | } |
502 | |
503 | // Un Booleen, c est 0/1. Mais on peut tolerer d autres valeurs |
504 | // On peut toujours consulter LastReadStatus apres la lecture pour etre sur |
505 | Standard_Integer flag = atoi (FP.CValue()); |
506 | if (flag != 0 && flag != 1) { |
507 | char ssem[100]; |
508 | sprintf(ssem," : Value is not 0/1, but %s",FP.CValue()); |
509 | if (exact) { |
510 | AddFail (mess,ssem," : Value is not 0/1, but %s"); |
511 | thelast = Standard_True; |
512 | return Standard_False; |
513 | } |
514 | else AddWarning (mess,ssem," : Value is not 0/1, but %s"); |
515 | } |
516 | val = (flag > 0); |
517 | return Standard_True; |
518 | } |
519 | |
520 | |
521 | // ReadReal for MoniTool |
522 | |
523 | //======================================================================= |
524 | //function : ReadReal |
525 | //purpose : |
526 | //======================================================================= |
527 | |
528 | Standard_Boolean IGESData_ParamReader::ReadReal (const IGESData_ParamCursor& PC, |
529 | Standard_Real& val) |
530 | { |
531 | if (!PrepareRead(PC,Standard_False)) return Standard_False; |
532 | // return ReadingReal (theindex,amsg,val); |
533 | return ReadingReal (theindex,val); |
534 | } |
535 | |
536 | |
537 | //======================================================================= |
538 | //function : ReadReal |
539 | //purpose : |
540 | //======================================================================= |
541 | |
542 | Standard_Boolean IGESData_ParamReader::ReadReal |
543 | (const IGESData_ParamCursor& PC,const Standard_CString mess, |
544 | Standard_Real& val) |
545 | { |
546 | if (!PrepareRead(PC,mess,Standard_False)) return Standard_False; |
547 | return ReadingReal (theindex,mess,val); |
548 | } |
549 | |
550 | |
551 | // ReadXY for MoniTool |
552 | |
553 | //======================================================================= |
554 | //function : ReadXY |
555 | //purpose : |
556 | //======================================================================= |
557 | |
558 | Standard_Boolean IGESData_ParamReader::ReadXY |
559 | (const IGESData_ParamCursor& PC,Message_Msg& /*amsg*/, gp_XY& val) |
560 | { |
561 | if (!PrepareRead(PC,Standard_False,2)) return Standard_False; |
1d47d8d0 |
562 | Standard_Real X,Y = 0.; |
7fd59977 |
563 | Standard_Boolean stat = |
564 | (ReadingReal (theindex ,X) && |
565 | ReadingReal (theindex+1,Y) ); |
566 | if (stat) val.SetCoord(X,Y); |
567 | return stat; |
568 | } |
569 | |
570 | |
571 | //======================================================================= |
572 | //function : ReadXY |
573 | //purpose : |
574 | //======================================================================= |
575 | |
576 | Standard_Boolean IGESData_ParamReader::ReadXY |
577 | (const IGESData_ParamCursor& PC, const Standard_CString mess, gp_XY& val) |
578 | { |
579 | if (!PrepareRead(PC,mess,Standard_False,2)) return Standard_False; |
1d47d8d0 |
580 | Standard_Real X,Y = 0.; |
7fd59977 |
581 | Standard_Boolean stat = |
582 | (ReadingReal (theindex ,mess,X) && |
583 | ReadingReal (theindex+1,mess,Y) ); |
584 | if (stat) val.SetCoord(X,Y); |
585 | return stat; |
586 | } |
587 | |
588 | |
589 | // ReadXYZ for MoniTool |
590 | |
591 | //======================================================================= |
592 | //function : ReadXYZ |
593 | //purpose : |
594 | //======================================================================= |
595 | |
596 | Standard_Boolean IGESData_ParamReader::ReadXYZ |
597 | (const IGESData_ParamCursor& PC,Message_Msg& /*amsg*/, gp_XYZ& val) |
598 | { |
599 | if (!PrepareRead(PC,Standard_False,3)) return Standard_False; |
1d47d8d0 |
600 | Standard_Real X,Y = 0.,Z = 0.; |
7fd59977 |
601 | Standard_Boolean stat = |
602 | (ReadingReal (theindex ,X) && |
603 | ReadingReal (theindex+1,Y) && |
604 | ReadingReal (theindex+2,Z) ); |
605 | if (stat) val.SetCoord(X,Y,Z); |
606 | return Standard_True; |
607 | } |
608 | |
609 | |
610 | //======================================================================= |
611 | //function : ReadXYZ |
612 | //purpose : |
613 | //======================================================================= |
614 | |
615 | Standard_Boolean IGESData_ParamReader::ReadXYZ |
616 | (const IGESData_ParamCursor& PC, const Standard_CString mess, gp_XYZ& val) |
617 | { |
618 | if (!PrepareRead(PC,mess,Standard_False,3)) return Standard_False; |
1d47d8d0 |
619 | Standard_Real X,Y = 0.,Z = 0.; |
7fd59977 |
620 | Standard_Boolean stat = |
621 | (ReadingReal (theindex ,mess,X) && |
622 | ReadingReal (theindex+1,mess,Y) && |
623 | ReadingReal (theindex+2,mess,Z) ); |
624 | if (stat) val.SetCoord(X,Y,Z); |
625 | return Standard_True; |
626 | } |
627 | |
628 | |
629 | // ReadText for MoniTool |
630 | |
631 | //======================================================================= |
632 | //function : ReadText |
633 | //purpose : |
634 | //======================================================================= |
635 | |
636 | Standard_Boolean IGESData_ParamReader::ReadText |
637 | (const IGESData_ParamCursor& PC, const Message_Msg& amsg, |
638 | Handle(TCollection_HAsciiString)& val) |
639 | { |
640 | if (!PrepareRead(PC,Standard_False)) return Standard_False; |
641 | const Interface_FileParameter& FP = theparams->Value(theindex+thebase); |
642 | if (FP.ParamType() != Interface_ParamText) { |
643 | if (FP.ParamType() == Interface_ParamVoid) { |
644 | val = new TCollection_HAsciiString(""); |
645 | return Standard_True; |
646 | } |
647 | SendFail (amsg); |
648 | return Standard_False; |
649 | } |
650 | Handle(TCollection_HAsciiString) tval = new TCollection_HAsciiString (FP.CValue()); |
651 | Standard_Integer lnt = tval->Length(); |
652 | Standard_Integer lnh = tval->Location(1,'H',1,lnt); |
653 | if (lnh <= 1 || lnh >= lnt) { |
654 | SendFail (amsg); |
655 | return Standard_False; |
656 | } else { |
657 | Standard_Integer hol = atoi (tval->SubString(1,lnh-1)->ToCString()); |
658 | if (hol != (lnt-lnh)) SendWarning (amsg); |
659 | } |
660 | val = new TCollection_HAsciiString(tval->SubString(lnh+1,lnt)->ToCString()); |
661 | return Standard_True; |
662 | } |
663 | |
664 | |
665 | //======================================================================= |
666 | //function : ReadText |
667 | //purpose : |
668 | //======================================================================= |
669 | |
670 | Standard_Boolean IGESData_ParamReader::ReadText |
671 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
672 | Handle(TCollection_HAsciiString)& val) |
673 | { |
674 | if (!PrepareRead(PC,mess,Standard_False)) return Standard_False; |
675 | const Interface_FileParameter& FP = theparams->Value(theindex+thebase); |
676 | if (FP.ParamType() != Interface_ParamText) { |
677 | if (FP.ParamType() == Interface_ParamVoid) { |
678 | val = new TCollection_HAsciiString(""); |
679 | return Standard_True; |
680 | } |
681 | AddFail (mess," : not given as a Text",""); |
682 | return Standard_False; |
683 | } |
684 | Handle(TCollection_HAsciiString) tval = new TCollection_HAsciiString (FP.CValue()); |
685 | Standard_Integer lnt = tval->Length(); |
686 | Standard_Integer lnh = tval->Location(1,'H',1,lnt); |
687 | if (lnh <= 1 || lnh >= lnt) { |
688 | AddFail (mess," : not in Hollerith Form",""); |
689 | return Standard_False; |
690 | } |
691 | else { |
692 | Standard_Integer hol = atoi (tval->SubString(1,lnh-1)->ToCString()); |
693 | if (hol != (lnt-lnh)) AddWarning (mess," : bad Hollerith count ",""); |
694 | } |
695 | val = new TCollection_HAsciiString(tval->SubString(lnh+1,lnt)->ToCString()); |
696 | return Standard_True; |
697 | } |
698 | |
699 | |
700 | // ReadEntity for MoniTool |
701 | |
702 | //======================================================================= |
703 | //function : ReadEntity |
704 | //purpose : |
705 | //======================================================================= |
706 | |
707 | Standard_Boolean IGESData_ParamReader::ReadEntity (const Handle(IGESData_IGESReaderData)& IR, |
708 | const IGESData_ParamCursor& PC, |
709 | IGESData_Status& aStatus, |
710 | Handle(IGESData_IGESEntity)& val, |
711 | const Standard_Boolean canbenul) |
712 | { |
713 | if (!PrepareRead(PC,Standard_False)) return Standard_False; |
714 | Standard_Integer nval; |
715 | // if (!ReadingEntityNumber(theindex,amsg,nval)) return Standard_False; |
716 | if (!ReadingEntityNumber(theindex,nval)) return Standard_False; |
717 | if (nval == 0) { |
718 | val.Nullify(); |
719 | if (!canbenul) { |
720 | aStatus = IGESData_ReferenceError; |
721 | // Message_Msg Msg216 ("IGESP_216"); |
722 | // amsg.Arg(amsg.Value()); |
723 | // SendFail (amsg); |
724 | |
725 | thelast = Standard_True; |
726 | } |
727 | return canbenul; |
728 | } |
729 | else val = GetCasted(IGESData_IGESEntity,IR->BoundEntity(nval)); |
730 | if (val.IsNull()) return canbenul; |
731 | // Cas du "Nul IGES" |
732 | if (val->TypeNumber() == 0) { // Null ou pas encore rempli ... |
733 | if (IR->DirType(nval).Type() == 0) { // le vrai critere (un peu cher) |
734 | val.Nullify(); |
735 | if (!canbenul) { |
736 | aStatus = IGESData_EntityError; |
737 | // Message_Msg Msg217 ("IGES_217"); |
738 | //amsg.Arg(Msg217.Value()); |
739 | //SendFail (amsg); |
740 | thelast = Standard_True; |
741 | } |
742 | return canbenul; |
743 | } |
744 | } |
745 | aStatus = IGESData_EntityOK; |
746 | return Standard_True; |
747 | } |
748 | |
749 | |
750 | //======================================================================= |
751 | //function : ReadEntity |
752 | //purpose : |
753 | //======================================================================= |
754 | |
755 | Standard_Boolean IGESData_ParamReader::ReadEntity |
756 | (const Handle(IGESData_IGESReaderData)& IR, const IGESData_ParamCursor& PC, |
757 | const Standard_CString mess, Handle(IGESData_IGESEntity)& val, const Standard_Boolean canbenul) |
758 | { |
759 | if (!PrepareRead(PC,mess,Standard_False)) return Standard_False; |
760 | Standard_Integer nval; |
761 | if (!ReadingEntityNumber(theindex,mess,nval)) return Standard_False; |
762 | if (nval == 0) { |
763 | val.Nullify(); |
764 | if (!canbenul) { |
765 | AddFail (mess," : Null Reference",""); |
766 | thelast = Standard_True; |
767 | } |
768 | return canbenul; |
769 | } |
770 | else val = GetCasted(IGESData_IGESEntity,IR->BoundEntity(nval)); |
771 | if (val.IsNull()) return canbenul; |
772 | // Cas du "Nul IGES" |
773 | if (val->TypeNumber() == 0) { // Null ou pas encore rempli ... |
774 | if (IR->DirType(nval).Type() == 0) { // le vrai critere (un peu cher) |
775 | val.Nullify(); |
776 | if (!canbenul) { |
777 | AddFail (mess," : IGES Null Entity",""); |
778 | thelast = Standard_True; |
779 | } |
780 | return canbenul; |
781 | } |
782 | } |
783 | return Standard_True; |
784 | } |
785 | |
786 | |
787 | // ReadEntity for MoniTool |
788 | |
789 | //======================================================================= |
790 | //function : ReadEntity |
791 | //purpose : |
792 | //======================================================================= |
793 | |
794 | Standard_Boolean IGESData_ParamReader::ReadEntity (const Handle(IGESData_IGESReaderData)& IR, |
795 | const IGESData_ParamCursor& PC, |
796 | IGESData_Status& aStatus, |
797 | const Handle(Standard_Type)& type, |
798 | Handle(IGESData_IGESEntity)& val, |
799 | const Standard_Boolean canbenul) |
800 | { |
801 | Standard_Boolean res = ReadEntity (IR,PC,aStatus,val,canbenul); |
802 | if (!res) { |
803 | return res; |
804 | } |
805 | if (val.IsNull()) return res; |
806 | if (!val->IsKind(type)) { |
807 | aStatus = IGESData_TypeError; |
808 | // Message_Msg Msg218 ("IGES_218"); |
809 | //amsg.Arg(Msg218.Value()); |
810 | //SendFail(amsg); |
811 | thelast = Standard_True; |
812 | val.Nullify(); |
813 | return Standard_False; |
814 | } |
815 | return Standard_True; |
816 | } |
817 | |
818 | |
819 | //======================================================================= |
820 | //function : ReadEntity |
821 | //purpose : |
822 | //======================================================================= |
823 | |
824 | Standard_Boolean IGESData_ParamReader::ReadEntity |
825 | (const Handle(IGESData_IGESReaderData)& IR, |
826 | const IGESData_ParamCursor& PC, const Standard_CString mess, |
827 | const Handle(Standard_Type)& type, |
828 | Handle(IGESData_IGESEntity)& val, const Standard_Boolean canbenul) |
829 | { |
830 | Standard_Boolean res = ReadEntity (IR,PC,mess,val,canbenul); |
831 | if (!res) return res; |
832 | if (val.IsNull()) return res; |
833 | if (!val->IsKind(type)) { |
834 | AddFail (mess," : Incorrect Type",""); |
835 | thelast = Standard_True; |
836 | val.Nullify(); |
837 | return Standard_False; |
838 | } |
839 | return Standard_True; |
840 | } |
841 | |
842 | |
843 | // ReadInts for MoniTool |
844 | |
845 | //======================================================================= |
846 | //function : ReadInts |
847 | //purpose : |
848 | //======================================================================= |
849 | |
850 | Standard_Boolean IGESData_ParamReader::ReadInts |
851 | (const IGESData_ParamCursor& PC, const Message_Msg& amsg , |
852 | Handle(TColStd_HArray1OfInteger)& val, const Standard_Integer index) |
853 | { |
854 | if (!PrepareRead(PC,Standard_True)) return Standard_False; |
855 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
856 | val = new TColStd_HArray1OfInteger (index,index+thenbitem*thetermsz-1); |
857 | Standard_Integer ind = index; |
858 | |
859 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
860 | const Interface_FileParameter& FP = theparams->Value(i+thebase); |
861 | if (FP.ParamType() == Interface_ParamInteger) { |
862 | val->SetValue (ind, atoi(FP.CValue())); ind ++; |
863 | } else if (FP.ParamType() == Interface_ParamVoid) { |
864 | val->SetValue (ind,0); ind ++; // DEFAULT : rien a dire |
865 | } else { |
866 | SendFail (amsg); |
867 | return Standard_False; |
868 | } |
869 | } |
870 | return Standard_True; |
871 | } |
872 | |
873 | |
874 | //======================================================================= |
875 | //function : ReadInts |
876 | //purpose : |
877 | //======================================================================= |
878 | |
879 | Standard_Boolean IGESData_ParamReader::ReadInts |
880 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
881 | Handle(TColStd_HArray1OfInteger)& val, const Standard_Integer index) |
882 | { |
883 | if (!PrepareRead(PC,mess,Standard_True)) return Standard_False; |
884 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
885 | val = new TColStd_HArray1OfInteger (index,index+thenbitem*thetermsz-1); |
886 | Standard_Integer ind = index; |
887 | |
888 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
889 | const Interface_FileParameter& FP = theparams->Value(i+thebase); |
890 | if (FP.ParamType() == Interface_ParamInteger) { |
891 | val->SetValue (ind, atoi(FP.CValue())); ind ++; |
892 | } else if (FP.ParamType() == Interface_ParamVoid) { |
893 | val->SetValue (ind,0); ind ++; // DEFAULT : rien a dire |
894 | } else { |
895 | char ssem[100]; |
896 | sprintf(ssem," : not an Integer, rank %d",i); |
897 | AddFail (mess,ssem," : not an Integer, rank %d"); |
898 | return Standard_False; |
899 | } |
900 | } |
901 | return Standard_True; |
902 | } |
903 | |
904 | |
905 | // ReadReals for MoniTool |
906 | |
907 | //======================================================================= |
908 | //function : ReadReals |
909 | //purpose : |
910 | //======================================================================= |
911 | |
912 | Standard_Boolean IGESData_ParamReader::ReadReals |
913 | (const IGESData_ParamCursor& PC,Message_Msg& /*amsg*/, |
914 | Handle(TColStd_HArray1OfReal)& val, const Standard_Integer index) |
915 | { |
916 | if (!PrepareRead(PC,Standard_True)) return Standard_False; |
917 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
918 | val = new TColStd_HArray1OfReal (index,index+thenbitem*thetermsz-1); |
919 | Standard_Integer ind = index; |
920 | |
921 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
922 | Standard_Real rval; |
923 | if (!ReadingReal(i,rval)) return Standard_False; |
924 | val->SetValue (ind, rval); ind ++; |
925 | } |
926 | return Standard_True; |
927 | } |
928 | |
929 | |
930 | //======================================================================= |
931 | //function : ReadReals |
932 | //purpose : |
933 | //======================================================================= |
934 | |
935 | Standard_Boolean IGESData_ParamReader::ReadReals |
936 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
937 | Handle(TColStd_HArray1OfReal)& val, const Standard_Integer index) |
938 | { |
939 | if (!PrepareRead(PC,mess,Standard_True)) return Standard_False; |
940 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
941 | val = new TColStd_HArray1OfReal (index,index+thenbitem*thetermsz-1); |
942 | Standard_Integer ind = index; |
943 | |
944 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
945 | Standard_Real rval; |
946 | if (!ReadingReal(i,mess,rval)) return Standard_False; |
947 | val->SetValue (ind, rval); ind ++; |
948 | } |
949 | return Standard_True; |
950 | } |
951 | |
952 | |
953 | // ReadTexts for MoniTool |
954 | |
955 | //======================================================================= |
956 | //function : ReadTexts |
957 | //purpose : |
958 | //======================================================================= |
959 | |
960 | Standard_Boolean IGESData_ParamReader::ReadTexts |
961 | (const IGESData_ParamCursor& PC, const Message_Msg& amsg , |
962 | Handle(Interface_HArray1OfHAsciiString)& val, const Standard_Integer index) |
963 | { |
964 | if (!PrepareRead(PC,Standard_True)) return Standard_False; |
965 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
966 | val = new Interface_HArray1OfHAsciiString(index,index+thenbitem*thetermsz-1); |
967 | Standard_Integer ind = index; |
968 | |
969 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
970 | const Interface_FileParameter& FP = theparams->Value(i+thebase); |
971 | if (FP.ParamType() != Interface_ParamText) { |
972 | if (FP.ParamType() == Interface_ParamVoid) { |
973 | val->SetValue (ind, new TCollection_HAsciiString("")); |
974 | ind ++; |
975 | //AddWarning (mess," : empty text",""); DEFAULT : rien a dire |
976 | continue; |
977 | } |
978 | SendFail(amsg); |
979 | return Standard_False; |
980 | } |
981 | Handle(TCollection_HAsciiString) tval = new TCollection_HAsciiString (FP.CValue()); |
982 | // IGESFile_Read a filtre |
983 | Standard_Integer lnt = tval->Length(); |
984 | Standard_Integer lnh = tval->Location(1,'H',1,lnt); |
985 | if (lnh <= 1 || lnh >= lnt) { |
986 | SendFail (amsg); |
987 | return Standard_False; |
988 | } else { |
989 | Standard_Integer hol = atoi (tval->SubString(1,lnh-1)->ToCString()); |
990 | if (hol != (lnt-lnh)) SendWarning(amsg); |
991 | } |
992 | val->SetValue (ind, new TCollection_HAsciiString |
993 | (tval->SubString(lnh+1,lnt)->ToCString())); |
994 | ind++; |
995 | } |
996 | return Standard_True; |
997 | } |
998 | |
999 | |
1000 | //======================================================================= |
1001 | //function : ReadTexts |
1002 | //purpose : |
1003 | //======================================================================= |
1004 | |
1005 | Standard_Boolean IGESData_ParamReader::ReadTexts |
1006 | (const IGESData_ParamCursor& PC, const Standard_CString mess, |
1007 | Handle(Interface_HArray1OfHAsciiString)& val, const Standard_Integer index) |
1008 | { |
1009 | if (!PrepareRead(PC,mess,Standard_True)) return Standard_False; |
1010 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
1011 | val = new Interface_HArray1OfHAsciiString(index,index+thenbitem*thetermsz-1); |
1012 | Standard_Integer ind = index; |
1013 | |
1014 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
1015 | const Interface_FileParameter& FP = theparams->Value(i+thebase); |
1016 | if (FP.ParamType() != Interface_ParamText) { |
1017 | if (FP.ParamType() == Interface_ParamVoid) { |
1018 | val->SetValue (ind, new TCollection_HAsciiString("")); |
1019 | ind ++; |
1020 | //AddWarning (mess," : empty text",""); DEFAULT : rien a dire |
1021 | continue; |
1022 | } |
1023 | AddFail (mess," : not given as a Text",""); |
1024 | return Standard_False; |
1025 | } |
1026 | Handle(TCollection_HAsciiString) tval = new TCollection_HAsciiString (FP.CValue()); |
1027 | // IGESFile_Read a filtre |
1028 | Standard_Integer lnt = tval->Length(); |
1029 | Standard_Integer lnh = tval->Location(1,'H',1,lnt); |
1030 | if (lnh <= 1 || lnh >= lnt) { |
1031 | AddFail (mess," : not in Hollerith Form",""); |
1032 | return Standard_False; |
1033 | } else { |
1034 | Standard_Integer hol = atoi (tval->SubString(1,lnh-1)->ToCString()); |
1035 | if (hol != (lnt-lnh)) AddWarning(mess," : bad Hollerith count ",""); |
1036 | } |
1037 | val->SetValue (ind, new TCollection_HAsciiString |
1038 | (tval->SubString(lnh+1,lnt)->ToCString())); |
1039 | ind++; |
1040 | } |
1041 | return Standard_True; |
1042 | } |
1043 | |
1044 | |
1045 | // ReadEnts for MoniTool |
1046 | |
1047 | //======================================================================= |
1048 | //function : ReadEnts |
1049 | //purpose : |
1050 | //======================================================================= |
1051 | |
1052 | Standard_Boolean IGESData_ParamReader::ReadEnts |
1053 | (const Handle(IGESData_IGESReaderData)& IR, |
1054 | const IGESData_ParamCursor& PC, const Message_Msg& amsg , |
1055 | Handle(IGESData_HArray1OfIGESEntity)& val, const Standard_Integer index) |
1056 | { |
1057 | if (!PrepareRead(PC,Standard_True)) return Standard_False; |
1058 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
1059 | Standard_Integer indmax = index+thenbitem*thetermsz-1; |
1060 | val = new IGESData_HArray1OfIGESEntity (index , indmax); |
1061 | Standard_Integer ind = index; |
1062 | Standard_Integer nbneg = 0, nbnul = 0; |
1063 | |
1064 | Standard_Integer i; // svv Jan11 2000 : porting on DEC |
1065 | for (i = FirstRead(); i > 0; i = NextRead()) { |
1066 | Standard_Integer nval; |
1067 | if (!ReadingEntityNumber(i,nval)) nval = 0; //return Standard_False; |
1068 | if (nval < 0) nbneg ++; |
1069 | if (nval > 0) { |
1070 | DeclareAndCast(IGESData_IGESEntity,anent,IR->BoundEntity(nval)); |
1071 | if (anent.IsNull()) nbnul ++; |
1072 | else if (IR->DirType(nval).Type() == 0) nbnul ++; |
1073 | else { val->SetValue (ind, anent); ind ++; } |
1074 | } |
1075 | } |
1076 | if (ind == indmax+1) { } // tableau complet |
1077 | else if (ind == index) val.Nullify(); // tableau vide |
1078 | else { |
1079 | // Trous : ils ont ete elimines, mais le tableau est a retailler |
1080 | Handle(IGESData_HArray1OfIGESEntity) tab = |
1081 | new IGESData_HArray1OfIGESEntity (index , ind-1); |
1082 | for (i = index; i < ind; i ++) tab->SetValue (i,val->Value(i)); |
1083 | val = tab; |
1084 | } |
1085 | if (nbnul > 0) { |
1086 | SendWarning (amsg); |
1087 | } |
1088 | return Standard_True; |
1089 | } |
1090 | |
1091 | |
1092 | //======================================================================= |
1093 | //function : ReadEnts |
1094 | //purpose : |
1095 | //======================================================================= |
1096 | |
1097 | Standard_Boolean IGESData_ParamReader::ReadEnts |
1098 | (const Handle(IGESData_IGESReaderData)& IR, |
1099 | const IGESData_ParamCursor& PC, const Standard_CString mess, |
1100 | Handle(IGESData_HArray1OfIGESEntity)& val, const Standard_Integer index) |
1101 | { |
1102 | if (!PrepareRead(PC,mess,Standard_True)) return Standard_False; |
1103 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
1104 | Standard_Integer indmax = index+thenbitem*thetermsz-1; |
1105 | val = new IGESData_HArray1OfIGESEntity (index , indmax); |
1106 | Standard_Integer ind = index; |
1107 | Standard_Integer nbneg = 0, nbnul = 0; |
1108 | |
1109 | Standard_Integer i; // svv Jan11 2000 : porting on DEC |
1110 | for (i = FirstRead(); i > 0; i = NextRead()) { |
1111 | Standard_Integer nval; |
1112 | if (!ReadingEntityNumber(i,mess,nval)) nval = 0; //return Standard_False; |
1113 | if (nval < 0) nbneg ++; |
1114 | if (nval > 0) { |
1115 | DeclareAndCast(IGESData_IGESEntity,anent,IR->BoundEntity(nval)); |
1116 | if (anent.IsNull()) nbnul ++; |
1117 | else if (IR->DirType(nval).Type() == 0) nbnul ++; |
1118 | else { val->SetValue (ind, anent); ind ++; } |
1119 | } |
1120 | } |
1121 | if (ind == indmax+1) { } // tableau complet |
1122 | else if (ind == index) val.Nullify(); // tableau vide |
1123 | else { |
1124 | // Trous : ils ont ete elimines, mais le tableau est a retailler |
1125 | Handle(IGESData_HArray1OfIGESEntity) tab = |
1126 | new IGESData_HArray1OfIGESEntity (index , ind-1); |
1127 | for (i = index; i < ind; i ++) tab->SetValue (i,val->Value(i)); |
1128 | val = tab; |
1129 | } |
1130 | // Messages ? |
1131 | char mest[80]; |
1132 | if (nbneg > 0) { |
1133 | sprintf(mest,"Skipped Negative Pointer(s), count %d",nbneg); |
1134 | AddWarning (mest,"Skipped Negative Pointer(s), count %d"); |
1135 | } |
1136 | if (nbnul > 0) { |
1137 | sprintf(mest,"Skipped Null Type Entity(ies), count %d",nbnul); |
1138 | AddWarning (mest,"Skipped Null Type Entity(ies), count %d"); |
1139 | } |
1140 | return Standard_True; |
1141 | } |
1142 | |
1143 | |
1144 | // ReadEntList for MoniTool |
1145 | |
1146 | //======================================================================= |
1147 | //function : ReadEntList |
1148 | //purpose : |
1149 | //======================================================================= |
1150 | |
1151 | Standard_Boolean IGESData_ParamReader::ReadEntList |
1152 | (const Handle(IGESData_IGESReaderData)& IR, |
1153 | const IGESData_ParamCursor& PC, Message_Msg& amsg, |
1154 | Interface_EntityList& val, const Standard_Boolean ord) |
1155 | { |
1156 | |
1157 | if (!PrepareRead(PC,Standard_True)) return Standard_False; |
1158 | val.Clear(); |
1159 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
1160 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
1161 | Standard_Integer nval; |
1162 | if (!ReadingEntityNumber(i,nval)) return Standard_False; |
1163 | if (nval < 0) |
1164 | { |
1165 | Message_Msg Msg219 ("XSTEP_219"); |
1166 | amsg.Arg(Msg219.Value()); |
1167 | SendWarning(amsg); |
1168 | } |
1169 | if (nval <= 0) continue; |
1170 | DeclareAndCast(IGESData_IGESEntity,anent,IR->BoundEntity(nval)); |
1171 | if (anent.IsNull()) |
1172 | { |
1173 | Message_Msg Msg216 ("XSTEP_216"); |
1174 | amsg.Arg(Msg216.Value()); |
1175 | SendWarning(amsg); |
1176 | } |
1177 | else if (IR->DirType(nval).Type() == 0) |
1178 | { |
1179 | Message_Msg Msg217 ("XSTEP_217"); |
1180 | SendWarning(TCollection_AsciiString(Msg217.Value()).ToCString()); |
1181 | } |
1182 | else if (ord) val.Append (anent); |
1183 | else val.Add (anent); |
1184 | } |
1185 | return Standard_True; |
1186 | } |
1187 | |
1188 | |
1189 | //======================================================================= |
1190 | //function : ReadEntList |
1191 | //purpose : |
1192 | //======================================================================= |
1193 | |
1194 | Standard_Boolean IGESData_ParamReader::ReadEntList |
1195 | (const Handle(IGESData_IGESReaderData)& IR, |
1196 | const IGESData_ParamCursor& PC, const Standard_CString mess, |
1197 | Interface_EntityList& val, const Standard_Boolean ord) |
1198 | { |
1199 | if (!PrepareRead(PC,mess,Standard_True)) return Standard_False; |
1200 | val.Clear(); |
1201 | if (thenbitem == 0) return Standard_True; // vide : retour Null ... |
1202 | for (Standard_Integer i = FirstRead(); i > 0; i = NextRead()) { |
1203 | Standard_Integer nval; |
1204 | if (!ReadingEntityNumber(i,mess,nval)) return Standard_False; |
1205 | if (nval < 0) AddWarning(" Negative Pointer, skipped",""); |
1206 | if (nval <= 0) continue; |
1207 | DeclareAndCast(IGESData_IGESEntity,anent,IR->BoundEntity(nval)); |
1208 | if (anent.IsNull()) AddWarning(" Null Pointer, skipped",""); |
1209 | else if (IR->DirType(nval).Type() == 0) AddWarning(" Pointer to IGES Null Entity, skipped",""); |
1210 | else if (ord) val.Append (anent); |
1211 | else val.Add (anent); |
1212 | } |
1213 | return Standard_True; |
1214 | } |
1215 | |
1216 | |
1217 | // ReadingReal for MoniTool |
1218 | |
1219 | //======================================================================= |
1220 | //function : ReadingReal |
1221 | //purpose : |
1222 | //======================================================================= |
1223 | |
1224 | Standard_Boolean IGESData_ParamReader::ReadingReal (const Standard_Integer num, |
1225 | Standard_Real& val) |
1226 | { |
1227 | const Interface_FileParameter& FP = theparams->Value(num+thebase); |
1228 | if(FP.ParamType() == Interface_ParamInteger) { |
1229 | if (!pbrealint) { |
1230 | if (testconv < 0) testconv = 0; //Interface_Static::IVal("iges.convert.read"); |
1231 | if (testconv > 0) { |
1232 | // char ssem[100]; |
1233 | pbrealint = num; |
1234 | // sprintf(ssem,": Integer converted to Real, 1st rank=%d",num); |
1235 | // AddWarning (mess,ssem,"At least one Integer converted to Real, 1st rank=%d"); |
1236 | } |
1237 | } |
1238 | Standard_Integer ival = atoi(FP.CValue()); |
1239 | val = ival; |
1240 | return Standard_True; |
1241 | } |
1242 | char text[50]; |
1243 | Standard_CString orig = FP.CValue(); |
1244 | Standard_Integer i , j = 0; |
1245 | for (i = 0; i < 50; i ++) { |
1246 | if (orig[i] == 'D' || orig[i] == 'd') |
1247 | text[j++] = 'e'; |
1248 | else |
1249 | text[j++] = orig[i]; |
1250 | if (orig[i] == '\0') break; |
1251 | } |
91322f44 |
1252 | if (FP.ParamType() == Interface_ParamReal) |
1253 | val = Atof(text); |
1254 | else if (FP.ParamType() == Interface_ParamEnum) { // convention |
7fd59977 |
1255 | if (!pbrealform) { |
1256 | if (testconv < 0) testconv = 0; //Interface_Static::IVal("iges.convert.read"); |
1257 | if (testconv > 0) { |
1258 | // char ssem[100]; |
1259 | pbrealform = num; |
1260 | // sprintf(ssem,"Real with no decimal point (added), 1st rank=%d",num); |
1261 | // AddWarning (mess,ssem,"Real with no decimal point (added), 1st rank=%d"); |
1262 | } |
1263 | } |
1264 | // Par convention (pas d enum explicite dans IGES), signifie |
1265 | // "reconnu comme flottant mais pas blanc-bleu" c-a-d sans point decimal |
1266 | // mais avec exposant (sinon ce serait un entier) |
1267 | // -> un message avertissement + on ajoute le point puis on convertit |
1268 | |
91322f44 |
1269 | val = Atof(text); |
7fd59977 |
1270 | } else if (FP.ParamType() == Interface_ParamVoid) { |
1271 | val = 0.0; // DEFAULT |
1272 | } else { |
1273 | // char ssem[100]; |
1274 | // sprintf(ssem,": not given as Real, rank %d",num); |
1275 | // AddFail (mess,ssem,": not given as Real, rank %d"); |
1276 | /* TCollection_AsciiString mess = amsg.Value(); |
1277 | if ((mess.Search("ter %d"))||(mess.Search("tre %d"))) |
1278 | amsg.AddInteger(num); // Parameter index |
1279 | */ |
1280 | return Standard_False; |
1281 | } |
1282 | return Standard_True; |
1283 | } |
1284 | |
1285 | |
1286 | //======================================================================= |
1287 | //function : ReadingReal |
1288 | //purpose : |
1289 | //======================================================================= |
1290 | |
1291 | Standard_Boolean IGESData_ParamReader::ReadingReal |
1292 | (const Standard_Integer num, const Standard_CString mess, |
1293 | Standard_Real& val) |
1294 | { |
1295 | const Interface_FileParameter& FP = theparams->Value(num+thebase); |
1296 | if (FP.ParamType() == Interface_ParamInteger) { |
1297 | if (!pbrealint) { |
1298 | if (testconv < 0) testconv = 0; //Interface_Static::IVal("iges.convert.read"); |
1299 | if (testconv > 0) { |
1300 | char ssem[100]; |
1301 | pbrealint = num; |
1302 | sprintf(ssem,": Integer converted to Real, 1st rank=%d",num); |
1303 | AddWarning (mess,ssem,"At least one Integer converted to Real, 1st rank=%d"); |
1304 | } |
1305 | } |
1306 | Standard_Integer ival = atoi(FP.CValue()); |
1307 | val = ival; |
1308 | return Standard_True; |
1309 | } |
1310 | char text[50]; |
1311 | Standard_CString orig = FP.CValue(); |
1312 | Standard_Integer i , j = 0; |
1313 | for (i = 0; i < 50; i ++) { |
1314 | if (orig[i] == 'D' || orig[i] == 'd') |
1315 | text[j++] = 'e'; |
1316 | else |
1317 | text[j++] = orig[i]; |
1318 | if (orig[i] == '\0') break; |
1319 | } |
91322f44 |
1320 | if (FP.ParamType() == Interface_ParamReal) |
1321 | val = Atof(text); |
7fd59977 |
1322 | else if (FP.ParamType() == Interface_ParamEnum) { // convention |
1323 | if (!pbrealform) { |
1324 | if (testconv < 0) testconv = 0; //Interface_Static::IVal("iges.convert.read"); |
1325 | if (testconv > 0) { |
1326 | char ssem[100]; |
1327 | pbrealform = num; |
1328 | sprintf(ssem,"Real with no decimal point (added), 1st rank=%d",num); |
1329 | AddWarning (mess,ssem,"Real with no decimal point (added), 1st rank=%d"); |
1330 | } |
1331 | } |
1332 | // Par convention (pas d enum explicite dans IGES), signifie |
1333 | // "reconnu comme flottant mais pas blanc-bleu" c-a-d sans point decimal |
1334 | // mais avec exposant (sinon ce serait un entier) |
1335 | // -> un message avertissement + on ajoute le point puis on convertit |
1336 | |
91322f44 |
1337 | val = Atof(text); |
7fd59977 |
1338 | } else if (FP.ParamType() == Interface_ParamVoid) { |
1339 | val = 0.0; // DEFAULT |
1340 | } else { |
1341 | char ssem[100]; |
1342 | sprintf(ssem,": not given as Real, rank %d",num); |
1343 | AddFail (mess,ssem,": not given as Real, rank %d"); |
1344 | return Standard_False; |
1345 | } |
1346 | return Standard_True; |
1347 | } |
1348 | |
1349 | |
1350 | // ReadingEntityNumber for MoniTool |
1351 | |
1352 | //======================================================================= |
1353 | //function : ReadingEntityNumber |
1354 | //purpose : |
1355 | //======================================================================= |
1356 | |
1357 | Standard_Boolean IGESData_ParamReader::ReadingEntityNumber (const Standard_Integer num, |
1358 | Standard_Integer& val) |
1359 | { |
1360 | const Interface_FileParameter& FP = theparams->Value(num+thebase); |
1361 | val = ParamNumber(num); |
1362 | if (val == 0) { |
1363 | Standard_Boolean nulref = Standard_False; |
1364 | if (FP.ParamType() == Interface_ParamInteger) |
1365 | nulref = (atoi(FP.CValue()) == 0); |
1366 | else if (FP.ParamType() == Interface_ParamVoid) nulref = Standard_True; |
1367 | if (!nulref) { |
1368 | // AddFail (mess," : cannot refer to an Entity",""); |
1369 | thelast = Standard_True; |
1370 | return Standard_False; |
1371 | } |
1372 | } |
1373 | return Standard_True; |
1374 | } |
1375 | |
1376 | |
1377 | //======================================================================= |
1378 | //function : ReadingEntityNumber |
1379 | //purpose : |
1380 | //======================================================================= |
1381 | |
1382 | Standard_Boolean IGESData_ParamReader::ReadingEntityNumber |
1383 | (const Standard_Integer num, const Standard_CString mess, |
1384 | Standard_Integer& val) |
1385 | { |
1386 | const Interface_FileParameter& FP = theparams->Value(num+thebase); |
1387 | val = ParamNumber(num); |
1388 | if (val == 0) { |
1389 | Standard_Boolean nulref = Standard_False; |
1390 | if (FP.ParamType() == Interface_ParamInteger) |
1391 | nulref = (atoi(FP.CValue()) == 0); |
1392 | else if (FP.ParamType() == Interface_ParamVoid) nulref = Standard_True; |
1393 | if (!nulref) { |
1394 | AddFail (mess," : cannot refer to an Entity",""); |
1395 | thelast = Standard_True; |
1396 | return Standard_False; |
1397 | } |
1398 | } |
1399 | return Standard_True; |
1400 | } |
1401 | |
1402 | |
1403 | //======================================================================= |
1404 | //function : SendFail |
1405 | //purpose : |
1406 | //======================================================================= |
1407 | |
1408 | void IGESData_ParamReader::SendFail (const Message_Msg& amsg) |
1409 | { |
1410 | thecheck->SendFail (amsg); |
1411 | thelast = Standard_False; |
1412 | } |
1413 | |
1414 | |
1415 | //======================================================================= |
1416 | //function : SendWarning |
1417 | //purpose : |
1418 | //======================================================================= |
1419 | |
1420 | void IGESData_ParamReader::SendWarning (const Message_Msg& amsg) |
1421 | { |
1422 | thecheck->SendWarning (amsg); |
1423 | thelast = Standard_False; |
1424 | } |
1425 | |
1426 | |
1427 | |
1428 | // .... Gestion courante du statut de lecture .... |
1429 | |
1430 | |
1431 | //======================================================================= |
1432 | //function : AddFail |
1433 | //purpose : |
1434 | //======================================================================= |
1435 | |
1436 | void IGESData_ParamReader::AddFail(const Standard_CString idm, |
1437 | const Handle(TCollection_HAsciiString)& afail, |
1438 | const Handle(TCollection_HAsciiString)& bfail) |
1439 | { |
1440 | afail->Insert (1,idm); |
1441 | if (bfail != afail) bfail->Insert (1,idm); |
1442 | thecheck->AddFail (afail,bfail); |
1443 | thelast = Standard_False; |
1444 | } |
1445 | |
1446 | |
1447 | //======================================================================= |
1448 | //function : AddFail |
1449 | //purpose : |
1450 | //======================================================================= |
1451 | |
1452 | void IGESData_ParamReader::AddFail(const Standard_CString idm, |
1453 | const Standard_CString afail, |
1454 | const Standard_CString bfail) |
1455 | { |
1456 | Handle(TCollection_HAsciiString) af = new TCollection_HAsciiString(afail); |
1457 | Handle(TCollection_HAsciiString) bf = af; |
1458 | if (bfail[0] != '\0') bf = new TCollection_HAsciiString(bfail); |
1459 | AddFail (idm, af,bf); |
1460 | } |
1461 | |
1462 | |
1463 | //======================================================================= |
1464 | //function : AddWarning |
1465 | //purpose : |
1466 | //======================================================================= |
1467 | |
1468 | void IGESData_ParamReader::AddWarning(const Standard_CString idm, |
1469 | const Handle(TCollection_HAsciiString)& aw, |
1470 | const Handle(TCollection_HAsciiString)& bw) |
1471 | { |
1472 | aw->Insert (1,idm); |
1473 | if (bw != aw) bw->Insert (1,idm); |
1474 | thecheck->AddWarning (aw,bw); |
1475 | } |
1476 | |
1477 | |
1478 | //======================================================================= |
1479 | //function : AddWarning |
1480 | //purpose : |
1481 | //======================================================================= |
1482 | |
1483 | void IGESData_ParamReader::AddWarning(const Standard_CString idm, |
1484 | const Standard_CString awarn, |
1485 | const Standard_CString bwarn) |
1486 | { |
1487 | Handle(TCollection_HAsciiString) aw = new TCollection_HAsciiString(awarn); |
1488 | Handle(TCollection_HAsciiString) bw = aw; |
1489 | if (bwarn[0] != '\0') bw = new TCollection_HAsciiString(bwarn); |
1490 | AddWarning (idm, aw,bw); |
1491 | } |
1492 | |
1493 | |
1494 | //======================================================================= |
1495 | //function : AddFail |
1496 | //purpose : |
1497 | //======================================================================= |
1498 | |
1499 | void IGESData_ParamReader::AddFail(const Standard_CString afail, |
1500 | const Standard_CString bfail) |
1501 | { |
1502 | thelast = Standard_False; |
1503 | thecheck->AddFail(afail,bfail); |
1504 | } |
1505 | |
1506 | |
1507 | //======================================================================= |
1508 | //function : AddFail |
1509 | //purpose : |
1510 | //======================================================================= |
1511 | |
1512 | void IGESData_ParamReader::AddFail(const Handle(TCollection_HAsciiString)& afail, |
1513 | const Handle(TCollection_HAsciiString)& bfail) |
1514 | { |
1515 | thelast = Standard_False; |
1516 | thecheck->AddFail(afail,bfail); |
1517 | } |
1518 | |
1519 | |
1520 | //======================================================================= |
1521 | //function : AddWarning |
1522 | //purpose : |
1523 | //======================================================================= |
1524 | |
1525 | void IGESData_ParamReader::AddWarning(const Standard_CString amess, |
1526 | const Standard_CString bmess) |
1527 | { |
1528 | thecheck->AddWarning(amess,bmess); |
1529 | } |
1530 | |
1531 | |
1532 | //======================================================================= |
1533 | //function : AddWarning |
1534 | //purpose : |
1535 | //======================================================================= |
1536 | |
1537 | void IGESData_ParamReader::AddWarning(const Handle(TCollection_HAsciiString)& amess, |
1538 | const Handle(TCollection_HAsciiString)& bmess) |
1539 | { |
1540 | thecheck->AddWarning(amess,bmess); |
1541 | } |
1542 | |
1543 | |
1544 | //======================================================================= |
1545 | //function : Mend |
1546 | //purpose : |
1547 | //======================================================================= |
1548 | |
1549 | void IGESData_ParamReader::Mend (const Standard_CString pref) |
1550 | { |
1551 | thecheck->Mend (pref); |
1552 | thelast = Standard_True; |
1553 | } |
1554 | |
1555 | |
1556 | //======================================================================= |
1557 | //function : HasFailed |
1558 | //purpose : |
1559 | //======================================================================= |
1560 | |
1561 | Standard_Boolean IGESData_ParamReader::HasFailed () const |
1562 | { |
1563 | return !thelast; |
1564 | } //thecheck.HasFailed(); |
1565 | |
1566 | |
1567 | //======================================================================= |
1568 | //function : Check |
1569 | //purpose : |
1570 | //======================================================================= |
1571 | |
1572 | const Handle(Interface_Check)& IGESData_ParamReader::Check () const |
1573 | { |
1574 | return thecheck; |
1575 | } |
1576 | |
1577 | |
1578 | //======================================================================= |
1579 | //function : CCheck |
1580 | //purpose : |
1581 | //======================================================================= |
1582 | |
1583 | Handle(Interface_Check)& IGESData_ParamReader::CCheck () |
1584 | { |
1585 | return thecheck; |
1586 | } |
1587 | |
1588 | |
1589 | //======================================================================= |
1590 | //function : IsCheckEmpty |
1591 | //purpose : |
1592 | //======================================================================= |
1593 | |
1594 | Standard_Boolean IGESData_ParamReader::IsCheckEmpty () const |
1595 | { |
1596 | return (!thecheck->HasFailed() && !thecheck->HasWarnings()); |
1597 | } |