0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IGESToBRep / IGESToBRep_Reader.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14//pdn 11.01.99 including <stdio.h> for compilation on NT
15//#70 rln 03.03.99 syntax correction
16// sln 11.06.2002 OCC448 : Initialize "read.onlyvisiable" parameter to control transfering invisiable sub entities which logicaly depend on the grouping entities
7fd59977 17
7fd59977 18#include <BRep_Builder.hxx>
19#include <BRepLib.hxx>
20#include <BRepTools_Modifier.hxx>
42cf5bc1 21#include <gp_Trsf.hxx>
22#include <IGESAppli.hxx>
23#include <IGESAppli_Protocol.hxx>
7fd59977 24#include <IGESData_FileProtocol.hxx>
25#include <IGESData_GlobalSection.hxx>
26#include <IGESData_IGESEntity.hxx>
42cf5bc1 27#include <IGESData_IGESModel.hxx>
28#include <IGESFile_Read.hxx>
7fd59977 29#include <IGESSolid.hxx>
30#include <IGESSolid_Protocol.hxx>
7fd59977 31#include <IGESToBRep.hxx>
32#include <IGESToBRep_Actor.hxx>
33#include <IGESToBRep_CurveAndSurface.hxx>
42cf5bc1 34#include <IGESToBRep_Reader.hxx>
35#include <Interface_Check.hxx>
36#include <Interface_CheckIterator.hxx>
37#include <Interface_CheckTool.hxx>
38#include <Interface_Macros.hxx>
39#include <Interface_ShareFlags.hxx>
40#include <Interface_Static.hxx>
41#include <Message_Messenger.hxx>
42#include <Message_Msg.hxx>
43#include <Message_ProgressSentry.hxx>
44#include <OSD_Timer.hxx>
45#include <ShapeAlgo.hxx>
46#include <ShapeAlgo_AlgoContainer.hxx>
7fd59977 47#include <ShapeExtend_Explorer.hxx>
48#include <ShapeFix_ShapeTolerance.hxx>
42cf5bc1 49#include <Standard_ErrorHandler.hxx>
50#include <Standard_Failure.hxx>
51#include <TopAbs.hxx>
52#include <TopoDS_Compound.hxx>
53#include <TopoDS_Shape.hxx>
7fd59977 54#include <Transfer_IteratorOfProcessForTransient.hxx>
42cf5bc1 55#include <Transfer_TransferOutput.hxx>
56#include <Transfer_TransientProcess.hxx>
7fd59977 57#include <TransferBRep.hxx>
58#include <TransferBRep_ShapeBinder.hxx>
59#include <TransferBRep_ShapeListBinder.hxx>
60#include <XSAlgo.hxx>
61#include <XSAlgo_AlgoContainer.hxx>
62
42cf5bc1 63#include <stdio.h>
64//#include <ShapeCustom.hxx>
57c28b61 65#ifdef _MSC_VER
7fd59977 66#include <stdlib.h>
67#else
68#include <errno.h>
69#endif
70//extern int errno;
71
72static Handle(IGESData_FileProtocol) protocol;
73
74
75//=======================================================================
76//function : IGESToBRep_Reader
77//purpose :
78//=======================================================================
79 IGESToBRep_Reader::IGESToBRep_Reader ()
80{
81 theDone = Standard_False;
82 if (protocol.IsNull()) {
83 IGESAppli::Init(); IGESSolid::Init();
84 protocol = new IGESData_FileProtocol;
85 protocol->Add(IGESAppli::Protocol());
86 protocol->Add(IGESSolid::Protocol());
87 }
88 theActor = new IGESToBRep_Actor;
89 theProc = new Transfer_TransientProcess;
90}
91
92
93//=======================================================================
94//function : LoadFile
95//purpose : loads a Model from a file
96//=======================================================================
97
98Standard_Integer IGESToBRep_Reader::LoadFile (const Standard_CString filename)
99{
100 if ( theProc.IsNull() )
101 theProc = new Transfer_TransientProcess;
102 Handle(Message_Messenger) TF = theProc->Messenger();
103
104 // Message for Diagnostic file.
105 Message_Msg msg2000("IGES_2000");
106 msg2000.Arg(filename);
107 TF->Send (msg2000, Message_Info);
108 //Message_Msg msg2001("IGES_2001"); // Date
109 Message_Msg msg2005("IGES_2005");
110 msg2005.Arg(theProc->TraceLevel());
111 TF->Send (msg2005, Message_Info);
112 /////////////////////////////////////////////////////////
113 Handle(IGESData_IGESModel) model = new IGESData_IGESModel;
114
115 OSD_Timer c; c.Reset(); c.Start();
116 char *pfilename=(char *)filename;
117 Standard_Integer StatusFile = IGESFile_Read(pfilename,model,protocol);
118 if (StatusFile != 0) {
119 // Sending of message : IGES file opening error
120 Message_Msg Msg2("XSTEP_2");
121 TF->Send (Msg2, Message_Info);
122 //Message_Msg Msg3("XSTEP_3");
123 //Message_Msg Msg4("XSTEP_4");
124 //Message_Msg Msg5("XSTEP_5");
125 //Message_Msg Msg6("XSTEP_6");
126 //Message_Msg Msg7("XSTEP_7");
127 // Reasons of the file opening error
128 switch(errno)
129 {
130 case 2 : // Sending of message : No such file or directory
131 {
132 Message_Msg Msg3("XSTEP_3");
133 TF->Send (Msg3, Message_Info);
134 }
135 break;
136 case 12 : // Sending of message : Not enough space
137 {
138 Message_Msg Msg4("XSTEP_4");
139 TF->Send (Msg4, Message_Info);
140 }
141 break;
142 case 13 : // Sending of message : Permission Denied
143 {
144 Message_Msg Msg5("XSTEP_5");
145 TF->Send (Msg5, Message_Info);
146 }
147 break;
148 case 24 : // Sending of message : Too many open files
149 {
150 Message_Msg Msg6("XSTEP_6");
151 TF->Send (Msg6, Message_Info);
152 }
153 break;
154 default : // Sending of message : No determined
155 {
156 Message_Msg Msg7("XSTEP_7");
157 TF->Send (Msg7, Message_Info);
158 }
159 break;
160 }
161 }
162
163 Message_Msg Msg8 ("XSTEP_8");
164 Message_Msg Msg25 ("XSTEP_25");
165 Message_Msg Msg26 ("XSTEP_26");
166 // Nb warning in global section.
167
168 Standard_Integer nbWarn = 0,nbFail = 0;
169 // Add the number of warning on enities :
170 Interface_CheckTool cht (model,protocol);
171 Interface_CheckIterator anIter = cht.CompleteCheckList();
172 for(anIter.Start(); anIter.More(); anIter.Next()) {
173 const Handle(Interface_Check) ach = anIter.Value();
174 nbWarn += ach->NbWarnings();
175 nbFail += ach->NbFails();
176 }
177// Messages nbWarn and nbFail;
178 Msg25.Arg(nbFail);
179 Msg26.Arg(nbWarn);
180 TF->Send (Msg25, Message_Info);
181 TF->Send (Msg26, Message_Info);
182
183 // Message fin de loading iGES file (elapsed time %s)
184 char t[20];
185 t[0]='\0';
186 Standard_Real second, cpu;
187 Standard_Integer minute, hour;
188 c.Show(second, minute, hour,cpu);
189 if (hour > 0)
91322f44 190 Sprintf(t,"%dh:%dm:%.2fs",hour,minute,second);
7fd59977 191 else if (minute > 0)
91322f44 192 Sprintf(t,"%dm:%.2fs",minute,second);
7fd59977 193 else
91322f44 194 Sprintf(t,"%.2fs",second);
7fd59977 195 // Sending of message : End of Loading
196 Msg8.Arg(t);
197 TF->Send (Msg8, Message_Info);
198
199 SetModel(model);
200 return StatusFile;
201}
202
203
204//=======================================================================
205//function : SetModel
206//purpose : Specifies a Model to work on
207//=======================================================================
208 void IGESToBRep_Reader::SetModel (const Handle(IGESData_IGESModel)& model)
209{
210 theModel = model;
211 theDone = Standard_False;
212 theShapes.Clear();
213 if ( theProc.IsNull() )
214 theProc = new Transfer_TransientProcess (theModel->NbEntities());
215 else
216 theProc->Clear();
217}
218
219
220//=======================================================================
221//function : Model
222//purpose : returns the Model to be worked on
223//=======================================================================
224 Handle(IGESData_IGESModel) IGESToBRep_Reader::Model () const
225 { return theModel; }
226
227
228//=======================================================================
229//function : SetTransientProcess
230//purpose : Specifies a TransferProcess
231//=======================================================================
232 void IGESToBRep_Reader::SetTransientProcess
233 (const Handle(Transfer_TransientProcess)& TP)
234 { theProc = TP; }
235
236//=======================================================================
237//function : TransientProcess
238//purpose : Returns the TransferProcess
239//=======================================================================
240 Handle(Transfer_TransientProcess) IGESToBRep_Reader::TransientProcess () const
241 { return theProc; }
242
243//=======================================================================
244//function : Actor
245//purpose : returns theActor
246//=======================================================================
247 Handle(IGESToBRep_Actor) IGESToBRep_Reader::Actor () const
248 { return theActor; }
249
250
251//=======================================================================
252//function : Clear
253//purpose : Clears the result and Done status
254//=======================================================================
255 void IGESToBRep_Reader::Clear ()
256{
257 theDone = Standard_False;
258 theShapes.Clear();
259}
260
261
262//=======================================================================
263//function : Check
264//purpose : Checks the Model
265//=======================================================================
266 Standard_Boolean IGESToBRep_Reader::Check
267 (const Standard_Boolean withprint) const
268{
269 Interface_CheckTool cht (theModel,protocol);
270 Interface_CheckIterator chl = cht.CompleteCheckList();
0ebe5b0a 271 if (withprint
272 && !theProc.IsNull()
273 && !theProc->Messenger().IsNull())
274 {
275 Message_Messenger::StreamBuffer aBuffer = theProc->Messenger()->SendInfo();
276 cht.Print(chl, aBuffer);
277 }
7fd59977 278 return chl.IsEmpty(Standard_True);
279}
280
281
282//=======================================================================
283//function : IsDone
284//purpose : returns True if the last transfert was a success
285//=======================================================================
286 Standard_Boolean IGESToBRep_Reader::IsDone () const
287 { return theDone; }
288
289
290//=======================================================================
291//function : EncodeRegul
292//purpose : INTERNAL to encode regularity on edges
293//=======================================================================
294
295static Standard_Boolean EncodeRegul (const TopoDS_Shape& sh)
296{
297 Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle");
298 if (sh.IsNull()) return Standard_True;
299 if (tolang <= 0) return Standard_True;
300 try {
301 OCC_CATCH_SIGNALS
302 BRepLib::EncodeRegularity (sh,tolang);
303 }
a738b534 304 catch(Standard_Failure const&) {
7fd59977 305 return Standard_False;
306 }
307 return Standard_True;
308}
309
310//=======================================================================
311//function : UpdateMap
312//purpose : Updates the correspondence map (Transfer_TransientProcess),
313// setting as translation results, the shapes received after
314// modification by modifier (BRepTools_Modifier)
315//warning : BRepTools_Modifier raises exception when it cannot find input
316// shape in its internal list
317//=======================================================================
318
319// coment as unused PTV 18.09.2000
320// static void UpdateMap (const Handle(Transfer_TransientProcess)& map,
321// const BRepTools_Modifier& modifier)
322// {
323// Transfer_IteratorOfProcessForTransient iterator = map->CompleteResult(Standard_True);
324// for (iterator.Start(); iterator.More(); iterator.Next()) {
325// const Handle(Transfer_Binder) binder = iterator.Value();
326// try { //to avoid exception in BRepTools_Modifier
327// OCC_CATCH_SIGNALS
328// if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeBinder))) {
329// DeclareAndCast(TransferBRep_ShapeBinder, shapebinder, binder);
330// if (shapebinder->HasResult()) {
331// TopoDS_Shape result = shapebinder->Result();
332// TopoDS_Shape modified = modifier.ModifiedShape (result);
333// if (shapebinder->Status() != Transfer_StatusUsed) //to avoid exception
334// shapebinder->SetResult (modified);
335// }
336// }
337// else if (binder->IsKind (STANDARD_TYPE (TransferBRep_ShapeListBinder))) {
338// DeclareAndCast(TransferBRep_ShapeListBinder, shapelistbinder, binder);
339// for (Standard_Integer i = 1; i <= shapelistbinder->NbShapes(); i++) {
340// TopoDS_Shape result = shapelistbinder->Shape (i);
341// TopoDS_Shape modified = modifier.ModifiedShape (result);
342// shapelistbinder->SetResult (i, modified);
343// }
344// }
345// }
346// catch(Standard_Failure) {
347// continue;
348// }
349// }
350// }
351
352//=======================================================================
353//function : TrimTolerances
354//purpose : Trims tolerances of the shape according to static parameters
355//
356//=======================================================================
357
358static void TrimTolerances (const TopoDS_Shape& shape,
359 const Standard_Real tol)
360{
361 if( Interface_Static::IVal("read.maxprecision.mode")==1) {
362 ShapeFix_ShapeTolerance SFST;
363 SFST.LimitTolerance (shape, 0, Max(tol,Interface_Static::RVal ("read.maxprecision.val")));
364 }
365}
366
367//=======================================================================
368//function : TransferRoots
369//purpose : Transfers all Roots Entities
370//=======================================================================
371void IGESToBRep_Reader::TransferRoots (const Standard_Boolean onlyvisible)
372{
373 if (theModel.IsNull() || theProc.IsNull()) return;
374
375 Handle(Message_Messenger) TF = theProc->Messenger();
376 // Declaration of messages.
377 Message_Msg msg2030("IGES_2030");
378 TF->Send (msg2030, Message_Info);
379 Message_Msg msg2065("IGES_2065");
380 OSD_Timer c; c.Reset(); c.Start(); // Initialisation du CHRONO
381 theDone = Standard_False;
382 theShapes.Clear();
383
384 Standard_Integer level = theProc->TraceLevel();
385 theProc->SetErrorHandle(Standard_True);
386 theProc->SetRootManagement(Standard_True);
387// PrepareTransfer(); -> protocol, actor
388 theActor->SetModel(theModel);
389 Standard_Integer continuity = Interface_Static::IVal("read.iges.bspline.continuity");
390 theActor->SetContinuity (continuity);
391 theProc->SetModel (theModel);
392 theProc->SetActor (theActor);
393 Transfer_TransferOutput TP (theProc,theModel);
394
543a9964 395 const Handle(Interface_Protocol) aProtocol = protocol; // to avoid ambiguity
396 Interface_ShareFlags SH (theModel, aProtocol);
7fd59977 397 Standard_Integer nb = theModel->NbEntities();
398 ShapeExtend_Explorer SBE;
399
400
401 Standard_Integer precisionMode = Interface_Static::IVal("read.precision.mode");
402 Message_Msg msg2035("IGES_2035");
403 msg2035.Arg(precisionMode);
404 TF->Send (msg2035, Message_Info);
405 if (precisionMode==1) {
406 Message_Msg msg2040("IGES_2040");
407 msg2040.Arg(Interface_Static::RVal("read.precision.val"));//#70 rln 03.03.99
408 TF->Send (msg2040, Message_Info);
409 }
410 Message_Msg msg2045("IGES_2045");
411 msg2045.Arg(continuity);
412 TF->Send (msg2045, Message_Info);
413 Message_Msg msg2050("IGES_2050");
414 msg2050.Arg(Interface_Static::IVal("read.surfacecurve.mode"));
415 TF->Send (msg2050, Message_Info);
416
417 // sln 11.06.2002 OCC448
418 Interface_Static::SetIVal("read.iges.onlyvisible",onlyvisible);
419
420 Message_ProgressSentry PS ( theProc->GetProgress(), "Root", 0, nb, 1 );
421 for (Standard_Integer i = 1; i <= nb && PS.More(); i++, PS.Next()) {
422 Handle(IGESData_IGESEntity) ent = theModel->Entity(i);
423 if ( SH.IsShared(ent) || ! theActor->Recognize (ent) ) continue;
424 if (level > 0) {
425 Message_Msg msg2070("IGES_2070");
426 msg2070.Arg(2*i-1);
427 msg2070.Arg(ent->TypeNumber());
428 TF->Send (msg2070, Message_Info);
429 }
430 // on ajoute un traitement pour ne prendre que les entites visibles
431 if ( ! onlyvisible || ent->BlankStatus() == 0 ) {
432 TopoDS_Shape shape;
433 theDone = Standard_True;
434 try {
435 OCC_CATCH_SIGNALS
436 TP.Transfer(ent);
437 shape = TransferBRep::ShapeResult (theProc,ent);
438 }
a738b534 439 catch(Standard_Failure const&) {
7fd59977 440 Message_Msg msg1005("IGES_1005");
441 TF->Send (msg1005, Message_Info);
442 continue;
443 }
444 if (shape.IsNull()) {
445 Message_Msg msg2076("IGES_2076");
446 TF->Send (msg2076, Message_Info);
447 }
448 else {
449 if (SBE.ShapeType(shape,Standard_True) != TopAbs_SHAPE) {
450 if (!shape.IsNull()) {
451 EncodeRegul (shape);
452 //#74 rln 03.03.99 S4135
453 TrimTolerances (shape, theActor->UsedTolerance());
454 theShapes.Append(shape);
455 }
456 }
457 }
458 }
459 }
460 char t [20];
461 t[0]='\0';
462 Standard_Real second, cpu;
463 Standard_Integer minute, hour;
464 c.Show(second, minute, hour,cpu);
465 if (hour > 0)
91322f44 466 Sprintf(t,"%dh:%dm:%.2fs",hour,minute,second);
7fd59977 467 else if (minute > 0)
91322f44 468 Sprintf(t,"%dm:%.2fs",minute,second);
7fd59977 469 else
91322f44 470 Sprintf(t,"%.2fs",second);
7fd59977 471 // Sending of message : End of Loading
472 msg2065.Arg(t);
473 TF->Send (msg2065, Message_Info);
474}
475
476
477//=======================================================================
478//function : Transfer
479//purpose : Transfers an Entity given
480//=======================================================================
481Standard_Boolean IGESToBRep_Reader::Transfer(const Standard_Integer num)
482{
483 Handle(Message_Messenger) TF = theProc->Messenger();
484 theDone = Standard_False;
485 if (theModel.IsNull()) {
486 Message_Msg msg2031("IGES_2031");
487 TF->Send (msg2031, Message_Info);
488 return Standard_False;
489 }
490 if (num <= 0 || num > theModel->NbEntities()) {
491 Message_Msg msg2032("IGES_2032");
492 msg2032.Arg(num);
493 TF->Send (msg2032, Message_Info);
494 return Standard_False;
495 }
496 // declaration of messages
497 Message_Msg msg2030("IGES_2030");
498 TF->Send (msg2030, Message_Info);
499 Message_Msg msg2065("IGES_2065");
500 OSD_Timer c; c.Reset(); c.Start(); // Initialisation du CHRONO
501
502 Handle(IGESData_IGESEntity) ent = theModel->Entity(num);
503
504 Message_ProgressSentry PS ( theProc->GetProgress(), "OneEnt", 0, 1, 1 ); //skl
505
506 XSAlgo::AlgoContainer()->PrepareForTransfer();
507 IGESToBRep_CurveAndSurface CAS;
508 CAS.SetModel(theModel);
509 Standard_Real eps;
510 Standard_Integer Ival = Interface_Static::IVal("read.precision.mode");
511 Message_Msg msg2035("IGES_2035");
512 msg2035.Arg(Ival);
513 TF->Send (msg2035, Message_Info);
514 if ( Ival == 0)
515 eps = theModel->GlobalSection().Resolution();
516 else {
517 //mjm : modif du 19/12/97 pour prise en compte effective du parametre
518 eps = Interface_Static::RVal("read.precision.val");
519 Message_Msg msg2040("IGES_2040");
520 msg2040.Arg(eps);//#70 rln 03.03.99
521 TF->Send (msg2040, Message_Info);
522
523 }
524 Ival = Interface_Static::IVal("read.iges.bspline.approxd1.mode");
525 CAS.SetModeApprox ( (Ival > 0) );
526 Message_Msg msg2045("IGES_2045");
527 Ival = Interface_Static::IVal("read.iges.bspline.continuity");
528 msg2045.Arg(Ival);
529 TF->Send (msg2045, Message_Info);
530 CAS.SetContinuity(Ival);
531 Message_Msg msg2050("IGES_2050");
532 Ival = Interface_Static::IVal("read.surfacecurve.mode");
533 msg2050.Arg(Ival);
534 TF->Send (msg2050, Message_Info);
535 CAS.SetSurfaceCurve (Ival);
536
537 if (eps > 1.E-08) CAS.SetEpsGeom(eps);
538 CAS.SetTransferProcess(theProc);
539
540 Standard_Boolean exceptionRaised = Standard_False;
541 TopoDS_Shape shape;
542 Standard_Integer nbTPitems = theProc->NbMapped();
543 {
544 try {
545 OCC_CATCH_SIGNALS
546 shape = CAS.TransferGeometry (ent);
547 }
a738b534 548 catch(Standard_Failure const&) {
7fd59977 549 Message_Msg msg1015("IGES_1015");
550 TF->Send (msg1015, Message_Info);
551 exceptionRaised = Standard_True;
552 }
553 }
554 if (!exceptionRaised) {
555 // fixing shape
556// shape = XSAlgo::AlgoContainer()->PerformFixShape ( shape, theProc, eps*CAS.GetUnitFactor(), CAS.GetMaxTol() );
557
558 Handle(Standard_Transient) info;
559 shape = XSAlgo::AlgoContainer()->ProcessShape( shape, eps*CAS.GetUnitFactor(), CAS.GetMaxTol(),
560 "read.iges.resource.name",
b485ee79
KD
561 "read.iges.sequence", info,
562 theProc->GetProgress() );
7fd59977 563 XSAlgo::AlgoContainer()->MergeTransferInfo(theProc, info, nbTPitems);
564
565 ShapeExtend_Explorer SBE;
566 if (SBE.ShapeType (shape,Standard_True) != TopAbs_SHAPE) {
567 TransferBRep::SetShapeResult (theProc,ent,shape);
568 theProc->SetRoot (ent);
569 if (!shape.IsNull()) {
570 theDone = Standard_True;
571 EncodeRegul (shape);
572 //#74 rln 03.03.99 S4135
573 TrimTolerances (shape, CAS.GetMaxTol());
574 theShapes.Append(shape);
575 }
576 }
577 }
578
579 PS.Relieve(); //skl
580
581 char t [20];
582 t[0]='\0';
583 Standard_Real second, cpu;
584 Standard_Integer minute, hour;
585 c.Show(second, minute, hour,cpu);
586 if (hour > 0)
91322f44 587 Sprintf(t,"%dh:%dm:%.2fs",hour,minute,second);
7fd59977 588 else if (minute > 0)
91322f44 589 Sprintf(t,"%dm:%.2fs",minute,second);
7fd59977 590 else
91322f44 591 Sprintf(t,"%.2fs",second);
7fd59977 592 // Sending of message : End of Loading
593 msg2065.Arg(t);
594 TF->Send (msg2065, Message_Info);
595 return Standard_True;
596}
597
598
599//=======================================================================
600//function : UsedTolerance
601//purpose : Returns the used tolerance (input)
602//=======================================================================
603 Standard_Real IGESToBRep_Reader::UsedTolerance () const
604 { return theActor->UsedTolerance(); }
605
606//=======================================================================
607//function : NbShapes
608//purpose : Returns the count of produced Shapes
609//=======================================================================
610 Standard_Integer IGESToBRep_Reader::NbShapes () const
611 { return theShapes.Length(); }
612
613
614//=======================================================================
615//function : Shape
616//purpose : Returns a Shape given its rank
617//=======================================================================
618 TopoDS_Shape IGESToBRep_Reader::Shape (const Standard_Integer num) const
619{
620 TopoDS_Shape res;
621 if (num > 0 && num <= theShapes.Length()) res = theShapes.Value(num);
622 return res;
623}
624
625
626//=======================================================================
627//function : OneShape
628//purpose : Returns a unique Shape
629//=======================================================================
630 TopoDS_Shape IGESToBRep_Reader::OneShape () const
631{
632 TopoDS_Shape res;
633 Standard_Integer nb = theShapes.Length();
634 if (nb == 0) return res;
635 else if (nb == 1) return theShapes.Value(1);
636 else {
637 TopoDS_Compound C;
638 BRep_Builder B;
639 B.MakeCompound(C);
640 for (Standard_Integer i = 1; i <= nb; i ++) B.Add (C,theShapes.Value(i));
641 return C;
642 }
643}