0022627: Change OCCT memory management defaults
[occt.git] / src / IGESData / IGESData_IGESModel.cxx
1 //pdn 11.01.99 modification for linking on NT
2 //#73 rln 10.03.99 S4135: "read.scale.unit" does not affect GlobalSection
3 //#13 smh 13.01.2000 : Parsing long year date
4 #include <IGESData_IGESModel.ixx>
5 #include <TCollection_HAsciiString.hxx>
6 #include <IGESData_Protocol.hxx>
7 #include <IGESData_BasicEditor.hxx>
8 #include <Interface_Static.hxx>
9 #include <Interface_Macros.hxx>
10 #include <Message_Msg.hxx>
11
12 #include <stdio.h>
13
14
15 static Standard_CString voidline = "";
16
17 // Routine interne utilisee pour VerifyCheck
18 void IGESData_VerifyDate
19   (const Handle(TCollection_HAsciiString)& str,
20    Handle(Interface_Check)& ach, const Standard_CString mess);
21
22
23
24 //=======================================================================
25 //function : IGESData_IGESModel
26 //purpose  : 
27 //=======================================================================
28
29 IGESData_IGESModel::IGESData_IGESModel ()
30 {
31   thestart = new TColStd_HSequenceOfHAsciiString();
32 //  thecheckstx = new Interface_Check;
33 //  thechecksem = new Interface_Check;
34 }
35
36
37 //=======================================================================
38 //function : ClearHeader
39 //purpose  : 
40 //=======================================================================
41
42 void IGESData_IGESModel::ClearHeader ()
43 {
44   IGESData_GlobalSection newheader;  // Un peu brutal, certes
45   theheader = newheader;
46   thestart = new TColStd_HSequenceOfHAsciiString();
47 }
48
49
50 //=======================================================================
51 //function : DumpHeader
52 //purpose  : 
53 //=======================================================================
54
55 void IGESData_IGESModel::DumpHeader
56   (const Handle(Message_Messenger)& S, const Standard_Integer ) const
57 {
58   Standard_Integer ns = thestart->Length();
59   S<<"****    Dump of IGES Model , Start and Global Sections   ****"<<endl;
60   if (ns > 0) {
61     S << "****    Start Section : "<<ns<<" Line(s)   ****"<<"\n";
62     for (Standard_Integer i = 1; i <= ns; i ++)
63       S<<"["<<(i<10 ? " ": "")<<i<<"]:"<<thestart->Value(i)->ToCString()<<endl;
64   }
65   S << "\n"<<"****    Global Section    ****"<<"\n";
66   char sep = theheader.Separator();
67   if (sep == ',')  S << "[ 1]      Default Separator : " << sep;
68   else             S << "[ 1]  Non Default Separator : " << sep;
69   char emk = theheader.EndMark();
70   if (emk == ';')  S << "        [ 2]      Default End Mark  : " << emk;
71   else             S << "        [ 2]  Non Default End Mark  : " << emk;
72   S<<"\n";
73   Handle(TCollection_HAsciiString) str;
74   str = theheader.SendName();
75   if (!str.IsNull()) S<<"[ 3]  Sender                : "<<str->ToCString()<<endl;
76   str = theheader.FileName();
77   if (!str.IsNull()) S<<"[ 4]  (recorded) File Name  : "<<str->ToCString()<<endl;
78   str = theheader.SystemId();
79   if (!str.IsNull()) S<<"[ 5]  System Identification : "<<str->ToCString()<<endl;
80   str = theheader.InterfaceVersion();
81   if (!str.IsNull()) S<<"[ 6]  Interface Version     : "<<str->ToCString()<<endl;
82   S<<endl;
83   S << "[ 7]  Integer Bits          : " << theheader.IntegerBits()
84     << "          Features for Reals : " << endl;
85   S << "[ 8]  Single Max.Power(10)  : " << theheader.MaxPower10Single();
86   S << "         [ 9]  Digits   : " << theheader.MaxDigitsSingle()<<"\n";
87   S << "[10]  Double Max.Power(10)  : " << theheader.MaxPower10Double();
88   S << "         [11]  Digits   : " << theheader.MaxDigitsDouble() << "\n\n";
89   str = theheader.ReceiveName();
90   if (!str.IsNull()) S<<"[12]  Receiver              : "<<str->ToCString()<<"\n";
91   S << "[13]  Scale                 : " << theheader.Scale()<<"\n";
92   S << "[14]  Unit  Flag            : " << theheader.UnitFlag();
93 //  if (Interface_Static::IVal("read.scale.unit") == 1)
94     //#73 rln 10.03.99 S4135: "read.scale.unit" does not affect GlobalSection
95 //    S    << "    -> Value (in Meter) = " << theheader.UnitValue() / 1000 <<"\n";
96 //  else S << "    -> Value (in Millimeter) = " << theheader.UnitValue()<<"\n";
97   //abv 02 Mar 00: no unit parameter in OCC
98   S << "    -> Value (in CASCADE units) = " << theheader.UnitValue() <<"\n";
99   
100   str = theheader.UnitName();
101   if (!str.IsNull()) S<<"[15]  Unit  Name            : " << str->ToCString()<<"\n\n";
102   S << "[16]  Line Weight  Gradient : " << theheader.LineWeightGrad()<<"\n";
103   S << "[17]  Line Weight  Max Value: " << theheader.MaxLineWeight()<<"\n";
104
105   str = theheader.Date();
106   if (!str.IsNull()) S<<"[18]  (Creation) Date       : "<<str->ToCString()
107     <<"  i.e. "<<IGESData_GlobalSection::NewDateString(str,1)->ToCString()<<"\n";
108   S << "[19]  Resolution            : " << theheader.Resolution()<<"\n";
109   if (theheader.HasMaxCoord())
110     S<<"[20]  Maximum Coord         : " << theheader.MaxCoord() << "\n\n";
111   else S<<"[20]  Maximum Coord           not defined"<<"\n\n";
112
113   str = theheader.AuthorName();
114   if (!str.IsNull()) S<<"[21]  Author                : "<<str->ToCString()<<"\n";
115   str = theheader.CompanyName();
116   if (!str.IsNull()) S<<"[22]  Company               : "<<str->ToCString()<<"\n";
117   Standard_Integer num = theheader.IGESVersion();
118   S << "[23]  IGES Version Number   : " << num << "   -> Name : " 
119     << IGESData_BasicEditor::IGESVersionName(num);
120
121   num = theheader.DraftingStandard();
122   S << "\n"<<"[24]  Drafting Standard     : " << num;
123   if (num > 0) S<< "   -> Name : " << IGESData_BasicEditor::DraftingName(num);
124   S<<endl;
125
126   if (theheader.HasLastChangeDate()) {
127     str = theheader.LastChangeDate();
128     S <<  "[25]  Last Change Date      : " << str->ToCString() 
129       <<"  i.e. "<<IGESData_GlobalSection::NewDateString(str,1)->ToCString()<<endl;
130   }
131   else S<<"[25]  Last Change Date        not defined (version IGES < 5.1)" << endl;
132
133   if (theheader.HasApplicationProtocol()) {
134     str = theheader.ApplicationProtocol();
135     S <<  "[26]  Application Protocol  : " << str->ToCString() <<endl;
136   }
137
138   S << " ****     End of Dump      ****"<<endl;
139 }
140
141
142 //=======================================================================
143 //function : StartSection
144 //purpose  : 
145 //=======================================================================
146
147 Handle(TColStd_HSequenceOfHAsciiString) IGESData_IGESModel::StartSection
148        () const
149 {  return thestart;  }
150
151
152 //=======================================================================
153 //function : NbStartLines
154 //purpose  : 
155 //=======================================================================
156
157 Standard_Integer IGESData_IGESModel::NbStartLines () const
158 {  return thestart->Length();  }
159
160
161 //=======================================================================
162 //function : StartLine
163 //purpose  : 
164 //=======================================================================
165
166 Standard_CString IGESData_IGESModel::StartLine
167   (const Standard_Integer num) const
168 {
169   if (num > 0 && num <= thestart->Length()) return
170     thestart->Value(num)->ToCString();
171   return voidline;
172 }
173
174
175 //=======================================================================
176 //function : ClearStartSection
177 //purpose  : 
178 //=======================================================================
179
180 void   IGESData_IGESModel::ClearStartSection ()
181       {  thestart->Clear();  }
182
183     void   IGESData_IGESModel::SetStartSection
184   (const Handle(TColStd_HSequenceOfHAsciiString)& list,
185    const Standard_Boolean copy)
186 {
187   if (copy) {
188     thestart = new TColStd_HSequenceOfHAsciiString();
189     if (list.IsNull()) return;
190     Standard_Integer i, nb = list->Length();
191     for (i = 1; i <= nb; i ++) thestart->Append
192       (new TCollection_HAsciiString(list->Value(i)->ToCString()));
193   }
194   else if (list.IsNull()) thestart = new TColStd_HSequenceOfHAsciiString();
195   else thestart = list;
196 }
197
198
199 //=======================================================================
200 //function : AddStartLine
201 //purpose  : 
202 //=======================================================================
203
204 void   IGESData_IGESModel::AddStartLine
205   (const Standard_CString line, const Standard_Integer atnum)
206 {
207   if (atnum <= 0 || atnum > thestart->Length())
208     thestart->Append (new TCollection_HAsciiString(line));
209   else thestart->InsertBefore (atnum,new TCollection_HAsciiString(line));
210 }
211
212
213
214 //=======================================================================
215 //function : GlobalSection
216 //purpose  : 
217 //=======================================================================
218
219 const IGESData_GlobalSection& IGESData_IGESModel::GlobalSection () const
220       {  return theheader;  }
221
222
223 //=======================================================================
224 //function : SetGlobalSection
225 //purpose  : 
226 //=======================================================================
227
228 void IGESData_IGESModel::SetGlobalSection
229   (const IGESData_GlobalSection& header)
230       {  theheader = header;  }
231
232
233 //=======================================================================
234 //function : ApplyStatic
235 //purpose  : 
236 //=======================================================================
237
238 Standard_Boolean  IGESData_IGESModel::ApplyStatic
239   (const Standard_CString param)
240 {
241   if (param[0] == '\0') {
242     //Standard_Boolean ret = Standard_True; //szv#4:S4163:12Mar99 not needed
243     ApplyStatic("receiver"); //szv#4:S4163:12Mar99 'ret =' not needed
244     ApplyStatic("author"); //szv#4:S4163:12Mar99 'ret =' not needed
245     ApplyStatic("company"); //szv#4:S4163:12Mar99 'ret =' not needed
246     return Standard_True;
247   }
248
249   Standard_CString val;
250   if (param[0] == 'r') {
251     val = Interface_Static::CVal("write.iges.header.receiver");
252     if (!val || val[0] == '\0') return Standard_False;
253     theheader.SetReceiveName (new TCollection_HAsciiString(val));
254   }
255   if (param[0] == 'a') {
256     val = Interface_Static::CVal("write.iges.header.author");
257     if (!val || val[0] == '\0') return Standard_False;
258     theheader.SetAuthorName (new TCollection_HAsciiString(val));
259   }
260   if (param[0] == 'c') {
261     val = Interface_Static::CVal("write.iges.header.company");
262     if (!val || val[0] == '\0') return Standard_False;
263     theheader.SetCompanyName (new TCollection_HAsciiString(val));
264   }
265   return Standard_True;
266 }
267
268
269 //=======================================================================
270 //function : Entity
271 //purpose  : 
272 //=======================================================================
273
274 Handle(IGESData_IGESEntity) IGESData_IGESModel::Entity
275   (const Standard_Integer num) const
276 {  return GetCasted(IGESData_IGESEntity,Value(num));  }
277
278
279 //=======================================================================
280 //function : DNum
281 //purpose  : 
282 //=======================================================================
283
284 Standard_Integer  IGESData_IGESModel::DNum
285   (const Handle(IGESData_IGESEntity)& ent) const
286 {
287   Standard_Integer num = Number(ent);
288   if (num == 0) return 0;
289   else return 2*num-1;
290 }
291
292
293 //=======================================================================
294 //function : GetFromAnother
295 //purpose  : 
296 //=======================================================================
297
298 void IGESData_IGESModel::GetFromAnother
299   (const Handle(Interface_InterfaceModel)& other)
300 {
301   DeclareAndCast(IGESData_IGESModel,another,other);
302   theheader = another->GlobalSection();
303   theheader.CopyRefs();
304   SetStartSection (another->StartSection(),Standard_True);
305 }
306
307
308 //=======================================================================
309 //function : NewEmptyModel
310 //purpose  : 
311 //=======================================================================
312
313 Handle(Interface_InterfaceModel) IGESData_IGESModel::NewEmptyModel () const
314       {  return new IGESData_IGESModel;  }
315
316
317 //=======================================================================
318 //function : VerifyCheck
319 //purpose  : 
320 //=======================================================================
321
322 void  IGESData_IGESModel::VerifyCheck (Handle(Interface_Check)& ach) const
323 {
324   // MGE 23/07/98
325   // =====================================
326   //Message_Msg Msg40 ("XSTEP_40");
327   //Message_Msg Msg41 ("XSTEP_41");
328   //Message_Msg Msg42 ("XSTEP_42");
329   //Message_Msg Msg43 ("XSTEP_43");
330   //Message_Msg Msg44 ("XSTEP_44");
331   //Message_Msg Msg45 ("XSTEP_45");
332   //Message_Msg Msg46 ("XSTEP_46");
333   //Message_Msg Msg47 ("XSTEP_47");
334   //Message_Msg Msg48 ("XSTEP_48");
335   //Message_Msg Msg50 ("XSTEP_50");
336   //Message_Msg Msg51 ("XSTEP_51");
337   //Message_Msg Msg52 ("XSTEP_52");
338   //Message_Msg Msg53 ("XSTEP_53");
339   //Message_Msg Msg54 ("XSTEP_54");
340   //Message_Msg Msg55 ("XSTEP_55");
341   // =====================================
342
343   char del[2];
344   del[0] = theheader.Separator();
345   del[1] = theheader.EndMark();
346   // Sending of message : Parameter Delimiter Character and Record Delimiter Character must be different.
347   if (del[0] == del[1]) {
348     Message_Msg Msg40 ("XSTEP_40");
349     ach->SendFail(Msg40);
350   }
351   for (int i = 0; i <= 1; i ++) {
352     if ( del[i] <= 32 || del[i] == 43  || del[i] == 45 || del[i] == 46 ||
353         (del[i] >= 48 && del[i] <= 57) || del[i] == 68 || del[i] == 69 ||
354         del [i] == 72 || del[i] >= 127) {
355         // Sending of message : Parameter Delimiter Character is incorrect.
356       if (i == 0) {
357         Message_Msg Msg41 ("XSTEP_41");
358         ach->SendFail(Msg41);
359       }
360       // Sending of message : Character Record Delimiter parameter is incorrect.
361       else {
362         Message_Msg Msg42 ("XSTEP_42");
363         ach->SendFail (Msg42);
364       }
365     }
366   }
367   // Sending of message : Single Precision Magnitude parameter is incorrect. 
368   if (theheader.MaxPower10Single() <= 0) {
369     Message_Msg Msg43 ("XSTEP_43");
370     ach->SendFail(Msg43);
371   }
372
373   // Sending of message : Precision Significance parameter is incorrect.
374   if (theheader.MaxDigitsSingle()  <= 0) {
375     Message_Msg Msg44 ("XSTEP_44");
376     ach->SendFail(Msg44);
377   }
378
379   // Sending of messages : Double Precision Magnitude parameter is incorrect.
380   if (theheader.MaxPower10Double() <= 0) {
381     Message_Msg Msg45 ("XSTEP_45");
382     ach->SendFail(Msg45);
383   }
384
385   // Sending of message : Double Precision Significance parameter is incorrect.
386   if (theheader.MaxDigitsDouble()  <= 0) {
387     Message_Msg Msg46 ("XSTEP_46");
388     ach->SendFail(Msg46);
389   }
390
391   // Sending of message : Model Space Scale parameter is incorrect.
392   if (theheader.Scale() <= 0.) {
393     Message_Msg Msg47 ("XSTEP_47");
394     ach->SendFail(Msg47);
395   }
396
397   Standard_Integer unf = theheader.UnitFlag();
398
399   // Sending of message : Unit Flag parameter is incorrect.
400   if (unf  < 1 || unf > 11) {
401     Message_Msg Msg48 ("XSTEP_48");
402     ach->SendFail(Msg48);
403   }
404
405 // ..  verifie-t-on UnitName en accord avec UnitFlag ?
406   if (theheader.UnitName().IsNull()) {
407     // Sending of message : Unit Name parameter is undefined.
408     if (unf == 3) {
409       Message_Msg Msg50 ("XSTEP_50");
410       ach->SendFail(Msg50);
411     }
412   }
413   else {
414     Standard_CString unm  = theheader.UnitName()->ToCString();
415     Standard_Boolean unok = Standard_True;
416     switch (unf) {
417       case  1 : unok = (!strcmp(unm,"IN") || !strcmp(unm,"INCH"));  break;
418       case  2 : unok = !strcmp(unm,"MM");   break;
419       case  3 : unok = Standard_True;       break;  // nom libre
420       case  4 : unok = !strcmp(unm,"FT");   break;
421       case  5 : unok = !strcmp(unm,"MI");   break;
422       case  6 : unok = !strcmp(unm,"M");    break;
423       case  7 : unok = !strcmp(unm,"KM");   break;
424       case  8 : unok = !strcmp(unm,"MIL");  break;
425       case  9 : unok = !strcmp(unm,"UM");   break;
426       case 10 : unok = !strcmp(unm,"CM");   break;
427       case 11 : unok = !strcmp(unm,"UIN");  break;
428       default : Message_Msg Msg48 ("XSTEP_48"); ach->SendFail(Msg48);
429         break;
430     }
431     // Sending of message : Flag parameter doesn`t correspond to the Unit Name parameter.
432     if (!unok) {
433       Message_Msg Msg51 ("XSTEP_51");
434       ach->SendFail(Msg51);
435     }
436   }
437
438   IGESData_VerifyDate (theheader.Date(),ach,"Creation Date");
439   // Sending of message : Minimum Resolution parameter is incorrect.
440   if (theheader.Resolution() <= 0.) {
441     Message_Msg Msg52 ("XSTEP_52");
442     ach->SendFail(Msg52);
443   }
444   // ..  comment verifier les coordonnees max ?
445
446   // Sending of message : Version Flag parameter is incorrect.
447   if (theheader.IGESVersion() < 1 ||
448       theheader.IGESVersion() > IGESData_BasicEditor::IGESVersionMax()) {
449     Message_Msg Msg53 ("XSTEP_53");
450     ach->SendWarning(Msg53);
451   }
452
453   // Sending of message : Drafting Standard Flag parameter is incorrect.
454   if (theheader.DraftingStandard() < 0 ||
455       theheader.DraftingStandard() > IGESData_BasicEditor::DraftingMax()) {
456     Message_Msg Msg54 ("XSTEP_54");
457     ach->SendWarning(Msg54);
458   }
459
460   // Sending of message : 
461   if (theheader.IGESVersion() >= 9) {
462     // Sending of message : Last change Date parameter is undefined.
463     if (!theheader.HasLastChangeDate()) {
464       Message_Msg Msg55 ("XSTEP_55");
465       ach->SendWarning(Msg55);
466     }
467     else IGESData_VerifyDate (theheader.LastChangeDate(),ach,"Last Change Date");
468   }
469 }
470
471
472 void IGESData_VerifyDate(const Handle(TCollection_HAsciiString)& str,
473                          Handle(Interface_Check)& ach,
474                          const Standard_CString mess)
475 {
476   // MGE 23/07/98
477   // =====================================
478   Message_Msg Msg57 ("XSTEP_57");
479   // =====================================
480
481   //  Attention c est du Hollerith
482   if (str.IsNull())
483     {  ach->SendFail(Msg57);  return;  }
484
485   Handle(TCollection_HAsciiString) stdvar = str;
486   if (strcmp(mess,"Last Change Date")==0)
487     Msg57.Arg(25);
488   else
489     Msg57.Arg(18);
490   if (((stdvar->Length() != 13) && (stdvar->Length() != 15)) || !stdvar->IsRealValue()) ach->SendFail(Msg57); 
491   //smh#13 For short year date
492   else if ((stdvar->Value(3) > '1' || 
493             (stdvar->Value(3) == '1' && stdvar->Value(4) > '2'))&&(stdvar->Length() == 13)) ach->SendFail(Msg57);  
494   
495   else if ((stdvar->Value(5) > '3' ||
496             (stdvar->Value(5) == '3' && stdvar->Value(6) > '1'))&&(stdvar->Length() == 13)) ach->SendFail(Msg57);  
497   else if ((stdvar->Value(7) != '.' || stdvar->Value(10) > '5' || stdvar->Value(12) > '5')&&(stdvar->Length() == 13))
498     ach->SendFail(Msg57);
499   else if ((stdvar->Value(8) > '2' ||
500             stdvar->Value(8) == '2' && stdvar->Value(9) > '3')&&(stdvar->Length() == 13)) ach->SendFail(Msg57);  
501   //smh#13 For long year date 
502   else if ( (stdvar->Value(5) > '1' ||
503              (stdvar->Value(5) == '1' && stdvar->Value(6) > '2'))&&(stdvar->Length() == 15)) ach->SendFail(Msg57);  
504   else if ((stdvar->Value(7) > '3' ||
505             (stdvar->Value(7) == '3' && stdvar->Value(8) > '1'))&&(stdvar->Length() == 15)) ach->SendFail(Msg57);  
506   else if ((stdvar->Value(9) != '.' || stdvar->Value(12) > '5' || stdvar->Value(14) > '5')&&(stdvar->Length() == 15))
507     ach->SendFail(Msg57);
508   else if ((stdvar->Value(10) > '2' ||
509             stdvar->Value(10) == '2' && stdvar->Value(11) > '3')&&(stdvar->Length() == 15)) ach->SendFail(Msg57);  
510   
511 }
512
513
514 //=======================================================================
515 //function : SetLineWeights
516 //purpose  : 
517 //=======================================================================
518
519 void IGESData_IGESModel::SetLineWeights (const Standard_Real defw)
520 {
521   Standard_Integer nb  = NbEntities();
522   Standard_Integer lwg = theheader.LineWeightGrad();
523   Standard_Real maxw   = theheader.MaxLineWeight();
524   if (lwg > 0) {  maxw = maxw/lwg; lwg = 1;  }
525    for (Standard_Integer i = 1; i <= nb; i ++)
526      Entity(i)->SetLineWeight(defw,maxw,lwg);
527 }
528
529
530 //=======================================================================
531 //function : ClearLabels
532 //purpose  : 
533 //=======================================================================
534
535 void  IGESData_IGESModel::ClearLabels ()  
536 {
537 }
538
539
540 //=======================================================================
541 //function : PrintLabel
542 //purpose  : 
543 //=======================================================================
544
545 void  IGESData_IGESModel::PrintLabel
546   (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const
547
548   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
549   if (igesent.IsNull()) S<<"Null";
550    else {
551      Standard_Integer num = Number(ent);
552      if (num == 0) S<<"??";
553      else          S<<"D"<<(2*num-1);
554    }
555 }
556
557
558 //=======================================================================
559 //function : PrintToLog
560 //purpose  : 
561 //=======================================================================
562
563 void  IGESData_IGESModel::PrintToLog
564   (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const
565 {
566   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
567   if (!igesent.IsNull()) {
568     Standard_Integer num = Number(ent);
569     if (num == 0) S<<"??";
570     else {
571       S<<" DE : "<<(2*num-1) << " type : " << igesent->TypeNumber();
572 //      Standard_Integer num2 = igesent->TypeNumber();
573     }
574   }
575 }
576
577
578 //=======================================================================
579 //function : PrintInfo
580 //purpose  : 
581 //=======================================================================
582
583 void  IGESData_IGESModel::PrintInfo
584   (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const
585 {
586   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
587   if (igesent.IsNull()) S<<"(NOT IGES)";
588   else {
589     Standard_Integer num = Number(ent);
590     if (num == 0) S<<"??";
591     else  {
592       S<<(2*num-1) << "type " << Type(ent)->Name();
593     }
594   }
595 }
596
597
598 //=======================================================================
599 //function : StringLabel
600 //purpose  : 
601 //=======================================================================
602
603 Handle(TCollection_HAsciiString) IGESData_IGESModel::StringLabel(const Handle(Standard_Transient)& ent) const
604 {
605   Handle(TCollection_HAsciiString) label;
606   DeclareAndCast(IGESData_IGESEntity,igesent,ent);
607   if (igesent.IsNull()) return new TCollection_HAsciiString("(NOT IGES)");
608   else {
609     char text[20];
610     Standard_Integer num = Number(ent);
611     if (num > 0) sprintf(text,"D%d",2*num-1);
612     else         sprintf(text,"D0...");
613     label = new TCollection_HAsciiString(text);
614   }
615   return label;
616 }