1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 //gka 06.01.99 S3767 new function TPSTAT (first version)
15 //pdn 11.01.99 putting "return" statement for compilation on NT
17 #include <BRepTools.hxx>
19 #include <Draw_Appli.hxx>
20 #include <Draw_ProgressIndicator.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <Geom_Curve.hxx>
23 #include <Geom_Surface.hxx>
24 #include <IFSelect_Functions.hxx>
25 #include <IFSelect_SessionPilot.hxx>
26 #include <IGESControl_Controller.hxx>
27 #include <IGESControl_Reader.hxx>
28 #include <IGESControl_Writer.hxx>
29 #include <IGESData.hxx>
30 #include <IGESData_BasicEditor.hxx>
31 #include <IGESData_IGESEntity.hxx>
32 #include <IGESData_IGESModel.hxx>
33 #include <IGESData_Protocol.hxx>
34 #include <IGESSelect_Activator.hxx>
35 #include <IGESToBRep.hxx>
36 #include <IGESToBRep_Actor.hxx>
37 #include <IGESToBRep_Reader.hxx>
38 #include <Interface_Check.hxx>
39 #include <Interface_CheckIterator.hxx>
40 #include <Interface_CheckTool.hxx>
41 #include <Interface_InterfaceModel.hxx>
42 #include <Interface_Macros.hxx>
43 #include <Interface_Static.hxx>
44 #include <Message.hxx>
45 #include <Message_Messenger.hxx>
46 #include <Message_ProgressSentry.hxx>
47 #include <Standard_ErrorHandler.hxx>
48 #include <Standard_Failure.hxx>
49 #include <TCollection_AsciiString.hxx>
50 #include <TCollection_HAsciiString.hxx>
51 #include <TColStd_HSequenceOfTransient.hxx>
52 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
53 #include <TColStd_MapOfTransient.hxx>
54 #include <TopExp_Explorer.hxx>
56 #include <TopoDS_Shape.hxx>
57 #include <Transfer_FinderProcess.hxx>
58 #include <Transfer_IteratorOfProcessForTransient.hxx>
59 #include <Transfer_TransferOutput.hxx>
60 #include <Transfer_TransientProcess.hxx>
61 #include <XSControl.hxx>
62 #include <XSControl_WorkSession.hxx>
63 #include <XSControl_TransferReader.hxx>
65 #include <XSDRAWIGES.hxx>
71 //=======================================================================
72 //function : WriteShape
73 //purpose : Creates a file Shape_'number'
74 //=======================================================================
75 void WriteShape(const TopoDS_Shape& shape, const Standard_Integer number)
78 sprintf(fname, "Shape_%d",number);
79 std::ofstream f(fname,std::ios::out);
80 std::cout << "Output file name : " << fname << std::endl;
81 f << "DBRep_DrawableShape\n";
83 BRepTools::Write(shape, f);
87 TCollection_AsciiString XSDRAW_CommandPart
88 (Standard_Integer argc, const char** argv, const Standard_Integer argf)
90 TCollection_AsciiString res;
91 for (Standard_Integer i = argf; i < argc; i ++) {
92 if (i > argf) res.AssignCat(" ");
93 res.AssignCat (argv[i]);
99 //--------------------------------------------------------------
100 // Function : igesbrep
101 //--------------------------------------------------------------
102 static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
104 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
105 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
107 // Progress indicator
108 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
109 progress->SetScale ( 0, 100, 1 );
112 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
113 Standard_Boolean aFullMode = Standard_True;
114 Reader.WS()->SetModeStat(aFullMode);
116 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
118 TCollection_AsciiString fnom,rnom;
120 Standard_Boolean modfic = XSDRAW::FileAndVar
121 (argv[1],argv[2],"IGESBREP",fnom,rnom);
122 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
123 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
124 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
125 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
128 OSD_Timer Chr; Chr.Reset();
134 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
137 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
138 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
140 progress->EndScope();
143 if (readstat != IFSelect_RetDone) {
144 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon\n";
145 else di<<"No model loaded\n";
148 // Choice of treatment
149 Standard_Boolean fromtcl = (argc > 3);
150 Standard_Integer modepri = 1, nent, nbs;
151 if (fromtcl) modepri = 4;
154 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
155 //mode OnlyVisible does not work.
156 // nent = Reader.NbRootsForTransfer();
158 std::cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<std::flush;
161 // amv 26.09.2003 : this is used to avoid error of enter's simbol
164 modepri = Draw::Atoi(str);
167 if (modepri == 0) { //fin
168 di << "Bye and good luck! \n";
172 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
173 di << "All Geometry Transfer\n";
174 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
175 di<<" To modify : command param read.iges.bspline.continuity\n";
176 Handle(XSControl_WorkSession) thesession = Reader.WS();
177 thesession->ClearContext();
178 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
179 progress->NewScope ( 80, "Translation" );
181 thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
183 if (modepri == 1) Reader.SetReadVisible (Standard_True);
184 Reader.TransferRoots();
186 thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
187 progress->EndScope();
189 // result in only one shape for all the roots
190 // or in one shape for one root.
191 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
192 Standard_Integer answer = 1;
193 if (Reader.NbShapes() > 1) {
194 std::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) : " << std::flush;
199 answer = Draw::Atoi(str_a);
201 if ( answer == 0) continue;
202 if ( answer == 1 || answer == 3) {
203 TopoDS_Shape shape = Reader.OneShape();
205 if (shape.IsNull()) { di<<"No Shape produced\n"; continue; }
207 Sprintf(fname, "%s", rnom.ToCString());
208 di << "Saving shape in variable Draw : " << fname << "\n";
209 if (answer == 3) WriteShape (shape,1);
212 DBRep::Set(fname,shape);
214 catch(Standard_Failure const& anException) {
215 di << "** Exception : ";
216 di << anException.GetMessageString();
218 di << "Saving shape in variable Draw : " << fname << "\n";
219 WriteShape (shape,1);
223 else if (answer == 2 || answer == 4) {
224 Standard_Integer numshape = Reader.NbShapes();
225 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
226 // save all the shapes
227 TopoDS_Shape shape = Reader.Shape(inum);
228 if (shape.IsNull()) { di<<"No Shape produced\n"; continue; }
230 Sprintf(fname, "%s_%d", rnom.ToCString(),inum);
231 di << "Saving shape in variable Draw : " << fname << "\n";
232 if (answer == 4) WriteShape (shape,inum);
235 DBRep::Set(fname,shape);
237 catch(Standard_Failure const& anException) {
238 di << "** Exception : ";
239 di << anException.GetMessageString();
247 else if (modepri == 3) { // One Entity
248 std::cout << "Only One Entity"<<std::endl;
249 std::cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<std::endl;
250 std::cout<<" To modify : command param read.iges.bspline.continuity"<<std::endl;
251 std::cout << " give the number of the Entity : " << std::flush;
252 nent = XSDRAW::GetEntityNumber();
254 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result\n";
256 nbs = Reader.NbShapes();
257 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nent);
258 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
259 di<<"Now, "<<nbs<<" Shapes produced\n";
260 TopoDS_Shape sh = Reader.Shape(nbs);
261 DBRep::Set (shname,sh);
265 else if (modepri == 4) { // Selection
266 Standard_Integer answer = 1;
267 Handle(TColStd_HSequenceOfTransient) list;
269 // Selection, nommee ou via tcl. tcl : raccourcis admis
270 // * donne iges-visible + xst-transferrable-roots
271 // *r donne xst-model-roots (TOUTES racines)
273 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
274 di << "All Geometry Transfer\n";
275 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
276 di<<" To modify : command param read.iges.bspline.continuity\n";
277 Handle(XSControl_WorkSession) thesession = Reader.WS();
278 thesession->ClearContext();
279 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
280 progress->NewScope ( 80, "Translation" );
282 thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
284 Reader.SetReadVisible (Standard_True);
285 Reader.TransferRoots();
287 thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
288 progress->EndScope();
291 // result in only one shape for all the roots
292 TopoDS_Shape shape = Reader.OneShape();
295 Sprintf(fname, "%s", rnom.ToCString());
296 di << "Saving shape in variable Draw : " << fname << "\n";
299 DBRep::Set(fname,shape);
301 catch(Standard_Failure const& anException) {
302 di << "** Exception : ";
303 di << anException.GetMessageString();
305 di << "Saving shape in variable Draw : " << fname << "\n";
306 WriteShape (shape,1);
312 modepri = 0; // d office, une seule passe
313 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
315 list = XSDRAW::GetList ("xst-model-roots");
318 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
319 di<<"List given by "<<compart.ToCString()<<" : ";
320 list = XSDRAW::GetList (compart.ToCString());
323 di<<"No list defined. Give a selection name or * for all visible transferrable roots\n";
328 std::cout<<"Name of Selection :"<<std::flush;
329 list = XSDRAW::GetList();
330 if (list.IsNull()) { std::cout<<"No list defined"<<std::endl; continue; }
333 Standard_Integer nbl = list->Length();
334 di<<"Nb entities selected : "<<nbl<<"\n";
335 if (nbl == 0) continue;
338 std::cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<std::flush;
342 std::cin>>str_answer;
343 answer = Draw::Atoi(str_answer);
345 if (answer <= 0 || answer > 3) continue;
347 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
348 Handle(Standard_Transient) ent = list->Value(ill);
349 di<<" ";// model->Print(ent,di);
353 if (answer == 1 || answer == 2) {
354 Standard_Integer nbt = 0;
355 Handle(XSControl_WorkSession) thesession = Reader.WS();
357 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
358 progress->NewScope ( 80, "Translation" );
360 thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
362 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
363 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
365 nent = Reader.Model()->Number(list->Value(ill));
366 if (nent == 0) continue;
367 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result\n";
369 nbs = Reader.NbShapes();
370 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
371 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
372 di<<"Now, "<<nbs<<" Shapes produced\n";
373 TopoDS_Shape sh = Reader.Shape(nbs);
374 DBRep::Set (shname,sh);
378 thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
379 progress->EndScope();
381 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
382 answer = 0; // on ne reboucle pas
386 else di<<"Unknown mode n0 "<<modepri<<"\n";
391 //--------------------------------------------------------------
392 // Function : testreadiges
394 //--------------------------------------------------------------
395 static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
399 di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
400 di << " Usage : " << argv[0] <<" file_name shape_name\n";
403 IGESControl_Reader Reader;
404 Standard_CString filename = argv[1];
405 IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
406 di<<"Status from reading IGES file "<<filename<<" : ";
408 case IFSelect_RetVoid : { di<<"empty file\n"; return 1; }
409 case IFSelect_RetDone : { di<<"file read\n"; break; }
410 case IFSelect_RetError : { di<<"file not found\n"; return 1; }
411 case IFSelect_RetFail : { di<<"error during read\n"; return 1; }
412 default : { di<<"failure\n"; return 1; }
414 Reader.TransferRoots();
415 TopoDS_Shape shape = Reader.OneShape();
416 DBRep::Set(argv[2],shape);
417 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
421 //--------------------------------------------------------------
422 // Function : brepiges
424 //--------------------------------------------------------------
426 static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, const char** a)
428 XSDRAW::SetNorm ("IGES");
429 // ecriture dans le model d'une entite :
430 // - model_AddEntity(ent) : ecriture de l`entite seule
431 // - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement
432 // . de sa matrice de transformation
433 // . de ses sous-elements
435 IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
436 Interface_Static::IVal("write.iges.brep.mode"));
437 di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
438 di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
439 di<<" To modifiy : command param\n";
441 // Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
442 // c a d tant qu il y a des + on ajoute ce qui suit
443 const char* nomfic = NULL;
444 Standard_Integer npris = 0;
446 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
447 progress->NewScope(90,"Translating");
449 ICW.TransferProcess()->SetProgress(progress);
451 for ( Standard_Integer i = 1; i < n; i++) {
452 const char* nomvar = a[i];
453 if (a[i][0] == '+') nomvar = &(a[i])[1];
454 else if (i > 1) { nomfic = a[i]; break; }
455 TopoDS_Shape Shape = DBRep::Get(nomvar);
456 if (ICW.AddShape (Shape)) npris ++;
457 else if (ICW.AddGeom (DrawTrSurf::GetCurve (nomvar)) ) npris ++;
458 else if (ICW.AddGeom (DrawTrSurf::GetSurface (nomvar)) ) npris ++;
461 XSDRAW::SetModel(ICW.Model());
462 XSDRAW::SetTransferProcess (ICW.TransferProcess());
464 ICW.TransferProcess()->SetProgress(0);
465 progress->EndScope();
467 progress->NewScope(10,"Writing");
470 di<<npris<<" Shapes written, giving "<<XSDRAW::Model()->NbEntities()<<" Entities\n";
472 if ( ! nomfic ) // delayed write
474 di<<" Now, to write a file, command : writeall filename\n";
479 if (! ICW.Write(nomfic)) di<<" Error: could not write file " << nomfic;
480 else di<<" File " << nomfic << " written";
482 progress->EndScope();
488 //--------------------------------------------------------------
489 // Function : testwriteiges
491 //--------------------------------------------------------------
493 static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, const char** a)
497 di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n";
498 di << " Usage : " << a[0] <<" file_name shape_name\n";
501 IGESControl_Writer Writer;
502 Standard_CString filename = a[1];
503 TopoDS_Shape shape = DBRep::Get(a[2]);
504 Standard_Boolean ok = Writer.AddShape(shape);
506 di<<"Shape not add\n";
510 if(!(Writer.Write(filename))){
511 di<<"Error on writing file\n";
514 di<<"File Is Written\n";
517 //--------------------------------------------------------------
518 // Function : igesparam
520 //--------------------------------------------------------------
523 static Standard_Integer igesparam (Draw_Interpretor& di, Standard_Integer , const char** )
525 // liste des parametres
526 di<<"List of parameters which control IGES :\n";
527 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";
528 di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
529 di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
530 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
531 di<<"\n To modifier, param nom_param new_val\n";
536 //--------------------------------------------------------------
537 // Function : tplosttrim
539 //--------------------------------------------------------------
541 static Standard_Integer XSDRAWIGES_tplosttrim (Draw_Interpretor& di, Standard_Integer n, const char** a)
543 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
545 // Standard_Integer narg = pilot->NbWords();
546 Standard_Integer narg = n;
548 const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
549 TColStd_Array1OfAsciiString strarg(1, 3);
550 TColStd_Array1OfAsciiString typarg(1, 3);
551 strarg.SetValue(1,"xst-type(CurveOnSurface)");
552 strarg.SetValue(2,"xst-type(Boundary)");
553 strarg.SetValue(3,"xst-type(Loop)");
554 typarg.SetValue(1,"IGESGeom_TrimmedSurface");
555 typarg.SetValue(2,"IGESGeom_BoundedSurface");
556 typarg.SetValue(3,"IGESSolid_Face");
557 if (TP.IsNull()) { di<<"No Transfer Read\n"; return 1; }
558 Standard_Integer nbFaces = 0, totFaces = 0 ;
559 Handle(IFSelect_WorkSession) WS = pilot->Session();
560 Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult();
561 Standard_Integer k=0;
563 // TCollection_AsciiString Arg = pilot->Word(1);
564 TCollection_AsciiString Arg(a[1]);
565 for(k=1 ; k<=3;k++ ) {
566 if(typarg.Value(k).Location(Arg,1,typarg.Value(k).Length()) != 0) break;
569 if( k == 4) {di<< "Invalid argument\n"; return 0; }
570 for(Standard_Integer j = 1 ; j <= 3; j++) {
571 TColStd_MapOfTransient aMap;
573 Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(),strarg.Value(k).ToCString());
574 if (!list.IsNull()) itrp.Filter (list);
576 di << "No untrimmed faces\n";
579 for (itrp.Start(); itrp.More(); itrp.Next()) {
580 Handle(Standard_Transient) ent = itrp.Starting();
581 Handle(TColStd_HSequenceOfTransient) super = WS->Sharings (ent);
582 if (!super.IsNull()) {
583 Standard_Integer nb = super->Length();
585 for (Standard_Integer i = 1; i <= nb; i++)
586 if (super->Value(i)->IsKind (typarg.Value(k).ToCString())) {
587 if(aMap.Add(super->Value(i))) nbFaces++;
593 if( j == 1 ) di << "Number of untrimmed faces: \n";
596 di << "Trimmed Surface: \n"; break;
598 di << "Bounded Surface: \n"; break;
600 di << "Face: \n"; break;
603 TColStd_MapIteratorOfMapOfTransient itmap;
604 Standard_SStream aTmpStream;
605 for(itmap.Initialize(aMap); itmap.More(); itmap.Next()) {
606 XSDRAW::Model()->Print (itmap.Key(), aTmpStream);
609 di << aTmpStream.str().c_str();
611 di << "\nNumber:"<< nbFaces << "\n";
618 if(totFaces == 0) di << "No untrimmed faces\n";
619 else di << "Total number :" << totFaces << "\n";
622 //-------------------------------------------------------------------
623 //--------------------------------------------------------------
626 //--------------------------------------------------------------
627 static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer n, const char** a)
629 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
630 Standard_Integer argc = n;//= pilot->NbWords();
631 const Standard_CString arg1 = a[1];//pilot->Arg(1);
632 const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
633 IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
635 Handle(Interface_InterfaceModel) model = TP->Model();
636 if (model.IsNull()) {di<<"No Transfer Read\n"; return -1;}
637 Handle(XSControl_WorkSession) thesession = read.WS();
638 thesession->SetMapReader(TP);
639 Standard_Integer mod1 = 0;
641 char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
643 case 'g' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_GeneralInfo);break;
644 case 'c' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_CountByItem); break;
645 case 'C' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ListByItem); break;
646 case 'r' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ResultCount);break;
647 case 's' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_Mapping);break;
648 case '?' : mod1 = -1; break;
649 default : mod1 = -2; break;
652 if (mod1 < -1) di<<"Unknown Mode\n";
654 di<<"Modes available :\n"
655 <<"g : general c : checks (count) C (list)\n"
656 <<"r : number of CasCade resulting shapes\n"
657 <<"s : mapping between IGES entities and CasCade shapes\n";
658 if (mod1 < -1) return -1;
664 static Standard_Integer etest(Draw_Interpretor& di, Standard_Integer argc, const char** a)
667 di<<"etest igesfile shape\n";
670 IGESControl_Reader aReader;
671 aReader.ReadFile(a[1]);
672 aReader.SetReadVisible(Standard_True);
673 aReader.TransferRoots();
674 TopoDS_Shape shape = aReader.OneShape();
675 DBRep::Set(a[2],shape);
680 static void cleanpilot ()
682 XSDRAW::Session()->ClearData(1);
687 //--------------------------------------------------------------
688 // Function : Init(s)
690 //--------------------------------------------------------------
692 void XSDRAWIGES::InitSelect ()
694 Handle(IGESSelect_Activator) igesact = new IGESSelect_Activator;
695 IGESControl_Controller::Init();
696 // XSDRAW::SetNorm ("IGES"); trop tot
697 XSDRAW::SetController (XSControl_Controller::Recorded("iges"));
703 //=======================================================================
704 //function : InitToBRep
706 //=======================================================================
708 void XSDRAWIGES::InitToBRep (Draw_Interpretor& theCommands)
710 const char* g = "DE: IGES";
711 theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
712 theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g);
713 theCommands.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
714 theCommands.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g);
715 theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g);
716 theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g);
717 theCommands.Add("etest", "test of eviewer", __FILE__, etest, g);
722 //=======================================================================
723 //function : InitFromBRep
725 //=======================================================================
727 void XSDRAWIGES::InitFromBRep (Draw_Interpretor& theCommands)
729 const char* g = "DE: IGES";
730 theCommands.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, g);
731 theCommands.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, g);