summaryrefslogtreecommitdiff
path: root/src/XSDRAWIGES/XSDRAWIGES.cxx
blob: 1a547c804ef3b2a24a455e7973bd721ae18ea881 (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
//gka 06.01.99 S3767 new function TPSTAT (first version)
//pdn 11.01.99 putting "return" statement for compilation on NT
#include <XSDRAWIGES.ixx>

#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Interface_Static.hxx>

#include <IGESControl_Writer.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESData_BasicEditor.hxx>

#include <IGESData.hxx>
#include <IGESData_Protocol.hxx>
// #include <IGESData_IGESWriter.hxx>
#include <IGESData_IGESEntity.hxx>         // pour igeslist
#include <IGESData_IGESModel.hxx>

#include <Interface_Check.hxx>
#include <Interface_CheckTool.hxx>
#include <Interface_CheckIterator.hxx>

#include <stdio.h>
#include <TCollection_HAsciiString.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_HSequenceOfTransient.hxx>

#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>

#include <IGESToBRep.hxx>
#include <IGESToBRep_Actor.hxx>
#include <IGESToBRep_Reader.hxx>

#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>

#include <Interface_Macros.hxx>
#include <Message_Messenger.hxx>

#include <Draw_Appli.hxx>
#include <Draw_Printer.hxx>
#include <DrawTrSurf.hxx>
#include <DBRep.hxx>
//#include <GeometryTest.hxx>  essai CKY 4-AUT-1998
//#include <BRepTest.hxx>      essai CKY 4-AUT-1998
//#include <MeshTest.hxx>      essai CKY 4-AUT-1998

// Init functions

#include <IGESSelect_Activator.hxx>
#include <XSDRAW.hxx>
#include <XSDRAW_Commands.hxx>
#include <Transfer_TransientProcess.hxx>
#include <Transfer_TransferOutput.hxx>
#include <Transfer_FinderProcess.hxx>
#include <XSControl_WorkSession.hxx>

// + tplosttrim
#include <IFSelect_SessionPilot.hxx>
#include <XSControl.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <IFSelect_Functions.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#include <IGESControl_Reader.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <TopExp_Explorer.hxx>
#include <Message_ProgressSentry.hxx>

//--------------------------------------------------------------
// Function : igesbrep
//
//--------------------------------------------------------------

static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char** argv) 
{
  DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
  if (ctl.IsNull()) XSDRAW::SetNorm("IGES");

  // Progress indicator
  Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
  progress->SetScale ( 0, 100, 1 );
  progress->Show();
 
  IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
  if (ctl.IsNull())
    ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());

  TCollection_AsciiString fnom,rnom;

  Standard_Boolean modfic = XSDRAW::FileAndVar
    (argv[1],argv[2],"IGESBREP",fnom,rnom);
  if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
  else        di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
  di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
  IFSelect_ReturnStatus readstat = IFSelect_RetVoid;

#ifdef CHRONOMESURE
  OSD_Timer Chr; Chr.Reset();
  IDT_SetLevel(3);
#endif


// Reading the file
  progress->NewScope ( 20, "Loading" ); // On average loading takes 20% 
  progress->Show();

  if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
  else  if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;

  progress->EndScope();
  progress->Show();

  if (readstat != IFSelect_RetDone) {
    if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
    else di<<"No model loaded"<<"\n";
    return 1;
  }
// Choice of treatment
  Standard_Boolean fromtcl = (argc > 3);
  Standard_Integer modepri = 1, nent, nbs;
  if (fromtcl) modepri = 4;

  while (modepri) {
    //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka 
    //mode OnlyVisible does not work.
    // nent = Reader.NbRootsForTransfer();
    if (!fromtcl) {
      cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
      modepri = -1;
      
// amv 26.09.2003 : this is used to avoid error of enter's simbol        
      char str[80];                                                             
      cin>>str;                                                                 
      modepri = atoi(str);   
    }

    if (modepri == 0) {  //fin
      di << "Bye and good luck! " << "\n";
      break;
    } 

    else if (modepri <= 2) {  // 1 : Visible Roots, 2 : All Roots
      di << "All Geometry Transfer"<<"\n";
      di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
      di<<"  To modify : command  param read.iges.bspline.continuity"<<"\n";
      Handle(XSControl_WorkSession) thesession = Reader.WS();
      thesession->ClearContext();
      XSDRAW::SetTransferProcess (thesession->MapReader());
      progress->NewScope ( 80, "Translation" );
      progress->Show();
      thesession->MapReader()->SetProgress ( progress );
      
      if (modepri == 1) Reader.SetReadVisible (Standard_True);
      Reader.TransferRoots();
      
      thesession->MapReader()->SetProgress ( 0 );
      progress->EndScope();
      progress->Show();
      // result in only one shape for all the roots
      //        or in one shape for one root.
      di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
      Standard_Integer answer = 1;
      if (Reader.NbShapes() > 1) {
	cout << " pass(0)  one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << flush;
        answer = -1;
        //amv 26.09.2003                                                        
        char str_a[80];                                                         
        cin >> str_a;                                                           
        answer = atoi(str_a);    
      }
      if ( answer == 0) continue;
      if ( answer == 1 || answer == 3) {
	TopoDS_Shape shape = Reader.OneShape();
	// save the shape
	if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
	char fname[110];
	sprintf(fname, "%s", rnom.ToCString());
	di << "Saving shape in variable Draw : " << fname << "\n";
	if (answer == 3) IGESToBRep::WriteShape (shape,1);
	try {
	  OCC_CATCH_SIGNALS
	  DBRep::Set(fname,shape);
	}
	catch(Standard_Failure) {
	  di << "** Exception : ";
	  di << Standard_Failure::Caught()->GetMessageString();
	  di<<" ** Skip"<<"\n";
	  di << "Saving shape in variable Draw : " << fname << "\n";
	  IGESToBRep::WriteShape (shape,1);
	}
      }
	
      else if (answer == 2 || answer == 4) {
	Standard_Integer numshape = Reader.NbShapes();
	for (Standard_Integer inum = 1; inum <= numshape; inum++) {
	  // save all the shapes
	  TopoDS_Shape shape = Reader.Shape(inum);
	  if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
	  char fname[110];
	  sprintf(fname, "%s_%d", rnom.ToCString(),inum);
	  di << "Saving shape in variable Draw : " << fname << "\n";
	  if (answer == 4) IGESToBRep::WriteShape (shape,inum);
	  try {
	    OCC_CATCH_SIGNALS
	    DBRep::Set(fname,shape);
	  }
	  catch(Standard_Failure) {
	    di << "** Exception : ";
	    di << Standard_Failure::Caught()->GetMessageString();
	    di<<" ** Skip"<<"\n";
	  }
	}
      }
      else return 0;
    }

    else if (modepri == 3) {  // One Entity
      cout << "Only One Entity"<<endl;
      cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
      cout<<"  To modify : command  param read.iges.bspline.continuity"<<endl;
      cout << " give the number of the Entity : " << flush;
      nent = XSDRAW::GetEntityNumber();

      if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
      else {
	nbs = Reader.NbShapes();
	char shname[30];  sprintf (shname,"%s_%d",rnom.ToCString(),nent);
	di<<"Transfer entity n0 "<<nent<<" OK  -> DRAW Shape: "<<shname<<"\n";
	di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
	TopoDS_Shape sh = Reader.Shape(nbs);
	DBRep::Set (shname,sh);
      }
    }

    else if (modepri == 4) {   // Selection
      Standard_Integer answer = 1;
      Handle(TColStd_HSequenceOfTransient)  list;

//  Selection, nommee ou via tcl. tcl : raccourcis admis
//   * donne iges-visible + xst-transferrable-roots
//   *r donne xst-model-roots (TOUTES racines)

      if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {         
        di << "All Geometry Transfer"<<"\n";
        di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
        di<<"  To modify : command  param read.iges.bspline.continuity"<<"\n";
        Handle(XSControl_WorkSession) thesession = Reader.WS();
        thesession->ClearContext();
        XSDRAW::SetTransferProcess (thesession->MapReader());
        progress->NewScope ( 80, "Translation" );
        progress->Show();
        thesession->MapReader()->SetProgress ( progress );
      
        Reader.SetReadVisible (Standard_True);
        Reader.TransferRoots();
      
        thesession->MapReader()->SetProgress ( 0 );
        progress->EndScope();
        progress->Show();
        
        // result in only one shape for all the roots
        TopoDS_Shape shape = Reader.OneShape();
        // save the shape
        char fname[110];
        sprintf(fname, "%s", rnom.ToCString());
        di << "Saving shape in variable Draw : " << fname << "\n";
        try {
          OCC_CATCH_SIGNALS
          DBRep::Set(fname,shape);
        }
        catch(Standard_Failure) {
          di << "** Exception : ";
	  di << Standard_Failure::Caught()->GetMessageString();
	  di<<" ** Skip"<<"\n";
          di << "Saving shape in variable Draw : " << fname << "\n";
          IGESToBRep::WriteShape (shape,1);
        }                                                                             
        return 0;
      }
   
      if(fromtcl) {
	modepri = 0;    // d office, une seule passe
	if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
	  di<<"All Roots : ";
	  list = XSDRAW::GetList ("xst-model-roots");
	}
        else {
	  TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
	  di<<"List given by "<<compart.ToCString()<<" : ";
	  list = XSDRAW::GetList (compart.ToCString());
	}
	if (list.IsNull()) {
          di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
          continue;
        }
      }
      else {
	cout<<"Name of Selection :"<<flush;
	list = XSDRAW::GetList();
	if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
      }

      Standard_Integer nbl = list->Length();
      di<<"Nb entities selected : "<<nbl<<"\n";
      if (nbl == 0) continue;
      while (answer) {
	if (!fromtcl) {
	  cout<<"Choice: 0 abandon  1 transfer all  2 with confirmation  3 list n0s ents :"<<flush;
          answer = -1;
          // anv 26.09.2003                                                     
          char str_answer[80];                                                  
          cin>>str_answer;                                                      
          answer = atoi(str_answer);    
	}
	if (answer <= 0 || answer > 3) continue;
	if (answer == 3) {
	  for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
	    Handle(Standard_Transient) ent = list->Value(ill);
	    di<<"  ";// model->Print(ent,di);
	  }
	  di<<"\n";
	}
	if (answer == 1 || answer == 2) {
	  Standard_Integer nbt = 0;
	  Handle(XSControl_WorkSession) thesession = Reader.WS();
	
	  XSDRAW::SetTransferProcess (thesession->MapReader());
          progress->NewScope ( 80, "Translation" );
          progress->Show();
          thesession->MapReader()->SetProgress ( progress );

          Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
	  for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
	  
	    nent = Reader.Model()->Number(list->Value(ill));
	    if (nent == 0) continue;
	    if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
	    else {
	      nbs = Reader.NbShapes();
	      char shname[30];  sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
	      di<<"Transfer entity n0 "<<nent<<" OK  -> DRAW Shape: "<<shname<<"\n";
	      di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
	      TopoDS_Shape sh = Reader.Shape(nbs);
	      DBRep::Set (shname,sh);
              nbt++;
	    }
	  }
	  thesession->MapReader()->SetProgress ( 0 );
          progress->EndScope();
          progress->Show();
	  di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
	  answer = 0;  // on ne reboucle pas
	}
      }
    }
    else di<<"Unknown mode n0 "<<modepri<<"\n";
  }
  return 0;
}

//--------------------------------------------------------------
// Function : testreadiges
//
//--------------------------------------------------------------
static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv) 
{
  if (argc != 3)                                                                                      
    {                                                                                             
      di << "ERROR in " << argv[0] << "Wrong Number of Arguments."<<"\n";                     
      di << " Usage : " << argv[0] <<" file_name shape_name"<< "\n";                          
      return 1;                                                                                 
    }  
  IGESControl_Reader Reader;
  Standard_CString filename = argv[1];
  IFSelect_ReturnStatus readstat =  Reader.ReadFile(filename);
  di<<"Status from reading IGES file "<<filename<<" : ";  
  switch(readstat) {                                                              
    case IFSelect_RetVoid  : { di<<"empty file"<<"\n"; return 1; }            
    case IFSelect_RetDone  : { di<<"file read"<<"\n";    break; }             
    case IFSelect_RetError : { di<<"file not found"<<"\n";   return 1; }      
    case IFSelect_RetFail  : { di<<"error during read"<<"\n";  return 1; }    
    default  :  { di<<"failure"<<"\n";   return 1; }                          
  }       
  Reader.TransferRoots();
  TopoDS_Shape shape = Reader.OneShape();
  DBRep::Set(argv[2],shape); 
  di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
  return 0;  
}
 
//--------------------------------------------------------------
// Function : brepiges
//
//--------------------------------------------------------------

static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, const char** a) 
{
  XSDRAW::SetNorm ("IGES");
  // ecriture dans le model d'une entite :
  //    -  model_AddEntity(ent)             : ecriture de l`entite seule
  //    -  model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement 
  //                                          . de sa matrice de transformation 
  //                                          . de ses sous-elements

  IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
			  Interface_Static::IVal("write.iges.brep.mode"));
  di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
  di<<"mode  write  : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
  di<<"  To modifiy : command  param"<<"\n";

//  Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
//   c a d tant qu il y a des + on ajoute ce qui suit
  const char* ficnom = NULL;
  Standard_Integer npris = 0;

  Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
  progress->NewScope(90,"Translating");
  progress->Show();
  ICW.TransferProcess()->SetProgress(progress);

  for ( Standard_Integer i = 1; i < n; i++) {
    const char* nomvar = a[i];
    if (a[i][0] == '+') nomvar = &(a[i])[1];
    else if (i > 1)  {  ficnom = a[i];  break;  }
    TopoDS_Shape Shape = DBRep::Get(nomvar);
    if      (ICW.AddShape (Shape)) npris ++;
    else if (ICW.AddGeom (DrawTrSurf::GetCurve   (nomvar)) ) npris ++;
    else if (ICW.AddGeom (DrawTrSurf::GetSurface (nomvar)) ) npris ++;
  }
  ICW.ComputeModel();
  XSDRAW::SetModel(ICW.Model());
  XSDRAW::SetTransferProcess (ICW.TransferProcess());
    
  ICW.TransferProcess()->SetProgress(0);
  progress->EndScope();
  progress->Show();
  progress->NewScope(10,"Writing");
  progress->Show();

  di<<npris<<" Shapes written, giving "<<XSDRAW::Model()->NbEntities()<<" Entities"<<"\n";
  di<<" Now, to write a file, command : writeall filename"<<"\n";

  // creation du fichier de sortie

  char nomfic[100] ;
  Standard_Integer modepri = 0;
  if (ficnom) {
    modepri = 2;
    strcpy (nomfic,ficnom);
  }

  if (!modepri) {
    cout<<" Mode (0 End, 1 ->screen, 2 file) :"<<flush;
    modepri = -1;
    cin >> modepri; di << "Output mode " << modepri << "\n";
  }

  if (modepri == 0) return 0;
  // Ecran
  else if (modepri == 1) {
    di << " Screen Output" << "\n";
    //ICW.Write (cout);
    Standard_SStream aSStream;
    ICW.Write (aSStream);
    di << aSStream;
  }

  //  ....                      WRITE (Fichier)                        ....
  else if (modepri == 2) {
    if (!ficnom)  { cout << " Output file name :" << flush;  cin  >> nomfic; }
    di << " Output on file : " << nomfic << "\n";
    if (ICW.Write(nomfic)) di<<" Write OK"<<"\n";
    else                   di<<" Write KO"<<"\n";
  }

  progress->EndScope();
  progress->Show();

  return 0;
}

//--------------------------------------------------------------
// Function : testwriteiges
//
//--------------------------------------------------------------

static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, const char** a) 
{
  if (n != 3)                                                                                      
    {                                                                                             
      di << "ERROR in " << a[0] << "Wrong Number of Arguments."<<"\n";                     
      di << " Usage : " << a[0] <<" file_name shape_name"<< "\n";                          
      return 1;                                                                                 
    }
  IGESControl_Writer Writer;
  Standard_CString filename = a[1];
  TopoDS_Shape shape = DBRep::Get(a[2]); 
  Standard_Boolean ok = Writer.AddShape(shape);
  if(!ok){
    di<<"Shape not add"<<"\n";
    return 1;
  }
  
  if(!(Writer.Write(filename))){
    di<<"Error on writing file"<<"\n";
    return 1;
  }
  di<<"File Is Written"<<"\n"; 
  return 0;
}
//--------------------------------------------------------------
// Function : igesparam
//
//--------------------------------------------------------------


static Standard_Integer igesparam (Draw_Interpretor& di, Standard_Integer , const char** ) 
{
//  liste des parametres
  di<<"List of parameters which control IGES :"<<"\n";
  di<<"  unit : write.iges.unit\n  mode write : write.iges.brep.mode\n  spline_continuity (read) : read.iges.bspline.continuity\nSee definition by  defparam, read/edit value by  param"<<"\n";
  di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
  di<<"mode  write  : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
  di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
  di<<"\n"<<" To modifier, param nom_param new_val"<<"\n";
  return 0;
}


//--------------------------------------------------------------
// Function : tplosttrim
//
//--------------------------------------------------------------

static Standard_Integer XSDRAWIGES_tplosttrim (Draw_Interpretor& di, Standard_Integer n, const char** a) 
{
  Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();

//  Standard_Integer narg = pilot->NbWords();
  Standard_Integer narg = n;

  Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
  TColStd_Array1OfAsciiString strarg(1, 3);
  TColStd_Array1OfAsciiString typarg(1, 3);
  strarg.SetValue(1,"xst-type(CurveOnSurface)");
  strarg.SetValue(2,"xst-type(Boundary)");
  strarg.SetValue(3,"xst-type(Loop)");
  typarg.SetValue(1,"IGESGeom_TrimmedSurface");
  typarg.SetValue(2,"IGESGeom_BoundedSurface");
  typarg.SetValue(3,"IGESSolid_Face");
  if (TP.IsNull()) { di<<"No Transfer Read"<<"\n"; return 1; }
  Standard_Integer nbFaces = 0, totFaces = 0 ;
  Handle(IFSelect_WorkSession) WS = pilot->Session(); 
  Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult(); 
  Standard_Integer k=0;
  if(narg > 1) {
//    TCollection_AsciiString Arg = pilot->Word(1);
    TCollection_AsciiString Arg(a[1]);
    for(k=1 ; k<=3;k++ ) {
      if(typarg.Value(k).Location(Arg,1,typarg.Value(k).Length()) != 0) break;
    }
  }   
  if( k == 4) {di<< "Invalid argument"<<"\n"; return 0; }
  for(Standard_Integer j = 1 ; j <= 3; j++) {
    TColStd_MapOfTransient aMap;
    if(narg == 1) k=j;
    Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(),strarg.Value(k).ToCString());
    if (!list.IsNull()) itrp.Filter (list);
    else {
      di << "No untrimmed faces" << "\n";
      return 0;
    }
    for (itrp.Start(); itrp.More(); itrp.Next()) {
      Handle(Standard_Transient) ent = itrp.Starting();
      Handle(TColStd_HSequenceOfTransient) super = WS->Sharings (ent);
      if (!super.IsNull()) {
	Standard_Integer nb = super->Length();
	if (nb > 0) {
	    for (Standard_Integer i = 1; i <= nb; i++)
	      if (super->Value(i)->IsKind (typarg.Value(k).ToCString())) {
		if(aMap.Add(super->Value(i))) nbFaces++;
	      }
	}
      }
    }
    if(nbFaces != 0) {
      if( j == 1 ) di << "Number of untrimmed faces: " << "\n";
      switch(k){
      case 1:  
	di << "Trimmed Surface: " << "\n"; break;
      case 2:
	di << "Bounded Surface: " << "\n"; break;
      case 3:
	di << "Face: " << "\n"; break;
      }
      Handle(Message_Messenger) aDIMessenger = 
	new Message_Messenger (new Draw_Printer(di));
      TColStd_MapIteratorOfMapOfTransient itmap;
      for(itmap.Initialize(aMap); itmap.More(); itmap.Next()) {
	//XSDRAW::Model()->Print(itmap.Key(),cout);
	Standard_SStream aSStream;
	XSDRAW::Model()->Print(itmap.Key(),aDIMessenger);
	di << aSStream;
	di<<"  ";
      }
      di << "\n";
      di << "\n" << "Number:"<< nbFaces << "\n";
      totFaces += nbFaces;
    }
    if(narg > 1) break;
    nbFaces = 0;
  }
  
  if(totFaces == 0) di << "No untrimmed faces" << "\n";
  else              di << "Total number :" << totFaces << "\n";
  return 0;
}
//-------------------------------------------------------------------
//--------------------------------------------------------------
// Function : TPSTAT
//
//--------------------------------------------------------------
static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer n, const char** a)
{
  Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
  Standard_Integer argc = n;//= pilot->NbWords();
  const Standard_CString arg1 = a[1];//pilot->Arg(1);
  //IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
  Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
   IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
  //read.SetTransientProcess(TP);
//        ****    tpent        ****
//  if (TP.IsNull()) { di<<"No Transfer Read"<<"\n"; return IFSelect_RetError;}
  Handle(Interface_InterfaceModel) model = TP->Model();
  //Handle(Interface_InterfaceModel) model = read.Model();
  if (model.IsNull()) {di<<"No Transfer Read"<<"\n"; return -1;}
 //DeclareAndCast(IGESData_IGESModel,modelig,model);
 // read.SetModel(modelig);
  Handle(XSControl_WorkSession) thesession = read.WS();
  thesession->SetMapReader(TP);
  //read.SetModel(model);
  Standard_Integer mod1 = 0;
  if (argc > 1) {
    char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
    switch (arg1[0]) {
    case 'g' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_GeneralInfo);break;
    case 'c' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_CountByItem); break;
    case 'C' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ListByItem); break;
    case 'r' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ResultCount);break;
    case 's' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_Mapping);break;
    case '?' : mod1 = -1; break;
    default  : mod1 = -2; break;
    }
  }
  if (mod1 < -1) di<<"Unknown Mode"<<"\n";
  if (mod1 < 0) {
    di<<"Modes available :\n"
      <<"g : general    c : checks (count)  C (list)"<<"\n"
      <<"r : number of CasCade resulting shapes"<<"\n"
      <<"s : mapping between IGES entities and CasCade shapes"<<"\n";
    if (mod1 < -1) return -1;
    return 0;
  }
  return 0;
}

static Standard_Integer etest(Draw_Interpretor& di, Standard_Integer argc, const char** a)
{
  if(argc < 3) {
    di<<"etest igesfile shape"<<"\n";
    return 0;
  }
  IGESControl_Reader aReader;
  aReader.ReadFile(a[1]);
  aReader.SetReadVisible(Standard_True);
  aReader.TransferRoots();
  TopoDS_Shape shape = aReader.OneShape();
  DBRep::Set(a[2],shape);
  return 0;
}

extern "C" {
static void cleanpilot ()
{
  XSDRAW::Session()->ClearData(1);
}
}


//--------------------------------------------------------------
// Function : Init(s)
//
//--------------------------------------------------------------

void  XSDRAWIGES::InitSelect ()
{
  Handle(IGESSelect_Activator)    igesact = new IGESSelect_Activator;
  IGESControl_Controller::Init();
//  XSDRAW::SetNorm ("IGES");  trop tot
  XSDRAW::SetController (XSControl_Controller::Recorded("iges"));
  
  atexit (cleanpilot);
}


//=======================================================================
//function : InitToBRep
//purpose  : 
//=======================================================================

void  XSDRAWIGES::InitToBRep (Draw_Interpretor& theCommands)
{
  const char* g = "DE: IGES";
  theCommands.Add("igesbrep",     "igesbrep [file else already loaded model] [name DRAW]",     __FILE__, igesbrep,              g);
  theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread,              g);
  theCommands.Add("igesread",     "igesread [file else already loaded model] [name DRAW]",     __FILE__, igesbrep,              g);
  theCommands.Add("igesparam",    "igesparam ->list, + name ->one param, + name val->change",  __FILE__, igesparam,             g);
  theCommands.Add("TPSTAT",       " ",                                                         __FILE__, XSDRAWIGES_TPSTAT,     g);
  theCommands.Add("tplosttrim",   "number of untrimmed faces during last transfer",            __FILE__, XSDRAWIGES_tplosttrim, g);
  theCommands.Add("etest",        "test of eviewer",                                           __FILE__, etest,                 g);

}


//=======================================================================
//function : InitFromBRep
//purpose  : 
//=======================================================================

void  XSDRAWIGES::InitFromBRep (Draw_Interpretor& theCommands)
{
  const char* g = "DE: IGES";
  theCommands.Add("brepiges",      "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges,  g);
  theCommands.Add("testwriteiges", "testwriteiges filename.igs shape",           __FILE__, testwrite, g);
}