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