1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 //gka 06.01.99 S3767 new function TPSTAT (first version)
19 //pdn 11.01.99 putting "return" statement for compilation on NT
20 #include <XSDRAWIGES.ixx>
22 #include <Standard_ErrorHandler.hxx>
23 #include <Standard_Failure.hxx>
24 #include <Interface_Static.hxx>
26 #include <IGESControl_Writer.hxx>
27 #include <IGESControl_Controller.hxx>
28 #include <IGESData_BasicEditor.hxx>
30 #include <IGESData.hxx>
31 #include <IGESData_Protocol.hxx>
32 // #include <IGESData_IGESWriter.hxx>
33 #include <IGESData_IGESEntity.hxx> // pour igeslist
34 #include <IGESData_IGESModel.hxx>
36 #include <Interface_Check.hxx>
37 #include <Interface_CheckTool.hxx>
38 #include <Interface_CheckIterator.hxx>
41 #include <TCollection_HAsciiString.hxx>
42 #include <TCollection_AsciiString.hxx>
43 #include <TColStd_HSequenceOfTransient.hxx>
46 #include <TopoDS_Shape.hxx>
48 #include <IGESToBRep.hxx>
49 #include <IGESToBRep_Actor.hxx>
50 #include <IGESToBRep_Reader.hxx>
52 #include <Geom_Curve.hxx>
53 #include <Geom_Surface.hxx>
55 #include <Interface_Macros.hxx>
56 #include <Message_Messenger.hxx>
58 #include <Draw_Appli.hxx>
59 #include <Draw_Printer.hxx>
60 #include <DrawTrSurf.hxx>
62 //#include <GeometryTest.hxx> essai CKY 4-AUT-1998
63 //#include <BRepTest.hxx> essai CKY 4-AUT-1998
64 //#include <MeshTest.hxx> essai CKY 4-AUT-1998
68 #include <IGESSelect_Activator.hxx>
70 #include <XSDRAW_Commands.hxx>
71 #include <Transfer_TransientProcess.hxx>
72 #include <Transfer_TransferOutput.hxx>
73 #include <Transfer_FinderProcess.hxx>
74 #include <XSControl_WorkSession.hxx>
77 #include <IFSelect_SessionPilot.hxx>
78 #include <XSControl.hxx>
79 #include <Transfer_IteratorOfProcessForTransient.hxx>
80 #include <TColStd_MapOfTransient.hxx>
81 #include <IFSelect_Functions.hxx>
82 #include <TColStd_MapIteratorOfMapOfTransient.hxx>
83 #include <IGESControl_Reader.hxx>
84 #include <Interface_InterfaceModel.hxx>
85 #include <Draw_ProgressIndicator.hxx>
86 #include <TopExp_Explorer.hxx>
87 #include <Message_ProgressSentry.hxx>
89 //--------------------------------------------------------------
90 // Function : igesbrep
91 //--------------------------------------------------------------
93 static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
95 DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
96 if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
99 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
100 progress->SetScale ( 0, 100, 1 );
103 IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
104 Standard_Boolean aFullMode = Standard_True;
105 Reader.WS()->SetModeStat(aFullMode);
107 ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
109 TCollection_AsciiString fnom,rnom;
111 Standard_Boolean modfic = XSDRAW::FileAndVar
112 (argv[1],argv[2],"IGESBREP",fnom,rnom);
113 if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
114 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
115 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
116 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
119 OSD_Timer Chr; Chr.Reset();
125 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
128 if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
129 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
131 progress->EndScope();
134 if (readstat != IFSelect_RetDone) {
135 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
136 else di<<"No model loaded"<<"\n";
139 // Choice of treatment
140 Standard_Boolean fromtcl = (argc > 3);
141 Standard_Integer modepri = 1, nent, nbs;
142 if (fromtcl) modepri = 4;
145 //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
146 //mode OnlyVisible does not work.
147 // nent = Reader.NbRootsForTransfer();
149 cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
152 // amv 26.09.2003 : this is used to avoid error of enter's simbol
155 modepri = Draw::Atoi(str);
158 if (modepri == 0) { //fin
159 di << "Bye and good luck! " << "\n";
163 else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
164 di << "All Geometry Transfer"<<"\n";
165 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
166 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
167 Handle(XSControl_WorkSession) thesession = Reader.WS();
168 thesession->ClearContext();
169 XSDRAW::SetTransferProcess (thesession->MapReader());
170 progress->NewScope ( 80, "Translation" );
172 thesession->MapReader()->SetProgress ( progress );
174 if (modepri == 1) Reader.SetReadVisible (Standard_True);
175 Reader.TransferRoots();
177 thesession->MapReader()->SetProgress ( 0 );
178 progress->EndScope();
180 // result in only one shape for all the roots
181 // or in one shape for one root.
182 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
183 Standard_Integer answer = 1;
184 if (Reader.NbShapes() > 1) {
185 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;
190 answer = Draw::Atoi(str_a);
192 if ( answer == 0) continue;
193 if ( answer == 1 || answer == 3) {
194 TopoDS_Shape shape = Reader.OneShape();
196 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
198 Sprintf(fname, "%s", rnom.ToCString());
199 di << "Saving shape in variable Draw : " << fname << "\n";
200 if (answer == 3) IGESToBRep::WriteShape (shape,1);
203 DBRep::Set(fname,shape);
205 catch(Standard_Failure) {
206 di << "** Exception : ";
207 di << Standard_Failure::Caught()->GetMessageString();
208 di<<" ** Skip"<<"\n";
209 di << "Saving shape in variable Draw : " << fname << "\n";
210 IGESToBRep::WriteShape (shape,1);
214 else if (answer == 2 || answer == 4) {
215 Standard_Integer numshape = Reader.NbShapes();
216 for (Standard_Integer inum = 1; inum <= numshape; inum++) {
217 // save all the shapes
218 TopoDS_Shape shape = Reader.Shape(inum);
219 if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
221 Sprintf(fname, "%s_%d", rnom.ToCString(),inum);
222 di << "Saving shape in variable Draw : " << fname << "\n";
223 if (answer == 4) IGESToBRep::WriteShape (shape,inum);
226 DBRep::Set(fname,shape);
228 catch(Standard_Failure) {
229 di << "** Exception : ";
230 di << Standard_Failure::Caught()->GetMessageString();
231 di<<" ** Skip"<<"\n";
238 else if (modepri == 3) { // One Entity
239 cout << "Only One Entity"<<endl;
240 cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
241 cout<<" To modify : command param read.iges.bspline.continuity"<<endl;
242 cout << " give the number of the Entity : " << flush;
243 nent = XSDRAW::GetEntityNumber();
245 if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
247 nbs = Reader.NbShapes();
248 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nent);
249 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
250 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
251 TopoDS_Shape sh = Reader.Shape(nbs);
252 DBRep::Set (shname,sh);
256 else if (modepri == 4) { // Selection
257 Standard_Integer answer = 1;
258 Handle(TColStd_HSequenceOfTransient) list;
260 // Selection, nommee ou via tcl. tcl : raccourcis admis
261 // * donne iges-visible + xst-transferrable-roots
262 // *r donne xst-model-roots (TOUTES racines)
264 if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
265 di << "All Geometry Transfer"<<"\n";
266 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
267 di<<" To modify : command param read.iges.bspline.continuity"<<"\n";
268 Handle(XSControl_WorkSession) thesession = Reader.WS();
269 thesession->ClearContext();
270 XSDRAW::SetTransferProcess (thesession->MapReader());
271 progress->NewScope ( 80, "Translation" );
273 thesession->MapReader()->SetProgress ( progress );
275 Reader.SetReadVisible (Standard_True);
276 Reader.TransferRoots();
278 thesession->MapReader()->SetProgress ( 0 );
279 progress->EndScope();
282 // result in only one shape for all the roots
283 TopoDS_Shape shape = Reader.OneShape();
286 Sprintf(fname, "%s", rnom.ToCString());
287 di << "Saving shape in variable Draw : " << fname << "\n";
290 DBRep::Set(fname,shape);
292 catch(Standard_Failure) {
293 di << "** Exception : ";
294 di << Standard_Failure::Caught()->GetMessageString();
295 di<<" ** Skip"<<"\n";
296 di << "Saving shape in variable Draw : " << fname << "\n";
297 IGESToBRep::WriteShape (shape,1);
303 modepri = 0; // d office, une seule passe
304 if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
306 list = XSDRAW::GetList ("xst-model-roots");
309 TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
310 di<<"List given by "<<compart.ToCString()<<" : ";
311 list = XSDRAW::GetList (compart.ToCString());
314 di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
319 cout<<"Name of Selection :"<<flush;
320 list = XSDRAW::GetList();
321 if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
324 Standard_Integer nbl = list->Length();
325 di<<"Nb entities selected : "<<nbl<<"\n";
326 if (nbl == 0) continue;
329 cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<flush;
334 answer = Draw::Atoi(str_answer);
336 if (answer <= 0 || answer > 3) continue;
338 for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
339 Handle(Standard_Transient) ent = list->Value(ill);
340 di<<" ";// model->Print(ent,di);
344 if (answer == 1 || answer == 2) {
345 Standard_Integer nbt = 0;
346 Handle(XSControl_WorkSession) thesession = Reader.WS();
348 XSDRAW::SetTransferProcess (thesession->MapReader());
349 progress->NewScope ( 80, "Translation" );
351 thesession->MapReader()->SetProgress ( progress );
353 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
354 for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
356 nent = Reader.Model()->Number(list->Value(ill));
357 if (nent == 0) continue;
358 if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
360 nbs = Reader.NbShapes();
361 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
362 di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
363 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
364 TopoDS_Shape sh = Reader.Shape(nbs);
365 DBRep::Set (shname,sh);
369 thesession->MapReader()->SetProgress ( 0 );
370 progress->EndScope();
372 di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
373 answer = 0; // on ne reboucle pas
377 else di<<"Unknown mode n0 "<<modepri<<"\n";
382 //--------------------------------------------------------------
383 // Function : testreadiges
385 //--------------------------------------------------------------
386 static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
390 di << "ERROR in " << argv[0] << "Wrong Number of Arguments."<<"\n";
391 di << " Usage : " << argv[0] <<" file_name shape_name"<< "\n";
394 IGESControl_Reader Reader;
395 Standard_CString filename = argv[1];
396 IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
397 di<<"Status from reading IGES file "<<filename<<" : ";
399 case IFSelect_RetVoid : { di<<"empty file"<<"\n"; return 1; }
400 case IFSelect_RetDone : { di<<"file read"<<"\n"; break; }
401 case IFSelect_RetError : { di<<"file not found"<<"\n"; return 1; }
402 case IFSelect_RetFail : { di<<"error during read"<<"\n"; return 1; }
403 default : { di<<"failure"<<"\n"; return 1; }
405 Reader.TransferRoots();
406 TopoDS_Shape shape = Reader.OneShape();
407 DBRep::Set(argv[2],shape);
408 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
412 //--------------------------------------------------------------
413 // Function : brepiges
415 //--------------------------------------------------------------
417 static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, const char** a)
419 XSDRAW::SetNorm ("IGES");
420 // ecriture dans le model d'une entite :
421 // - model_AddEntity(ent) : ecriture de l`entite seule
422 // - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement
423 // . de sa matrice de transformation
424 // . de ses sous-elements
426 IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
427 Interface_Static::IVal("write.iges.brep.mode"));
428 di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
429 di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
430 di<<" To modifiy : command param"<<"\n";
432 // Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
433 // c a d tant qu il y a des + on ajoute ce qui suit
434 const char* nomfic = NULL;
435 Standard_Integer npris = 0;
437 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
438 progress->NewScope(90,"Translating");
440 ICW.TransferProcess()->SetProgress(progress);
442 for ( Standard_Integer i = 1; i < n; i++) {
443 const char* nomvar = a[i];
444 if (a[i][0] == '+') nomvar = &(a[i])[1];
445 else if (i > 1) { nomfic = a[i]; break; }
446 TopoDS_Shape Shape = DBRep::Get(nomvar);
447 if (ICW.AddShape (Shape)) npris ++;
448 else if (ICW.AddGeom (DrawTrSurf::GetCurve (nomvar)) ) npris ++;
449 else if (ICW.AddGeom (DrawTrSurf::GetSurface (nomvar)) ) npris ++;
452 XSDRAW::SetModel(ICW.Model());
453 XSDRAW::SetTransferProcess (ICW.TransferProcess());
455 ICW.TransferProcess()->SetProgress(0);
456 progress->EndScope();
458 progress->NewScope(10,"Writing");
461 di<<npris<<" Shapes written, giving "<<XSDRAW::Model()->NbEntities()<<" Entities"<<"\n";
463 if ( ! nomfic ) // delayed write
465 di<<" Now, to write a file, command : writeall filename"<<"\n";
470 if (! ICW.Write(nomfic)) di<<" Error: could not write file " << nomfic;
471 else di<<" File " << nomfic << " written";
473 progress->EndScope();
479 //--------------------------------------------------------------
480 // Function : testwriteiges
482 //--------------------------------------------------------------
484 static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, const char** a)
488 di << "ERROR in " << a[0] << "Wrong Number of Arguments."<<"\n";
489 di << " Usage : " << a[0] <<" file_name shape_name"<< "\n";
492 IGESControl_Writer Writer;
493 Standard_CString filename = a[1];
494 TopoDS_Shape shape = DBRep::Get(a[2]);
495 Standard_Boolean ok = Writer.AddShape(shape);
497 di<<"Shape not add"<<"\n";
501 if(!(Writer.Write(filename))){
502 di<<"Error on writing file"<<"\n";
505 di<<"File Is Written"<<"\n";
508 //--------------------------------------------------------------
509 // Function : igesparam
511 //--------------------------------------------------------------
514 static Standard_Integer igesparam (Draw_Interpretor& di, Standard_Integer , const char** )
516 // liste des parametres
517 di<<"List of parameters which control IGES :"<<"\n";
518 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";
519 di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
520 di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
521 di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
522 di<<"\n"<<" To modifier, param nom_param new_val"<<"\n";
527 //--------------------------------------------------------------
528 // Function : tplosttrim
530 //--------------------------------------------------------------
532 static Standard_Integer XSDRAWIGES_tplosttrim (Draw_Interpretor& di, Standard_Integer n, const char** a)
534 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
536 // Standard_Integer narg = pilot->NbWords();
537 Standard_Integer narg = n;
539 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
540 TColStd_Array1OfAsciiString strarg(1, 3);
541 TColStd_Array1OfAsciiString typarg(1, 3);
542 strarg.SetValue(1,"xst-type(CurveOnSurface)");
543 strarg.SetValue(2,"xst-type(Boundary)");
544 strarg.SetValue(3,"xst-type(Loop)");
545 typarg.SetValue(1,"IGESGeom_TrimmedSurface");
546 typarg.SetValue(2,"IGESGeom_BoundedSurface");
547 typarg.SetValue(3,"IGESSolid_Face");
548 if (TP.IsNull()) { di<<"No Transfer Read"<<"\n"; return 1; }
549 Standard_Integer nbFaces = 0, totFaces = 0 ;
550 Handle(IFSelect_WorkSession) WS = pilot->Session();
551 Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult();
552 Standard_Integer k=0;
554 // TCollection_AsciiString Arg = pilot->Word(1);
555 TCollection_AsciiString Arg(a[1]);
556 for(k=1 ; k<=3;k++ ) {
557 if(typarg.Value(k).Location(Arg,1,typarg.Value(k).Length()) != 0) break;
560 if( k == 4) {di<< "Invalid argument"<<"\n"; return 0; }
561 for(Standard_Integer j = 1 ; j <= 3; j++) {
562 TColStd_MapOfTransient aMap;
564 Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(),strarg.Value(k).ToCString());
565 if (!list.IsNull()) itrp.Filter (list);
567 di << "No untrimmed faces" << "\n";
570 for (itrp.Start(); itrp.More(); itrp.Next()) {
571 Handle(Standard_Transient) ent = itrp.Starting();
572 Handle(TColStd_HSequenceOfTransient) super = WS->Sharings (ent);
573 if (!super.IsNull()) {
574 Standard_Integer nb = super->Length();
576 for (Standard_Integer i = 1; i <= nb; i++)
577 if (super->Value(i)->IsKind (typarg.Value(k).ToCString())) {
578 if(aMap.Add(super->Value(i))) nbFaces++;
584 if( j == 1 ) di << "Number of untrimmed faces: " << "\n";
587 di << "Trimmed Surface: " << "\n"; break;
589 di << "Bounded Surface: " << "\n"; break;
591 di << "Face: " << "\n"; break;
593 Handle(Message_Messenger) aDIMessenger =
594 new Message_Messenger (new Draw_Printer(di));
595 TColStd_MapIteratorOfMapOfTransient itmap;
596 for(itmap.Initialize(aMap); itmap.More(); itmap.Next()) {
597 //XSDRAW::Model()->Print(itmap.Key(),cout);
598 Standard_SStream aSStream;
599 XSDRAW::Model()->Print(itmap.Key(),aDIMessenger);
604 di << "\n" << "Number:"<< nbFaces << "\n";
611 if(totFaces == 0) di << "No untrimmed faces" << "\n";
612 else di << "Total number :" << totFaces << "\n";
615 //-------------------------------------------------------------------
616 //--------------------------------------------------------------
619 //--------------------------------------------------------------
620 static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer n, const char** a)
622 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
623 Standard_Integer argc = n;//= pilot->NbWords();
624 const Standard_CString arg1 = a[1];//pilot->Arg(1);
625 //IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
626 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
627 IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
628 //read.SetTransientProcess(TP);
630 // if (TP.IsNull()) { di<<"No Transfer Read"<<"\n"; return IFSelect_RetError;}
631 Handle(Interface_InterfaceModel) model = TP->Model();
632 //Handle(Interface_InterfaceModel) model = read.Model();
633 if (model.IsNull()) {di<<"No Transfer Read"<<"\n"; return -1;}
634 //DeclareAndCast(IGESData_IGESModel,modelig,model);
635 // read.SetModel(modelig);
636 Handle(XSControl_WorkSession) thesession = read.WS();
637 thesession->SetMapReader(TP);
638 //read.SetModel(model);
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);