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_ProgressScope.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 Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100);
111 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
112 Standard_Boolean aFullMode = Standard_True;
113 Reader.WS()->SetModeStat(aFullMode);
115 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
117 TCollection_AsciiString fnom,rnom;
119 Standard_Boolean modfic = XSDRAW::FileAndVar
120 (argv[1],argv[2],"IGESBREP",fnom,rnom);
121 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
122 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
123 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
124 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
127 OSD_Timer Chr; Chr.Reset();
133 aPSRoot.SetName("Loading");
134 progress->Show(aPSRoot);
136 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
137 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
139 aPSRoot.Next(20); // On average loading takes 20%
140 if (aPSRoot.UserBreak())
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());
180 aPSRoot.SetName("Translation");
181 progress->Show(aPSRoot);
183 if (modepri == 1) Reader.SetReadVisible (Standard_True);
184 Reader.TransferRoots(aPSRoot.Next(80));
186 if (aPSRoot.UserBreak())
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))
255 di<<"Transfer entity n0 "<<nent<<" : no result\n";
257 nbs = Reader.NbShapes();
258 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nent);
259 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
260 di<<"Now, "<<nbs<<" Shapes produced\n";
261 TopoDS_Shape sh = Reader.Shape(nbs);
262 DBRep::Set (shname,sh);
266 else if (modepri == 4) { // Selection
267 Standard_Integer answer = 1;
268 Handle(TColStd_HSequenceOfTransient) list;
270 // Selection, nommee ou via tcl. tcl : raccourcis admis
271 // * donne iges-visible + xst-transferrable-roots
272 // *r donne xst-model-roots (TOUTES racines)
274 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
275 di << "All Geometry Transfer\n";
276 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
277 di<<" To modify : command param read.iges.bspline.continuity\n";
278 Handle(XSControl_WorkSession) thesession = Reader.WS();
279 thesession->ClearContext();
280 XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
282 aPSRoot.SetName("Translation");
283 progress->Show(aPSRoot);
285 Reader.SetReadVisible (Standard_True);
286 Reader.TransferRoots(aPSRoot.Next(80));
288 if (aPSRoot.UserBreak())
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 aPSRoot.SetName("Translation");
359 progress->Show(aPSRoot);
361 Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl);
362 for (Standard_Integer ill = 1; ill <= nbl && aPS.More(); ill++)
364 nent = Reader.Model()->Number(list->Value(ill));
365 if (nent == 0) continue;
366 if (!Reader.TransferOne(nent, aPS.Next()))
367 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 if (aPSRoot.UserBreak())
380 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
381 answer = 0; // on ne reboucle pas
385 else di<<"Unknown mode n0 "<<modepri<<"\n";
390 //--------------------------------------------------------------
391 // Function : testreadiges
393 //--------------------------------------------------------------
394 static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
398 di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
399 di << " Usage : " << argv[0] <<" file_name shape_name\n";
402 IGESControl_Reader Reader;
403 Standard_CString filename = argv[1];
404 IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
405 di<<"Status from reading IGES file "<<filename<<" : ";
407 case IFSelect_RetVoid : { di<<"empty file\n"; return 1; }
408 case IFSelect_RetDone : { di<<"file read\n"; break; }
409 case IFSelect_RetError : { di<<"file not found\n"; return 1; }
410 case IFSelect_RetFail : { di<<"error during read\n"; return 1; }
411 default : { di<<"failure\n"; return 1; }
413 Reader.TransferRoots();
414 TopoDS_Shape shape = Reader.OneShape();
415 DBRep::Set(argv[2],shape);
416 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
420 //--------------------------------------------------------------
421 // Function : brepiges
423 //--------------------------------------------------------------
425 static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, const char** a)
427 XSDRAW::SetNorm ("IGES");
428 // ecriture dans le model d'une entite :
429 // - model_AddEntity(ent) : ecriture de l`entite seule
430 // - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement
431 // . de sa matrice de transformation
432 // . de ses sous-elements
434 IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
435 Interface_Static::IVal("write.iges.brep.mode"));
436 di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
437 di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
438 di<<" To modify : command param\n";
440 // Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
441 // c a d tant qu il y a des + on ajoute ce qui suit
442 const char* nomfic = NULL;
443 Standard_Integer npris = 0;
445 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
446 Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100);
447 progress->Show(aPSRoot);
449 Message_ProgressScope aPS(aPSRoot.Next(90), NULL, n);
450 for ( Standard_Integer i = 1; i < n && aPS.More(); i++) {
451 const char* nomvar = a[i];
452 if (a[i][0] == '+') nomvar = &(a[i])[1];
453 else if (i > 1) { nomfic = a[i]; break; }
454 TopoDS_Shape Shape = DBRep::Get(nomvar);
455 if (ICW.AddShape (Shape, aPS.Next())) npris ++;
456 else if (ICW.AddGeom (DrawTrSurf::GetCurve (nomvar)) ) npris ++;
457 else if (ICW.AddGeom (DrawTrSurf::GetSurface (nomvar)) ) npris ++;
460 XSDRAW::SetModel(ICW.Model());
461 XSDRAW::SetTransferProcess (ICW.TransferProcess());
463 if (aPSRoot.UserBreak())
465 aPSRoot.SetName("Writing");
466 progress->Show(aPSRoot);
468 di<<npris<<" Shapes written, giving "<<XSDRAW::Model()->NbEntities()<<" Entities\n";
470 if ( ! nomfic ) // delayed write
472 di<<" Now, to write a file, command : writeall filename\n";
477 if (! ICW.Write(nomfic)) di<<" Error: could not write file " << nomfic;
478 else di<<" File " << nomfic << " written";
483 //--------------------------------------------------------------
484 // Function : testwriteiges
486 //--------------------------------------------------------------
488 static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, const char** a)
492 di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n";
493 di << " Usage : " << a[0] <<" file_name shape_name\n";
496 IGESControl_Writer Writer;
497 Standard_CString filename = a[1];
498 TopoDS_Shape shape = DBRep::Get(a[2]);
499 Standard_Boolean ok = Writer.AddShape(shape);
501 di<<"Shape not add\n";
505 if(!(Writer.Write(filename))){
506 di<<"Error on writing file\n";
509 di<<"File Is Written\n";
512 //--------------------------------------------------------------
513 // Function : igesparam
515 //--------------------------------------------------------------
518 static Standard_Integer igesparam (Draw_Interpretor& di, Standard_Integer , const char** )
520 // liste des parametres
521 di<<"List of parameters which control IGES :\n";
522 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";
523 di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
524 di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
525 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
526 di<<"\n To modifier, param nom_param new_val\n";
531 //--------------------------------------------------------------
532 // Function : tplosttrim
534 //--------------------------------------------------------------
536 static Standard_Integer XSDRAWIGES_tplosttrim (Draw_Interpretor& di, Standard_Integer n, const char** a)
538 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
540 // Standard_Integer narg = pilot->NbWords();
541 Standard_Integer narg = n;
543 const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
544 TColStd_Array1OfAsciiString strarg(1, 3);
545 TColStd_Array1OfAsciiString typarg(1, 3);
546 strarg.SetValue(1,"xst-type(CurveOnSurface)");
547 strarg.SetValue(2,"xst-type(Boundary)");
548 strarg.SetValue(3,"xst-type(Loop)");
549 typarg.SetValue(1,"IGESGeom_TrimmedSurface");
550 typarg.SetValue(2,"IGESGeom_BoundedSurface");
551 typarg.SetValue(3,"IGESSolid_Face");
552 if (TP.IsNull()) { di<<"No Transfer Read\n"; return 1; }
553 Standard_Integer nbFaces = 0, totFaces = 0 ;
554 Handle(IFSelect_WorkSession) WS = pilot->Session();
555 Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult();
556 Standard_Integer k=0;
558 // TCollection_AsciiString Arg = pilot->Word(1);
559 TCollection_AsciiString Arg(a[1]);
560 for(k=1 ; k<=3;k++ ) {
561 if(typarg.Value(k).Location(Arg,1,typarg.Value(k).Length()) != 0) break;
564 if( k == 4) {di<< "Invalid argument\n"; return 0; }
565 for(Standard_Integer j = 1 ; j <= 3; j++) {
566 TColStd_MapOfTransient aMap;
568 Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(),strarg.Value(k).ToCString());
569 if (!list.IsNull()) itrp.Filter (list);
571 di << "No untrimmed faces\n";
574 for (itrp.Start(); itrp.More(); itrp.Next()) {
575 Handle(Standard_Transient) ent = itrp.Starting();
576 Handle(TColStd_HSequenceOfTransient) super = WS->Sharings (ent);
577 if (!super.IsNull()) {
578 Standard_Integer nb = super->Length();
580 for (Standard_Integer i = 1; i <= nb; i++)
581 if (super->Value(i)->IsKind (typarg.Value(k).ToCString())) {
582 if(aMap.Add(super->Value(i))) nbFaces++;
588 if( j == 1 ) di << "Number of untrimmed faces: \n";
591 di << "Trimmed Surface: \n"; break;
593 di << "Bounded Surface: \n"; break;
595 di << "Face: \n"; break;
598 TColStd_MapIteratorOfMapOfTransient itmap;
599 Standard_SStream aTmpStream;
600 for(itmap.Initialize(aMap); itmap.More(); itmap.Next()) {
601 XSDRAW::Model()->Print (itmap.Key(), aTmpStream);
604 di << aTmpStream.str().c_str();
606 di << "\nNumber:"<< nbFaces << "\n";
613 if(totFaces == 0) di << "No untrimmed faces\n";
614 else di << "Total number :" << totFaces << "\n";
617 //-------------------------------------------------------------------
618 //--------------------------------------------------------------
621 //--------------------------------------------------------------
622 static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer n, const char** a)
624 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
625 Standard_Integer argc = n;//= pilot->NbWords();
626 const Standard_CString arg1 = a[1];//pilot->Arg(1);
627 const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
628 IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
630 Handle(Interface_InterfaceModel) model = TP->Model();
631 if (model.IsNull()) {di<<"No Transfer Read\n"; return -1;}
632 Handle(XSControl_WorkSession) thesession = read.WS();
633 thesession->SetMapReader(TP);
634 Standard_Integer mod1 = 0;
636 char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
638 case 'g' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_GeneralInfo);break;
639 case 'c' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_CountByItem); break;
640 case 'C' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ListByItem); break;
641 case 'r' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ResultCount);break;
642 case 's' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_Mapping);break;
643 case '?' : mod1 = -1; break;
644 default : mod1 = -2; break;
647 if (mod1 < -1) di<<"Unknown Mode\n";
649 di<<"Modes available :\n"
650 <<"g : general c : checks (count) C (list)\n"
651 <<"r : number of CasCade resulting shapes\n"
652 <<"s : mapping between IGES entities and CasCade shapes\n";
653 if (mod1 < -1) return -1;
659 static Standard_Integer etest(Draw_Interpretor& di, Standard_Integer argc, const char** a)
662 di<<"etest igesfile shape\n";
665 IGESControl_Reader aReader;
666 aReader.ReadFile(a[1]);
667 aReader.SetReadVisible(Standard_True);
668 aReader.TransferRoots();
669 TopoDS_Shape shape = aReader.OneShape();
670 DBRep::Set(a[2],shape);
675 static void cleanpilot ()
677 XSDRAW::Session()->ClearData(1);
682 //--------------------------------------------------------------
683 // Function : Init(s)
685 //--------------------------------------------------------------
687 void XSDRAWIGES::InitSelect ()
689 Handle(IGESSelect_Activator) igesact = new IGESSelect_Activator;
690 IGESControl_Controller::Init();
691 // XSDRAW::SetNorm ("IGES"); trop tot
692 XSDRAW::SetController (XSControl_Controller::Recorded("iges"));
698 //=======================================================================
699 //function : InitToBRep
701 //=======================================================================
703 void XSDRAWIGES::InitToBRep (Draw_Interpretor& theCommands)
705 const char* g = "DE: IGES";
706 theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
707 theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g);
708 theCommands.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
709 theCommands.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g);
710 theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g);
711 theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g);
712 theCommands.Add("etest", "test of eviewer", __FILE__, etest, g);
717 //=======================================================================
718 //function : InitFromBRep
720 //=======================================================================
722 void XSDRAWIGES::InitFromBRep (Draw_Interpretor& theCommands)
724 const char* g = "DE: IGES";
725 theCommands.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, g);
726 theCommands.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, g);