0024246: Draw command stepread given whithout arguments throws an exception
[occt.git] / src / XSDRAWSTEP / XSDRAWSTEP.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
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.
7//
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.
10//
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.
17
7fd59977 18//:k8 abv 6 Jan 98: using parameter "step.group" for writing assemblies/shapes
19#include <XSDRAWSTEP.ixx>
20#include <STEPControl_Controller.hxx>
21#include <STEPControl_ActorWrite.hxx>
22#include <STEPControl_Reader.hxx>
23#include <STEPControl_Writer.hxx>
24#include <STEPControl_StepModelType.hxx>
25#include <XSDRAW.hxx>
26#include <StepSelect_Activator.hxx>
27
28#include <Draw_Appli.hxx>
29#include <Draw_Interpretor.hxx>
30#include <Draw_Printer.hxx>
31#include <Message_Messenger.hxx>
32
33#include <DBRep.hxx>
34
35#include <TCollection_HAsciiString.hxx>
36#include <Interface_Macros.hxx>
37#include <Interface_InterfaceModel.hxx>
38
39// Pour le transfert (write)
40// Pour NewModel et Write : definition de produit (temporaire ...)
41#include <Transfer_FinderProcess.hxx>
42#include <TransferBRep_ShapeMapper.hxx>
43#include <StepShape_ShapeRepresentation.hxx>
44#include <TColStd_HSequenceOfTransient.hxx>
45
46#include <XSControl_Controller.hxx>
47#include <XSControl_WorkSession.hxx>
48#include <StepData_StepModel.hxx>
49
50#include <TopoDS.hxx>
51
52// steptrans
53#include <StepToTopoDS_MakeTransformed.hxx>
54#include <StepGeom_Axis2Placement3d.hxx>
55
56#include <stdio.h>
57#include <Interface_Static.hxx>
58#include <IFSelect_SessionPilot.hxx>
59#include <STEPSelections_Counter.hxx>
60#include <STEPSelections_AssemblyExplorer.hxx>
61
62#include <Draw_ProgressIndicator.hxx>
63#include <Transfer_TransientProcess.hxx>
64
65#include <TopExp_Explorer.hxx>
66#include <XSControl_TransferWriter.hxx>
67#include <Message_ProgressSentry.hxx>
68
69
70extern "C" {
71static void cleanpilot ()
72{
73 XSDRAW::Session()->ClearData(1);
74}
75}
76
77
78//=======================================================================
79//function : Init
80//purpose :
81//=======================================================================
82
83void XSDRAWSTEP::Init ()
84{
85 Handle(StepSelect_Activator) stepact = new StepSelect_Activator;
86 if (STEPControl_Controller::Init()) // XSDRAW::SetNorm("STEP AP-214"); trop tot
87 XSDRAW::SetController(XSControl_Controller::Recorded("STEP"));
88
89 atexit (cleanpilot);
90}
91
92// ######## COMMANDE stepread : teste le Reader #########
93
94//=======================================================================
95//function : stepread
96//purpose :
97//=======================================================================
98
99static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_Integer argc, const char** argv)
100{
f933f9cf 101 if (argc < 3) {
102 di << "Use: stepread [file] [f or r (type of model full or reduced)]\n";
103 return 1;
104 }
bc650d41 105 // On admet le controller AP214 ou une variante
7fd59977 106 DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
107 if (ctl.IsNull()) XSDRAW::SetNorm("STEP");
108
bc650d41 109
7fd59977 110 // Progress indicator
111 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
112 progress->SetScale ( 0, 100, 1 );
113 progress->Show();
bc650d41 114
7fd59977 115 STEPControl_Reader sr (XSDRAW::Session(),Standard_False);
116 TCollection_AsciiString fnom,rnom;
117 Standard_Boolean modfic = XSDRAW::FileAndVar
118 (argv[1],argv[2],"STEP",fnom,rnom);
119 if (modfic) di<<" File STEP to read : "<<fnom.ToCString()<<"\n";
120 else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
121 di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
122 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
123
124 progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
125 progress->Show();
126
bc650d41 127 Standard_Boolean fromtcl = Standard_False;
45521367 128 Standard_Boolean aFullMode = Standard_False;
bc650d41
G
129 Standard_Integer k = 3;
130 if(argc > k )
131 {
132 if(argv[k][0] == 'f' || argv[3][0] == 'F')
133 {
134 aFullMode = Standard_True;
135 k++;
136 }
137 else if(argv[k][0] == 'r' || argv[3][0] == 'R')
138 {
139 aFullMode = Standard_False;
140 k++;
141 }
142 else
143 fromtcl = Standard_True;
144
145 }
146 if(!fromtcl)
147 fromtcl = argc > k;
148 if(aFullMode)
149 cout<<"Full model for translation with additional info will be used \n"<<flush;
150 else
151 cout<<"Reduced model for translation without additional info will be used \n"<<flush;
152
153 sr.WS()->SetModeStat(aFullMode);
154
155
7fd59977 156 if (modfic) readstat = sr.ReadFile (fnom.ToCString());
157 else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
158
159 progress->EndScope();
160 progress->Show();
161
162 if (readstat != IFSelect_RetDone) {
163 if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
164 else di<<"No model loaded"<<"\n";
165 return 1;
166 }
bc650d41 167
7fd59977 168
bc650d41 169 // nom = "." -> fichier deja lu
7fd59977 170 Standard_Integer i, num, nbs, modepri = 1;
171 if (fromtcl) modepri = 4;
172 Handle(Message_Messenger) aDIMessenger =
173 new Message_Messenger (new Draw_Printer(di));
174 while (modepri) {
175 num = sr.NbRootsForTransfer();
176 if (!fromtcl) {
177 di<<"NbRootsForTransfer="<<num<<" :\n";
178 for (i = 1; i <= num; i ++) {
bc650d41
G
179 di<<"Root."<<i<<", Ent. ";
180 sr.Model()->Print(sr.RootForTransfer(i),aDIMessenger);
181 di<<" Type:"<<sr.RootForTransfer(i)->DynamicType()->Name()<<"\n";
7fd59977 182 }
183
184 cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<<flush;
185 cin>>modepri;
186 }
187
188 if (modepri == 0) { di<<"End Reading STEP"<<"\n"; return 0; }
189 if (modepri <= 2) {
190 num = 1;
191 if (modepri == 2) {
bc650d41 192 cout<<"Root N0 : "<<flush; cin>>num;
7fd59977 193 }
194
195 progress->NewScope ( 80, "Translation" );
196 progress->Show();
197 sr.WS()->MapReader()->SetProgress ( progress );
198
199 if (!sr.TransferRoot (num)) di<<"Transfer root n0 "<<num<<" : no result"<<"\n";
200 else {
bc650d41 201 nbs = sr.NbShapes();
91322f44 202 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
bc650d41
G
203 di<<"Transfer root n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
204 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
205 TopoDS_Shape sh = sr.Shape(nbs);
206 DBRep::Set (shname,sh);
7fd59977 207 }
208
209 sr.WS()->MapReader()->SetProgress ( 0 );
210 progress->EndScope();
211 progress->Show();
212 }
213 else if (modepri == 3) {
214 cout<<"Entity : "<<flush; num = XSDRAW::GetEntityNumber();
215 if (!sr.TransferOne (num)) di<<"Transfer entity n0 "<<num<<" : no result"<<"\n";
216 else {
bc650d41 217 nbs = sr.NbShapes();
91322f44 218 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),num);
bc650d41
G
219 di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
220 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
221 TopoDS_Shape sh = sr.Shape(nbs);
222 DBRep::Set (shname,sh);
7fd59977 223 }
224 }
225 else if (modepri == 4) {
bc650d41 226 // char snm[100]; Standard_Integer answer = 1;
7fd59977 227 Handle(TColStd_HSequenceOfTransient) list;
228
bc650d41
G
229 // Selection, nommee ou via tcl. tcl : raccourcis admis
230 // * donne xst-transferrable-roots
7fd59977 231 if (fromtcl) {
bc650d41
G
232 modepri = 0; // d ioffice une seule passe
233 if (argv[k][0] == '*' && argv[k][1] == '\0') {
234 di<<"Transferrable Roots : ";
235 list = XSDRAW::GetList("xst-transferrable-roots");
7fd59977 236 //list = new TColStd_HSequenceOfTransient;
237 //for(Standard_Integer j=1; j<=num; j++)
238 // list->Append(sr.RootForTransfer(j));
bc650d41 239 }
7fd59977 240 else {
bc650d41
G
241 di<<"List given by "<<argv[k];
242 if (argc > k+1) di<<" "<<argv[k+1];
243 di<<" : ";
244 list = XSDRAW::GetList (argv[k], ( argc > (k+1) ? argv[k+1] : 0 ) );
245 }
246 if (list.IsNull()) { di<<"No list defined. Give a selection name or * for all transferrable roots"<<"\n"; continue; }
7fd59977 247 } else {
bc650d41
G
248 cout<<"Name of Selection :"<<flush;
249 list = XSDRAW::GetList();
250 if (list.IsNull()) { di<<"No list defined"<<"\n"; continue; }
7fd59977 251 }
252
253 Standard_Integer ill, nbl = list->Length();
254 di<<"Nb entities selected : "<<nbl<<"\n";
255 if (nbl == 0) continue;
256
257 progress->NewScope ( 80, "Translation" );
258 progress->Show();
259 sr.WS()->MapReader()->SetProgress ( progress );
260
261 Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
262 for (ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
bc650d41
G
263 num = sr.Model()->Number(list->Value(ill));
264 if (num == 0) continue;
265 if (!sr.TransferOne(num)) di<<"Transfer entity n0 "<<num<<" : no result"<<"\n";
266 else {
267 nbs = sr.NbShapes();
91322f44 268 char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
bc650d41
G
269 di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
270 di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
271 TopoDS_Shape sh = sr.Shape(nbs);
272 DBRep::Set (shname,sh);
273 }
7fd59977 274 }
275 sr.WS()->MapReader()->SetProgress ( 0 );
276 progress->EndScope();
277 progress->Show();
278 }
279 else di<<"Unknown mode n0 "<<modepri<<"\n";
280 }
281 return 0;
282}
283
284//=======================================================================
285//function : testreadstep
286//purpose :
287//=======================================================================
288static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
289{
290 if (argc != 3)
291 {
292 di << "ERROR in " << argv[0] << "Wrong Number of Arguments."<<"\n";
293 di << " Usage : " << argv[0] <<" file_name shape_name"<< "\n";
294 return 1;
295 }
296 STEPControl_Reader Reader;
297 Standard_CString filename = argv[1];
298 IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
299 di<<"Status from reading STEP file "<<filename<<" : ";
300 switch(readstat) {
301 case IFSelect_RetVoid : { di<<"empty file"<<"\n"; return 1; }
302 case IFSelect_RetDone : { di<<"file read"<<"\n"; break; }
303 case IFSelect_RetError : { di<<"file not found"<<"\n"; return 1; }
304 case IFSelect_RetFail : { di<<"error during read"<<"\n"; return 1; }
305 default : { di<<"failure"<<"\n"; return 1; }
306 }
307 Reader.TransferRoots();
308 TopoDS_Shape shape = Reader.OneShape();
309 DBRep::Set(argv[2],shape);
310 di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
311 return 0;
312}
313
314//=======================================================================
315//function : readstep
316//purpose :
317//=======================================================================
318
319static Standard_Integer readstep (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** argv)
320{
321// On admet le controller AP214 ou une variante
322
323
324 STEPControl_Reader sr;
325
326 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
327
328 readstat = sr.ReadFile (argv[1]);
329
330 if (readstat != IFSelect_RetDone) {
331
332 di<<"No model loaded"<<"\n";
333 return 1;
334 }
335
336
337 Standard_Integer num = sr.NbRootsForTransfer();
338 Standard_Integer modepri;
339 di<<"NbRootsForTransfer="<<num<<" :\n";
340
341 cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<<flush;
342 cin>>modepri;
343 if (modepri == 0) { di<<"End Reading STEP"<<"\n"; return 0; }
344
345
346 if (!sr.TransferRoot (num)) di<<"Transfer root n0 "<<num<<" : no result"<<"\n";
347 else {
348 TopoDS_Shape sh = sr.OneShape();
349 DBRep::Set (argv[2],sh);
350 }
351 cin>>modepri;
352 return 0;
353}
354
355// ######## COMMANDE steptrans : teste les transformations #########
356//=======================================================================
357//function : steptrans
358//purpose :
359//=======================================================================
360
361static Standard_Integer steptrans (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
362{
363 if (argc < 5) { di<<"give shape-name new-shape + entity-n0 entity-n0: AXIS2"<<"\n";
364 return 1; }
365 TopoDS_Shape shape = DBRep::Get(argv[1]);
366 if (shape.IsNull()) { di<<"Not a shape : "<<argv[1]<<"\n"; return 1; }
367 Handle(StepGeom_Axis2Placement3d) ax1,ax2;
368 Standard_Integer n1 = 0, n2 = 0;
369 n1 = XSDRAW::GetEntityNumber(argv[3]);
370 if (argc > 4) n2 = XSDRAW::GetEntityNumber(argv[4]);
371 if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast
372 (XSDRAW::Entity(n1));
373 if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast
374 (XSDRAW::Entity(n2));
375 StepToTopoDS_MakeTransformed mktrans;
376 if (mktrans.Compute (ax1,ax2)) {
377 TopLoc_Location loc (mktrans.Transformation());
378 shape.Move (loc);
379// mktrans.Transform (shape);
380 DBRep::Set (argv[2],shape);
381 di<<"Transformed Shape as "<<argv[2]<<"\n";
382 }
383 else di<<"No transformation computed"<<"\n";
384 return 0;
385}
386
387// ######## COMMANDE stepwrite : teste le Writer #########
388
389//=======================================================================
390//function : stepwrite
391//purpose :
392//=======================================================================
393
394static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
395{
396// On admet le controller AP214 ou une variante
397 DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
398 if (ctl.IsNull()) {
399 XSDRAW::SetNorm("STEP");
400 //sln 14.01.2002 OCC51: assign new value to ctl in order to avoid exception during using one in the function
401 ctl = Handle(STEPControl_Controller)::DownCast(XSDRAW::Controller());
402 }
403
404 if (argc < 3) {
405 di<<"Give mode[1-4] and Shape name + optional file. Mode possible"<<"\n";
406 di<<"f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n"
407 <<"m ou 3 : ManifoldSolidBrep w ou 4 : GeometricCurveSet/WireFrame"<<"\n";
408 return 1; }
409 char modeshape = argv[1][0];
410 STEPControl_StepModelType mode;
411 switch (modeshape) {
412 case 'a' :
413 case '0' : mode = STEPControl_AsIs; break;
414 case 'f' :
415 case '1' : mode = STEPControl_FacetedBrep; break;
416 case 's' :
417 case '2' : mode = STEPControl_ShellBasedSurfaceModel; break;
418 case 'm' :
419 case '3' : mode = STEPControl_ManifoldSolidBrep; break;
420 case 'w' :
421 case '4' : mode = STEPControl_GeometricCurveSet; break;
422 default : di<<"1st arg = mode, incorrect [give fsmw]"<<"\n"; return 1;
423 }
424
425 //:k8 abv 6 Jan 98: using parameter for writing mode (assemblies/shapes)
426 Handle(STEPControl_ActorWrite) ActWrite =
427 Handle(STEPControl_ActorWrite)::DownCast ( ctl->ActorWrite() );
428 if ( ! ActWrite.IsNull() )
429 ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly"));
430
431 TopoDS_Shape shape = DBRep::Get(argv[2]);
432 STEPControl_Writer sw (XSDRAW::Session(),Standard_False);
433 Handle(Interface_InterfaceModel) stepmodel = sw.Model();
434 Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
435
436 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
437 progress->NewScope(90,"Translating");
438 progress->Show();
439 sw.WS()->TransferWriter()->FinderProcess()->SetProgress(progress);
440
441 Standard_Integer stat = sw.Transfer (shape,mode);
2857a8ac 442 if (stat == IFSelect_RetDone)
443 {
444 di << "Translation: OK\n";
445 }
446 else
447 {
448 di << "Error: translation failed, status = " << stat << "\n";
449 }
7fd59977 450
451 sw.WS()->TransferWriter()->FinderProcess()->SetProgress(0);
452 progress->EndScope();
453 progress->Show();
454 progress->NewScope(10,"Writing");
455 progress->Show();
456
457// Que s est-il passe
458 stepmodel = sw.Model();
459 Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
460 if (nbavant > 0) di<<"Beware : Model not empty before transferring"<<"\n";
461 if (nbapres <= nbavant) di<<"Beware : No data produced by this transfer"<<"\n";
462 if (nbapres == 0) { di<<"No data to write"<<"\n"; return 0; }
463
7fd59977 464 if (argc <= 3) {
2857a8ac 465 di<<" Now, to write a file, command : writeall filename"<<"\n";
466 return 0;
7fd59977 467 }
7fd59977 468
2857a8ac 469 const char *nomfic = argv[3];
7fd59977 470 stat = sw.Write(nomfic);
471 switch (stat) {
2857a8ac 472 case IFSelect_RetVoid : di<<"Error: No file written"<<"\n"; break;
7fd59977 473 case IFSelect_RetDone : di<<"File "<<nomfic<<" written"<<"\n"; break;
12bf87c5 474 case IFSelect_RetStop : di<<"Error on writing file: no space on disk or destination is write protected"<<"\n"; break;
2857a8ac 475 default : di<<"Error: File "<<nomfic<<" written with fail messages"<<"\n"; break;
7fd59977 476 }
477
478 progress->EndScope();
479 progress->Show();
480
481 return 0;
482}
483//=======================================================================
484//function : testwritestep
485//purpose :
486//=======================================================================
487static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
488{
489 if (argc != 3)
490 {
491 di << "ERROR in " << argv[0] << "Wrong Number of Arguments."<<"\n";
492 di << " Usage : " << argv[0] <<" file_name shape_name "<< "\n";
493 return 1;
494 }
495 STEPControl_Writer Writer;
496 Standard_CString filename = argv[1];
497 TopoDS_Shape shape = DBRep::Get(argv[2]);
498 IFSelect_ReturnStatus stat = Writer.Transfer(shape,STEPControl_AsIs);
499 stat = Writer.Write(filename);
500 if(stat != IFSelect_RetDone){
501 di<<"Error on writing file"<<"\n";
502 return 1;
503 }
504 di<<"File Is Written"<<"\n";
505 return 0;
506}
507
508//=======================================================================
509//function : countexpected
510//purpose :
511//=======================================================================
512
513static Standard_Integer countexpected
514 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
515{
516 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
517 Handle(IFSelect_WorkSession) WS = pilot->Session();
518 const Interface_Graph& graph = WS->Graph();
519
520 Handle(TColStd_HSequenceOfTransient) roots = WS->GiveList("xst-transferrable-roots", "");
521 STEPSelections_Counter cnt;
522
523 for (Standard_Integer i =1 ; i <= roots->Length(); i++) {
524 cnt.Count(graph,roots->Value(i));
525 }
526
527 di<< "Instances of Faces \t: "<<cnt.NbInstancesOfFaces()<<"\n";
528 di<< "Instances of Shells\t: "<<cnt.NbInstancesOfShells()<<"\n";
529 di<< "Instances of Solids\t: "<<cnt.NbInstancesOfSolids()<<"\n";
530 di<< "Instances of Wires in GS\t: "<<cnt.NbInstancesOfWires()<<"\n";
531 di<< "Instances of Edges in GS\t: "<<cnt.NbInstancesOfEdges()<<"\n";
532
533 di<< "Source Faces \t: "<<cnt.NbSourceFaces()<<"\n";
534 di<< "Source Shells\t: "<<cnt.NbSourceShells()<<"\n";
535 di<< "Source Solids\t: "<<cnt.NbSourceSolids()<<"\n";
536 di<< "Source Wires in GS\t: "<<cnt.NbSourceWires()<<"\n";
537 di<< "Source Edges in GS\t: "<<cnt.NbSourceEdges()<<"\n";
538
539 return 1;
540}
541
542static Standard_Integer dumpassembly
543 (Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char** /*argv*/)
544{
545 Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
546 Handle(IFSelect_WorkSession) WS = pilot->Session();
547 const Interface_Graph& graph = WS->Graph();
548
549 STEPSelections_AssemblyExplorer exp(graph);
550 exp.Dump(cout);
551 return 0;
552}
553
d402d481 554static Standard_Integer stepfileunits (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
555{
556
557 if( argc < 2)
558 {
559 cout<<"Error: Invalid number of parameters. Should be: getfileunits name_file"<<endl;
560 return 1;
561 }
562 STEPControl_Reader aStepReader;
563
564 IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
565 readstat = aStepReader.ReadFile (argv[1]);
566
567 if (readstat != IFSelect_RetDone) {
568
569 di<<"No model loaded"<<"\n";
570 return 1;
571 }
572
573 TColStd_SequenceOfAsciiString anUnitLengthNames;
574 TColStd_SequenceOfAsciiString anUnitAngleNames;
575 TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
576 aStepReader.FileUnits( anUnitLengthNames,anUnitAngleNames,anUnitSolidAngleNames);
577
302f96fb 578 Standard_Integer i =1;
d402d481 579 di<<"=====================================================\n";
580 di<<"LENTH Unit"<<"\n";
581 for( ; i <= anUnitLengthNames.Length() ; i++)
582 di<<anUnitLengthNames(i).ToCString()<<"\n";
583
584 di<<"=====================================================\n";
585 di<<"Angle Unit"<<"\n";
586 for( i =1 ; i <= anUnitAngleNames.Length() ; i++)
587 di<<anUnitAngleNames(i).ToCString()<<"\n";
588
589 di<<"=====================================================\n";
590 di<<"Solid Angle Unit"<<"\n";
591 for( i =1 ; i <= anUnitSolidAngleNames.Length() ; i++)
592 di<<anUnitSolidAngleNames(i).ToCString()<<"\n";
593
594 return 0;
595}
7fd59977 596// ######## COMMANDE stepwrite : teste le Writer #########
597
598void XSDRAWSTEP::InitCommands (Draw_Interpretor& theCommands)
599{
600 const char* g = "DE: STEP"; // Step transfer file commands
601 XSDRAWSTEP::Init();
602 XSDRAW::LoadDraw(theCommands);
603 theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
604 theCommands.Add("testwritestep", "testwritestep filename.stp shape", __FILE__, testwrite, g);
bc650d41 605 theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]",__FILE__, stepread, g);
7fd59977 606 theCommands.Add("testreadstep", "testreadstep [file] [name DRAW]", __FILE__, testread, g);
607 theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
608 theCommands.Add("countexpected","TEST", __FILE__, countexpected, g);
609 theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g);
610 theCommands.Add("readstep", "readstep [file]", __FILE__, readstep, g);
d402d481 611 theCommands.Add("stepfileunits" , "stepfileunits name_file", __FILE__, stepfileunits, g);
7fd59977 612}