summaryrefslogtreecommitdiff
path: root/src/IGESData/IGESData_GlobalSection.cxx
blob: a4219e00be99b3faf37d930f61490a578aa2339f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
//#52 rln 06.01.99 writing value 1.e-07
//gka 19.01.99 changing size of ParamSet
//#65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000 and YYYYMMDD.HHMMSS after Y2000)
//#66 rln Setting IGES 5.3 by default
//#73 rln 10.03.99 S4135: "read.scale.unit" is applied after translation
#include <IGESData_GlobalSection.ixx>
#include <Interface_ParamType.hxx>
#include <Interface_FloatWriter.hxx>
#include <Interface_FileReaderData.hxx>
#include <Interface_FileParameter.hxx>
#include <OSD_Process.hxx>
#include <Quantity_Date.hxx>
#include <Interface_Static.hxx>
#include <IGESData_BasicEditor.hxx>
#include <stdio.h>

// MGE 21/07/98
#include <Message_Msg.hxx>

#include <UnitsMethods.hxx>

//  valeurs en MILLIMETRE pardefaut, reajustable
//static Standard_Real convunit = 1000.;


//  Routines locales copiant une string [l`ideal serait : astr = astr->Copy()]
//    et transformant un CString (Hollerith ou non) en HAsciiString non Holl.
//    et l inverse


static void CopyString (Handle(TCollection_HAsciiString)& astr);

static void MakeHollerith(const Handle(TCollection_HAsciiString)& astr,
                          char* text, Standard_Integer& lt);

void CopyString (Handle(TCollection_HAsciiString)& astr)
{
  if (astr.IsNull()) return;   // ne rien faire si String pas definie !
  Handle(TCollection_HAsciiString) S = new TCollection_HAsciiString("");
  S->AssignCat(astr);  astr = S;
}

void MakeHollerith(const Handle(TCollection_HAsciiString)& astr,
   char* text, Standard_Integer& lt)
{
  lt = 0;  text[0] = '\0';
  if (astr.IsNull()) return;
  Standard_Integer ln = astr->Length();
  if (ln == 0) return;
  sprintf (text,"%dH%s",ln,astr->ToCString());
  lt = ln+2;  if (ln >= 10) lt ++;  if (ln >= 100) lt ++;    // strlen text
}


//=======================================================================
//function : IGESData_GlobalSection
//purpose  : 
//=======================================================================

IGESData_GlobalSection::IGESData_GlobalSection ()
{
//  convunit = 1000.;
  //#73 rln 10.03.99 S4135: "read.scale.unit" is applied after translation
  //if (Interface_Static::IVal("read.scale.unit") == 1) convunit = 1;
}


// pourrait etre une methode generale au package en fait
//=======================================================================
//function : TranslatedFromHollerith
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::TranslatedFromHollerith
       (const Handle(TCollection_HAsciiString)& astr) const
{
  Handle(TCollection_HAsciiString) res;
  if (astr.IsNull()) return res;
  Standard_Integer n = astr->Search("H");
  if (n > 1) {
    if (!astr->Token("H")->IsIntegerValue()) n = 0;
  }
  if (n > 1 && n < astr->Length()) res = astr->SubString(n+1,astr->Length());
  else if(astr->ToCString()== NULL)
    res = new TCollection_HAsciiString;
  else res = new TCollection_HAsciiString(astr->ToCString());
  return res;
}


//=======================================================================
//function : Init
//purpose  : 
//=======================================================================

void IGESData_GlobalSection::Init(const Handle(Interface_ParamSet)& params,
                                  Handle(Interface_Check)& ach)
{
  // MGE 21/07/98
  // Building of messages
  //======================================
  //Message_Msg Msg39 ("XSTEP_39");
  //Message_Msg Msg48 ("XSTEP_48");
  //Message_Msg Msg49 ("XSTEP_49");
  //======================================

  theSeparator = ',';       theEndMark = ';';
  theSendName.Nullify();    theFileName.Nullify();  theSystemId.Nullify();
  theInterfaceVersion.Nullify();
  theIntegerBits       = 32;  // par defaut, simple = entier = 32b, double = 64
  theMaxPower10Single  =  38;  theMaxDigitsSingle   =  6;
  theMaxPower10Double  = 308;  theMaxDigitsDouble   = 15;
  theReceiveName.Nullify();
  theScale             = 1.0;
  theUnitFlag          = 0;  theUnitName.Nullify();
  theLineWeightGrad    = 1;  theMaxLineWeight     = 0.;
  theDate.Nullify();
  theResolution        = 0.; theMaxCoord          = 0.; hasMaxCoord = Standard_False;
  theAuthorName.Nullify();  theCompanyName.Nullify();
  theIGESVersion       = 11;//3 //#66 rln Setting IGES 5.3 by default(To avoid misleading fails below)
  theDraftingStandard  = 0;
  theLastChangeDate.Nullify();  // nouveaute 5.1 (peut etre absente)
  theAppliProtocol.Nullify();   // nouveaute 5.3 (peut etre absente)

  Standard_Integer nbp = params->NbParams();

  // Sending of message : Incorrect number of parameters (following the IGES version)
  // Version less than 5.3 
  if  (theIGESVersion < 11) {
    if ((nbp < 24) || (nbp > 25)) {
       // 24 or 25 parameters are expected (parameter 25 is not required)
      Message_Msg Msg39 ("XSTEP_39");
      Msg39.Arg(24);
      Msg39.Arg(25);
      if (nbp < 24) ach->SendFail(Msg39);
      else          ach->SendWarning(Msg39);
    }
  }
  // Version 5.3 
  else if ((nbp < 25) || (nbp > 26)) {
    // 25 or 26 parameters are expected (parameter 25 is not required)
    Message_Msg Msg39 ("XSTEP_39");
    Msg39.Arg(25);
    Msg39.Arg(26);
    if (nbp < 25) ach->SendFail(Msg39);
    else          ach->SendWarning(Msg39);
  }

  for (Standard_Integer i = 1; i <= nbp; i ++) {
    Standard_Integer intval = 0;  Standard_Real realval = 0.0;
    Handle(TCollection_HAsciiString) strval;  // doit repartir a null
    //char message[80]; //szv#4:S4163:12Mar99 unused
    Standard_CString    val = params->Param(i).CValue();
    Interface_ParamType fpt = params->Param(i).ParamType();
    if (fpt == Interface_ParamVoid) continue;
    
    // if the param is an Integer
    if (fpt == Interface_ParamInteger) {
       // but a real is expected 
      if ( i == 13 || i == 17 || i == 19 || i == 20)
	realval = atof(val);
      intval  = atoi(val);
    }

    // if the param is a Real
    else if (fpt == Interface_ParamReal || fpt == Interface_ParamEnum) {
      char text[50];
      Standard_Integer k , j = 0;
      for (k = 0; k < 50; k ++) {
        if (val[k] ==  'D' || val[k] == 'd')
          text[j++] = 'e';
        else
          text[j++] = val[k];  
        if (val[k] == '\0') break;
      }
      realval = atof(text);//Interface_FileReaderData::Fastof(val);
    }

    // if the param is a text
    else if (fpt == Interface_ParamText) {
      strval = new TCollection_HAsciiString (val);
      if (val[0] != '\0') {
	Standard_Integer nhol = strval->Search("H");
	Standard_Integer lhol = strval->Length();
	if (nhol > 1) 
	  if (!strval->Token("H")->IsIntegerValue()) nhol = 0;
	if (nhol > 1 && nhol < lhol) 
	  strval = strval->SubString(nhol+1,lhol);
      }
    }

    char sepend = '\0';
    if (i < 3) {
      if (val[0] != '\0') sepend = val[0];
      if (val[1] == 'H')  sepend = val[2];  // prioritaire
    }

    switch (i) 
     {
      case  1 : if (sepend != '\0') theSeparator = sepend;    break;
      case  2 : if (sepend != '\0') theEndMark   = sepend;    break;
      case  3 : theSendName                      = strval;    break;
      case  4 : theFileName                      = strval;    break;
      case  5 : theSystemId                      = strval;    break;
      case  6 : theInterfaceVersion              = strval;    break;
      case  7 : theIntegerBits                   = intval;    break;
      case  8 : theMaxPower10Single              = intval;    break;
      case  9 : theMaxDigitsSingle               = intval;    break;
      case 10 : theMaxPower10Double              = intval;    break;
      case 11 : theMaxDigitsDouble               = intval;    break;
      case 12 : theReceiveName                   = strval;    break;
      case 13 : theScale                         = realval;   break;
      case 14 : theUnitFlag                      = intval;    break;
      case 15 : theUnitName                      = strval;    break;
      case 16 : theLineWeightGrad                = intval;    break;
      case 17 : theMaxLineWeight                 = realval;   break;
      case 18 : theDate                          = strval;    break;
      case 19 : theResolution                    = realval;   break;
      case 20 : theMaxCoord                      = realval;
		hasMaxCoord                      = Standard_True;  break;
      case 21 : theAuthorName                    = strval;    break;
      case 22 : theCompanyName                   = strval;    break;
      case 23 : theIGESVersion                   = intval;    break;
      case 24 : theDraftingStandard              = intval;    break;
      case 25 : theLastChangeDate                = strval;    break;
      case 26 : theAppliProtocol                 = strval;    break;
      default : break;
    }
  }
  
  //:45 by abv 11.12.97: if UnitFlag is not defined in the file, 
  // restore it from UnitName. Repris par CKY 13-FEV-1998
  if ( theUnitFlag == 0 || theUnitFlag == 3 ) {
    Standard_Integer corrected = 0 ;
    if(theUnitName.IsNull())
      //default (inches) value taken
      corrected = 1;
    else
      corrected = IGESData_BasicEditor::UnitNameFlag (theUnitName->ToCString());
    if (corrected > 0) theUnitFlag = corrected;
    else if (theUnitFlag == 3) {
      Message_Msg Msg49 ("XSTEP_49");
      ach->SendWarning (Msg49);
    }
    else {
      Message_Msg Msg48 ("XSTEP_48");
      ach->SendFail (Msg48);
    }
  }
}


//=======================================================================
//function : CopyRefs
//purpose  : 
//=======================================================================

void IGESData_GlobalSection::CopyRefs ()
{
  CopyString(theSendName);   CopyString(theFileName);  CopyString(theSystemId);
  CopyString(theInterfaceVersion);  CopyString(theReceiveName);
  CopyString(theUnitName);          CopyString(theDate);
  CopyString(theAuthorName);        CopyString(theCompanyName);
  CopyString(theLastChangeDate);    CopyString(theAppliProtocol);
}


//=======================================================================
//function : Params
//purpose  : 
//=======================================================================

Handle(Interface_ParamSet) IGESData_GlobalSection::Params () const
{
  char vide[1];  char uncar[2];  char nombre[20];  char text[200];
  Standard_Integer lt;
  vide[0] = uncar[1] = '\0';  uncar[0] = ',';
  Handle(Interface_ParamSet) res  = new Interface_ParamSet(26);  //gka 19.01.99
  if (theSeparator == ',') res->Append (vide,0,Interface_ParamVoid,0);
  else { uncar[0] = theSeparator; res->Append (uncar,1,Interface_ParamMisc,0); }

  if (theEndMark == ';') res->Append (vide,0,Interface_ParamVoid,0);
  else { uncar[0] = theEndMark; res->Append (uncar,1,Interface_ParamMisc,0); }

  MakeHollerith (theSendName,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  MakeHollerith (theFileName,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  MakeHollerith (theSystemId,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  MakeHollerith (theInterfaceVersion,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  sprintf(nombre,"%d",theIntegerBits);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  sprintf(nombre,"%d",theMaxPower10Single);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  sprintf(nombre,"%d",theMaxDigitsSingle);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  sprintf(nombre,"%d",theMaxPower10Double);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  sprintf(nombre,"%d",theMaxDigitsDouble);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  MakeHollerith (theReceiveName,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  Interface_FloatWriter::Convert (theScale,nombre,Standard_True,0.,0.,"%f","%f");
//  sprintf(nombre,"%f",theScale);
  res->Append (nombre,strlen(nombre),Interface_ParamReal,0);

  sprintf(nombre,"%d",theUnitFlag);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  MakeHollerith (theUnitName,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  sprintf(nombre,"%d",theLineWeightGrad);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  Interface_FloatWriter::Convert (theMaxLineWeight,nombre,Standard_True,0.,0.,"%f","%f");
//  sprintf(nombre,"%f",theMaxLineWeight);
  res->Append (nombre,strlen(nombre),Interface_ParamReal,0);

  MakeHollerith (theDate,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  Interface_FloatWriter::Convert (theResolution,nombre,Standard_True,0.,0.,"%g","%g");
//  sprintf(nombre,"%f",theResolution);
  res->Append (nombre,strlen(nombre),Interface_ParamReal,0);

  if (hasMaxCoord)
    Interface_FloatWriter::Convert (theMaxCoord,nombre,Standard_True,0.,0.,"%f","%f");
  //  sprintf(nombre,"%f",theMaxCoord);
  else nombre[0] = '\0';
  res->Append (nombre,strlen(nombre),Interface_ParamReal,0);

  MakeHollerith (theAuthorName,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  MakeHollerith (theCompanyName,text,lt);
  res->Append (text,lt, Interface_ParamText,0);

  sprintf(nombre,"%d",theIGESVersion);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  sprintf(nombre,"%d",theDraftingStandard);
  res->Append (nombre,strlen(nombre),Interface_ParamInteger,0);

  if (!theLastChangeDate.IsNull()) {
    MakeHollerith (theLastChangeDate,text,lt);
    res->Append (text,lt, Interface_ParamText,0);
  }

  if (!theAppliProtocol.IsNull()) {
    MakeHollerith (theAppliProtocol,text,lt);
    res->Append (text,lt, Interface_ParamText,0);
  }
// Ici : parametre absent ignore

  return res;
}


// ###############           QUERIES           ###############


//=======================================================================
//function : Separator
//purpose  : 
//=======================================================================

Standard_Character IGESData_GlobalSection::Separator () const
{
  return theSeparator;
}


//=======================================================================
//function : EndMark
//purpose  : 
//=======================================================================

Standard_Character IGESData_GlobalSection::EndMark () const
{
  return theEndMark;
}


//=======================================================================
//function : SendName
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::SendName () const
{
  return theSendName;
}


//=======================================================================
//function : FileName
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::FileName () const
{
  return theFileName;
}


//=======================================================================
//function : SystemId
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::SystemId () const
{
  return theSystemId;
}


//=======================================================================
//function : InterfaceVersion
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::InterfaceVersion () const
{
  return theInterfaceVersion;
}


//=======================================================================
//function : IntegerBits
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::IntegerBits () const
{
  return theIntegerBits;
}


//=======================================================================
//function : MaxPower10Single
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::MaxPower10Single () const
{
  return theMaxPower10Single;
}


//=======================================================================
//function : MaxDigitsSingle
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::MaxDigitsSingle () const
{
  return theMaxDigitsSingle;
}


//=======================================================================
//function : MaxPower10Double
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::MaxPower10Double () const
{
  return theMaxPower10Double;
}


//=======================================================================
//function : MaxDigitsDouble
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::MaxDigitsDouble () const
{
  return theMaxDigitsDouble;
}


//=======================================================================
//function : ReceiveName
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::ReceiveName () const
{
  return theReceiveName;
}


//=======================================================================
//function : Scale
//purpose  : 
//=======================================================================

Standard_Real IGESData_GlobalSection::Scale () const
{
  return theScale;
}


//=======================================================================
//function : UnitFlag
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::UnitFlag () const
{
  return theUnitFlag;
}


//=======================================================================
//function : UnitName
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::UnitName () const
{
  return theUnitName;
}


//=======================================================================
//function : LineWeightGrad
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::LineWeightGrad () const
{
  return theLineWeightGrad;
}


//=======================================================================
//function : MaxLineWeight
//purpose  : 
//=======================================================================

Standard_Real IGESData_GlobalSection::MaxLineWeight () const
{
  return theMaxLineWeight;
}


//=======================================================================
//function : Date
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::Date () const
{
  return theDate;
}


//=======================================================================
//function : Resolution
//purpose  : 
//=======================================================================

Standard_Real IGESData_GlobalSection::Resolution () const
{
  return theResolution;
}


//=======================================================================
//function : MaxCoord
//purpose  : 
//=======================================================================

Standard_Real IGESData_GlobalSection::MaxCoord () const
{
  return theMaxCoord;
}


//=======================================================================
//function : HasMaxCoord
//purpose  : 
//=======================================================================

Standard_Boolean IGESData_GlobalSection::HasMaxCoord () const
{
  return hasMaxCoord;
}


//=======================================================================
//function : AuthorName
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::AuthorName () const
{
  return theAuthorName;
}


//=======================================================================
//function : CompanyName
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::CompanyName () const
{
  return theCompanyName;
}


//=======================================================================
//function : IGESVersion
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::IGESVersion () const
{
  return theIGESVersion;
}


//=======================================================================
//function : DraftingStandard
//purpose  : 
//=======================================================================

Standard_Integer IGESData_GlobalSection::DraftingStandard () const
{
  return theDraftingStandard;
}


//=======================================================================
//function : LastChangeDate
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::LastChangeDate () const
{
  return theLastChangeDate;
}


//=======================================================================
//function : HasLastChangeDate
//purpose  : 
//=======================================================================

Standard_Boolean IGESData_GlobalSection::HasLastChangeDate () const
{
  return (!theLastChangeDate.IsNull());
}


//=======================================================================
//function : SetLastChangeDate
//purpose  : 
//=======================================================================

void IGESData_GlobalSection::SetLastChangeDate ()
{
  if (HasLastChangeDate()) return;
  Standard_Integer mois,jour,annee,heure,minute,seconde,millisec,microsec;
  OSD_Process system;
  Quantity_Date ladate = system.SystemDate();
  ladate.Values (mois,jour,annee,heure,minute,seconde,millisec,microsec);
  if (annee < 2000)
    //#65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000)
    theLastChangeDate = NewDateString (annee,mois,jour,heure,minute,seconde,0);
  else 
    //#65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000)
    theLastChangeDate = NewDateString (annee,mois,jour,heure,minute,seconde, -1);
}


//=======================================================================
//function : HasApplicationProtocol
//purpose  : 
//=======================================================================

Standard_Boolean IGESData_GlobalSection::HasApplicationProtocol () const
{
  return !theAppliProtocol.IsNull();
}


//=======================================================================
//function : ApplicationProtocol
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::ApplicationProtocol () const
{
  return theAppliProtocol;
}


//=======================================================================
//function : NewDateString
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::NewDateString
       (const Standard_Integer annee, const Standard_Integer mois,
        const Standard_Integer jour, const Standard_Integer heure,
        const Standard_Integer minute, const Standard_Integer seconde,
        const Standard_Integer mode)
{
//  0 : IGES annee a l ancienne 00-99    -1 IGES annee complete    1 lisible
  char madate[60];
  Standard_Integer moi  = mois  , jou   = jour   , anne   = annee;
  Standard_Integer heur = heure , minut = minute , second = seconde;
  if (annee == 0) {
    Standard_Integer millisec,microsec;
    OSD_Process system;
    Quantity_Date ladate = system.SystemDate();
    ladate.Values (moi,jou,anne,heur,minut,second,millisec,microsec);
  }
  if (mode == 0 || mode == -1) {
    Standard_Integer an = anne % 100;
    Standard_Boolean dizaine = (an >= 10);
    if (!dizaine) an += 10;
    if (mode < 0) { an = anne; dizaine = Standard_True; }
    Standard_Integer date1 = (an)         * 10000 + moi   * 100 + jou;
    Standard_Integer date2 = (heur + 100) * 10000 + minut * 100 + second;
    sprintf (madate,"%d%d",date1,date2);
    madate[(mode == 0 ? 6: 8)] = '.';
    if (!dizaine) madate[0] = '0';
  } else if (mode == 1) {
    sprintf (madate,"%4.4d-%2.2d-%2.2d:%2.2d-%2.2d-%2.2d",
	     anne,moi,jou,heur,minut,second);
  }
  return new TCollection_HAsciiString(madate);
}


//=======================================================================
//function : NewDateString
//purpose  : 
//=======================================================================

Handle(TCollection_HAsciiString) IGESData_GlobalSection::NewDateString
       (const Handle(TCollection_HAsciiString)& date, const Standard_Integer mode)
{
  Standard_Integer anne,moi,jou,heur,minut,second;
  if (date.IsNull()) return date;
  Standard_Integer i0 = 0;
  if (date->Length() == 15) i0 = 2;
  else if (date->Length() != 13) return date;
  if (date->Value(i0+7) != '.') return date;
  anne   = (date->Value(i0+ 1) - 48) * 10 + (date->Value(i0+ 2) - 48);
  if (i0 == 0) {
    anne = anne + 1900;
    if (anne < 1980) anne += 100;
  } else {
    anne = anne + (date->Value(1) - 48) *1000 + (date->Value(2) - 48) * 100;
  }
  moi    = (date->Value(i0+ 3) - 48) * 10 + (date->Value(i0+ 4) - 48);
  jou    = (date->Value(i0+ 5) - 48) * 10 + (date->Value(i0+ 6) - 48);
  heur   = (date->Value(i0+ 8) - 48) * 10 + (date->Value(i0+ 9) - 48);
  minut  = (date->Value(i0+10) - 48) * 10 + (date->Value(i0+11) - 48);
  second = (date->Value(i0+12) - 48) * 10 + (date->Value(i0+13) - 48);

  return IGESData_GlobalSection::NewDateString (anne,moi,jou,heur,minut,second,mode);
}


//=======================================================================
//function : UnitValue
//purpose  : 
//=======================================================================

Standard_Real IGESData_GlobalSection::UnitValue () const
{
  return UnitsMethods::GetLengthFactorValue ( theUnitFlag ) /
         UnitsMethods::GetCasCadeLengthUnit(); //abv 22 Feb 00: adding cascade unit factor
}


// ###############           UPDATES           ###############

    void  IGESData_GlobalSection::SetSeparator   (const Standard_Character val)
      {  theSeparator = val;  }

    void  IGESData_GlobalSection::SetEndMark     (const Standard_Character val)
      {  theEndMark = val;  }

    void  IGESData_GlobalSection::SetSendName (const Handle(TCollection_HAsciiString)& val)
      {  theSendName = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetFileName (const Handle(TCollection_HAsciiString)& val)
      {  theFileName = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetSystemId    (const Handle(TCollection_HAsciiString)& val)
      {  theSystemId = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetInterfaceVersion (const Handle(TCollection_HAsciiString)& val)
      {  theInterfaceVersion = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetIntegerBits (const Standard_Integer val)
      {  theIntegerBits = val;  }

    void  IGESData_GlobalSection::SetMaxPower10Single (const Standard_Integer val)
      {  theMaxPower10Single = val;  }

    void  IGESData_GlobalSection::SetMaxDigitsSingle (const Standard_Integer val)
      {  theMaxDigitsSingle = val;  }

    void  IGESData_GlobalSection::SetMaxPower10Double (const Standard_Integer val)
      {  theMaxPower10Double = val;  }

    void  IGESData_GlobalSection::SetMaxDigitsDouble (const Standard_Integer val)
      {  theMaxDigitsDouble = val;  }

    void  IGESData_GlobalSection::SetReceiveName (const Handle(TCollection_HAsciiString)& val)
      {  theReceiveName = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetScale       (const Standard_Real val)
      {  theScale = val;  }

    void  IGESData_GlobalSection::SetUnitFlag    (const Standard_Integer val)
      {  theUnitFlag = val;  }

    void  IGESData_GlobalSection::SetUnitName (const Handle(TCollection_HAsciiString)& val)
      {  theUnitName = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetLineWeightGrad (const Standard_Integer val)
      {  theLineWeightGrad = val;  }

    void  IGESData_GlobalSection::SetMaxLineWeight (const Standard_Real val)
      {  theMaxLineWeight = val;  }

    void  IGESData_GlobalSection::SetDate (const Handle(TCollection_HAsciiString)& val)
      {  theDate = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetResolution  (const Standard_Real val)
      {  theResolution = val;  }

    void  IGESData_GlobalSection::SetMaxCoord    (const Standard_Real val)
{
  hasMaxCoord = (val > 0.);
  theMaxCoord = (hasMaxCoord ? val : 0.);
}

    void  IGESData_GlobalSection::MaxMaxCoord    (const Standard_Real val)
{
  Standard_Real aval = Abs(val);
  if (hasMaxCoord)  {  if (aval > theMaxCoord) theMaxCoord = aval;  }
  else SetMaxCoord (aval);
}

    void  IGESData_GlobalSection::MaxMaxCoords   (const gp_XYZ& xyz)
{  MaxMaxCoord (xyz.X());  MaxMaxCoord (xyz.Y());  MaxMaxCoord (xyz.Z());  }


    void  IGESData_GlobalSection::SetAuthorName (const Handle(TCollection_HAsciiString)& val)
      {  theAuthorName = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetCompanyName (const Handle(TCollection_HAsciiString)& val)
      {  theCompanyName = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetIGESVersion (const Standard_Integer val)
      {  theIGESVersion = val;  }

    void  IGESData_GlobalSection::SetDraftingStandard (const Standard_Integer val)
      {  theDraftingStandard = val;  }

    void  IGESData_GlobalSection::SetLastChangeDate (const Handle(TCollection_HAsciiString)& val)
      {  theLastChangeDate = TranslatedFromHollerith(val);  }

    void  IGESData_GlobalSection::SetApplicationProtocol (const Handle(TCollection_HAsciiString)& val)
      {  theAppliProtocol = TranslatedFromHollerith(val);  }