0022898: IGES import fails in german environment
[occt.git] / src / TopTools / TopTools_ShapeSet.cxx
1 // Created on: 1993-07-02
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 // Modified:    02 Nov 2000: BUC60769. JMB, PTV.  In order to be able to read BRep 
23 //              is run, we need the following modifications.
24 //              On Unix platforms:
25 //              ------------------
26 //                In method Read(Standard_IStream &IS), during the version 
27 //                authentification we cut last '\r' in the line (which will
28 //                be present if file is in DOS coding)
29
30 #include <TopTools_ShapeSet.ixx>
31
32 #include <TopoDS_Iterator.hxx>
33 #include <TopoDS_Shape.hxx>
34 #include <locale.h>
35 #include <string.h>
36
37 #include <Message_ProgressSentry.hxx>
38
39 const char* Version  = "CASCADE Topology V1, (c) Matra-Datavision";
40 const char* Version2 = "CASCADE Topology V2, (c) Matra-Datavision";
41
42 //=======================================================================
43 //function : TopTools_ShapeSet
44 //purpose  : 
45 //=======================================================================
46
47 TopTools_ShapeSet::TopTools_ShapeSet() : myFormatNb(1)
48 {
49 }
50
51 void TopTools_ShapeSet::Delete()
52 {}
53
54 //=======================================================================
55 //function : SetFormatNb
56 //purpose  : 
57 //=======================================================================
58 void TopTools_ShapeSet::SetFormatNb(const Standard_Integer theFormatNb)
59 {
60   myFormatNb = theFormatNb;
61 }
62
63 //=======================================================================
64 //function : FormatNb
65 //purpose  : 
66 //=======================================================================
67 Standard_Integer TopTools_ShapeSet::FormatNb() const
68 {
69   return myFormatNb;
70 }
71
72 //=======================================================================
73 //function : Clear
74 //purpose  : 
75 //=======================================================================
76
77 void  TopTools_ShapeSet::Clear()
78 {
79   myShapes.Clear();
80   myLocations.Clear();
81 }
82
83
84 //=======================================================================
85 //function : Add
86 //purpose  : 
87 //=======================================================================
88
89 Standard_Integer  TopTools_ShapeSet::Add(const TopoDS_Shape& S)
90 {
91   if (S.IsNull()) return 0;
92   myLocations.Add(S.Location());
93   TopoDS_Shape S2 = S;
94   S2.Location(TopLoc_Location());
95   Standard_Integer index = myShapes.FindIndex(S2);
96   if (index == 0) {
97     AddGeometry(S2);
98
99     for (TopoDS_Iterator its(S2,Standard_False,Standard_False);
100          its.More(); its.Next())
101       Add(its.Value());
102     index = myShapes.Add(S2);
103   }
104   return index;
105 }
106
107
108 //=======================================================================
109 //function : Shape
110 //purpose  : 
111 //=======================================================================
112
113 const TopoDS_Shape&  TopTools_ShapeSet::Shape(const Standard_Integer I)const 
114 {
115   return myShapes(I);
116 }
117
118 //=======================================================================
119 //function : Index
120 //purpose  : 
121 //=======================================================================
122
123 Standard_Integer TopTools_ShapeSet::Index(const TopoDS_Shape& S) const
124 {
125   return myShapes.FindIndex(S);
126 }
127
128 //=======================================================================
129 //function : Locations
130 //purpose  : 
131 //=======================================================================
132
133 const TopTools_LocationSet&  TopTools_ShapeSet::Locations()const 
134 {
135   return myLocations;
136 }
137
138
139 //=======================================================================
140 //function : ChangeLocations
141 //purpose  : 
142 //=======================================================================
143
144 TopTools_LocationSet&  TopTools_ShapeSet::ChangeLocations()
145 {
146   return myLocations;
147 }
148
149 //=======================================================================
150 //function : PrintShapeEnum
151 //purpose  : 
152 //=======================================================================
153
154 static void PrintShapeEnum(const TopAbs_ShapeEnum T, 
155                            Standard_OStream& S, 
156                            Standard_Boolean C)
157 {
158   switch(T) {
159     
160   case TopAbs_VERTEX :
161     if (C) S << "Ve"; else S << "VERTEX   ";
162     break;
163     
164   case TopAbs_EDGE :
165     if (C) S << "Ed"; else S << "EDGE     ";
166     break;
167     
168   case TopAbs_WIRE :
169     if (C) S << "Wi"; else S << "WIRE     ";
170     break;
171     
172   case TopAbs_FACE :
173     if (C) S << "Fa"; else S << "FACE     ";
174     break;
175     
176   case TopAbs_SHELL :
177     if (C) S << "Sh"; else S << "SHELL    ";
178     break;
179     
180   case TopAbs_SOLID :
181     if (C) S << "So"; else S << "SOLID    ";
182     break;
183     
184   case TopAbs_COMPSOLID :
185     if (C) S << "CS"; else S << "COMPSOLID";
186     break;
187     
188   case TopAbs_COMPOUND :
189     if (C) S << "Co"; else S << "COMPOUND ";
190     break;
191     
192   case TopAbs_SHAPE :
193     if (C) S << "Sp"; else S << "SHAPE";
194     break;
195   }
196 }
197
198 //=======================================================================
199 //function : PrintOrientation
200 //purpose  : 
201 //=======================================================================
202
203 static void PrintOrientation(const TopAbs_Orientation O, 
204                              Standard_OStream& S, 
205                              Standard_Boolean C)
206 {
207   switch(O) {
208     
209   case TopAbs_FORWARD :
210     if (C) S << "+"; else S << "FORWARD";
211     break;
212     
213   case TopAbs_REVERSED :
214     if (C) S << "-"; else S << "REVERSED";
215     break;
216     
217   case TopAbs_INTERNAL :
218     if (C) S << "i"; else S << "INTERNAL";
219     break;
220     
221   case TopAbs_EXTERNAL :
222     if (C) S << "e"; else S << "EXTERNAL";
223     break;
224   }
225 }
226
227 //=======================================================================
228 //function : DumpExtent 
229 //purpose  : Dump number of shapes.
230 //=======================================================================
231
232 Standard_OStream& TopTools_ShapeSet::DumpExtent(Standard_OStream& OS)const 
233 {
234
235  Standard_Integer nbVERTEX = 0;
236  Standard_Integer nbEDGE = 0;
237  Standard_Integer nbWIRE = 0;
238  Standard_Integer nbFACE = 0;
239  Standard_Integer nbSHELL = 0;
240  Standard_Integer nbSOLID = 0;
241  Standard_Integer nbCOMPSOLID = 0;
242  Standard_Integer nbCOMPOUND = 0;
243  Standard_Integer nbSHAPE = myShapes.Extent();
244
245  for (Standard_Integer i = 1; i <= nbSHAPE; i++) {
246
247    switch(myShapes(i).ShapeType()) {
248     
249    case TopAbs_VERTEX :
250      nbVERTEX++;
251      break;
252      
253    case TopAbs_EDGE :
254      nbEDGE++;
255      break;
256      
257    case TopAbs_WIRE :
258      nbWIRE++;
259      break;
260      
261    case TopAbs_FACE :
262      nbFACE++;
263      break;
264      
265    case TopAbs_SHELL :
266      nbSHELL++;
267      break;
268      
269    case TopAbs_SOLID :
270      nbSOLID++;
271      break;
272      
273    case TopAbs_COMPSOLID :
274      nbCOMPSOLID++;
275      break;
276      
277    case TopAbs_COMPOUND :
278      nbCOMPOUND++;
279      break;
280      
281    case TopAbs_SHAPE :
282      break;
283    }
284  }
285
286  
287  OS << " VERTEX    : " << nbVERTEX << "\n";
288  OS << " EDGE      : " << nbEDGE << "\n";
289  OS << " WIRE      : " << nbWIRE << "\n";
290  OS << " FACE      : " << nbFACE << "\n";
291  OS << " SHELL     : " << nbSHELL << "\n";
292  OS << " SOLID     : " << nbSOLID << "\n";
293  OS << " COMPSOLID : " << nbCOMPSOLID << "\n";
294  OS << " COMPOUND  : " << nbCOMPOUND << "\n";
295  OS << " SHAPE     : " << nbSHAPE << "\n";
296
297  return OS;
298 }
299
300 //=======================================================================
301 //function : DumpExtent 
302 //purpose  : Dump number of shapes.
303 //=======================================================================
304
305 void TopTools_ShapeSet::DumpExtent(TCollection_AsciiString& S)const 
306 {
307
308  Standard_Integer nbVERTEX = 0;
309  Standard_Integer nbEDGE = 0;
310  Standard_Integer nbWIRE = 0;
311  Standard_Integer nbFACE = 0;
312  Standard_Integer nbSHELL = 0;
313  Standard_Integer nbSOLID = 0;
314  Standard_Integer nbCOMPSOLID = 0;
315  Standard_Integer nbCOMPOUND = 0;
316  Standard_Integer nbSHAPE = myShapes.Extent();
317
318  for (Standard_Integer i = 1; i <= nbSHAPE; i++) {
319
320    switch(myShapes(i).ShapeType()) {
321     
322    case TopAbs_VERTEX :
323      nbVERTEX++;
324      break;
325      
326    case TopAbs_EDGE :
327      nbEDGE++;
328      break;
329      
330    case TopAbs_WIRE :
331      nbWIRE++;
332      break;
333      
334    case TopAbs_FACE :
335      nbFACE++;
336      break;
337      
338    case TopAbs_SHELL :
339      nbSHELL++;
340      break;
341      
342    case TopAbs_SOLID :
343      nbSOLID++;
344      break;
345      
346    case TopAbs_COMPSOLID :
347      nbCOMPSOLID++;
348      break;
349      
350    case TopAbs_COMPOUND :
351      nbCOMPOUND++;
352      break;
353      
354    case TopAbs_SHAPE :
355      break;
356    }
357  }
358
359  S = S + " VERTEX    : " + TCollection_AsciiString(nbVERTEX) + "\n";
360  S = S + " EDGE      : " + TCollection_AsciiString(nbEDGE) + "\n";
361  S = S + " WIRE      : " + TCollection_AsciiString(nbWIRE) + "\n";
362  S = S + " FACE      : " + TCollection_AsciiString(nbFACE) + "\n";
363  S = S + " SHELL     : " + TCollection_AsciiString(nbSHELL) + "\n";
364  S = S + " SOLID     : " + TCollection_AsciiString(nbSOLID) + "\n";
365  S = S + " COMPSOLID : " + TCollection_AsciiString(nbCOMPSOLID) + "\n";
366  S = S + " COMPOUND  : " + TCollection_AsciiString(nbCOMPOUND) + "\n";
367  S = S + " SHAPE     : " + TCollection_AsciiString(nbSHAPE) + "\n";
368 }
369
370
371 //=======================================================================
372 //function : Dump
373 //purpose  : 
374 //=======================================================================
375
376 void  TopTools_ShapeSet::Dump(Standard_OStream& OS)const 
377 {
378   //-----------------------------------------
379   // dump the shapes
380   //-----------------------------------------
381
382   Standard_Integer i, nbShapes = myShapes.Extent();
383   
384   OS << "\nDump of " << nbShapes << " TShapes";
385   OS << "\n\n-----------------\n\n";
386
387   OS << "Flags : Free, Modified, Checked, Orientable, Closed, Infinite, Convex";
388   OS << "\n\n";
389   
390   for (i = nbShapes; i >= 1; i--) {
391     
392     const TopoDS_Shape& S = myShapes(i);
393     OS << "TShape # " << nbShapes - i + 1 << " : ";
394     
395     // Type and flags
396
397     PrintShapeEnum(S.ShapeType(),OS,Standard_False);
398     OS << " ";
399     OS << (S.Free()       ? 1 : 0);
400     OS << (S.Modified()   ? 1 : 0);
401     OS << (S.Checked()    ? 1 : 0);
402     OS << (S.Orientable() ? 1 : 0);
403     OS << (S.Closed()     ? 1 : 0);
404     OS << (S.Infinite()   ? 1 : 0);
405     OS << (S.Convex()     ? 1 : 0);
406     OS << " " << (void*) &(*S.TShape()) <<"\n";
407
408     // sub-shapes
409     OS << "    ";
410     TopoDS_Iterator its(S,Standard_False,Standard_False);
411     while (its.More()) {
412       const TopoDS_Shape& sub = its.Value();
413       PrintOrientation(sub.Orientation(),OS,Standard_True);
414       OS<<nbShapes - myShapes.FindIndex(sub.Located(TopLoc_Location())) + 1;
415       if (!sub.Location().IsIdentity()) 
416         OS << "(L" << myLocations.Index(sub.Location()) << ")";
417       OS << " ";
418       its.Next();
419     }
420     OS << "\n";
421
422     // Geometry
423
424     DumpGeometry(S,OS);
425   }
426     
427   
428   //-----------------------------------------
429   // dump the geometry
430   //-----------------------------------------
431
432   DumpGeometry(OS);
433
434   //-----------------------------------------
435   // dump the locations
436   //-----------------------------------------
437
438   myLocations.Dump(OS);
439
440   OS << endl;
441 }
442
443
444 //=======================================================================
445 //function : Write
446 //purpose  : 
447 //=======================================================================
448
449 void  TopTools_ShapeSet::Write(Standard_OStream& OS)
450 {
451   // always use C locale for writing shapes
452   std::locale anOldLocale = OS.imbue (std::locale::classic());
453
454   // use 15-digit precision
455   std::streamsize prec = OS.precision(15);
456
457   // write the copyright
458   if (myFormatNb == 2)
459     OS << "\n" << Version2 << endl;
460   else
461     OS << "\n" << Version << endl;
462
463   //-----------------------------------------
464   // write the locations
465   //-----------------------------------------
466
467   if ( !myProgress.IsNull() ) 
468     myProgress->NewScope ( 10, "Locations" );
469   myLocations.SetProgress(myProgress);
470   myLocations.Write(OS);
471   if ( !myProgress.IsNull() ) {
472     myProgress->EndScope();
473     myProgress->Show();
474   }
475
476   if (!myProgress.IsNull() && myProgress->UserBreak()) {
477     OS << "Interrupted by the user"<<endl;
478     OS.imbue (anOldLocale);
479     return;
480   }
481
482   //-----------------------------------------
483   // write the geometry
484   //-----------------------------------------
485
486   if ( !myProgress.IsNull() ) 
487     myProgress->NewScope ( 75, "Geometry" );
488   WriteGeometry(OS);
489   if ( !myProgress.IsNull() ) {
490     myProgress->EndScope();
491     myProgress->Show();
492   }
493
494   //-----------------------------------------
495   // write the shapes
496   //-----------------------------------------
497
498   Standard_Integer i, nbShapes = myShapes.Extent();
499   
500   OS << "\nTShapes " << nbShapes << "\n";
501
502   // subshapes are written first
503   //OCC19559
504   if ( !myProgress.IsNull() ) 
505     myProgress->NewScope ( 15, "Shapes" );
506   Message_ProgressSentry PS(myProgress, "Shapes", 0, nbShapes, 1);
507
508   for (i = 1; i <= nbShapes && PS.More(); i++, PS.Next()) {
509     if ( !myProgress.IsNull() ) 
510       myProgress->Show();
511
512     const TopoDS_Shape& S = myShapes(i);
513     
514     // Type
515     PrintShapeEnum(S.ShapeType(),OS,Standard_True);
516     OS << "\n";
517
518     // Geometry
519     WriteGeometry(S,OS);
520
521     // Flags
522     OS << "\n";
523     OS << (S.Free()       ? 1 : 0);
524     OS << (S.Modified()   ? 1 : 0);
525     OS << (S.Checked()    ? 1 : 0);
526     OS << (S.Orientable() ? 1 : 0);
527     OS << (S.Closed()     ? 1 : 0);
528     OS << (S.Infinite()   ? 1 : 0);
529     OS << (S.Convex()     ? 1 : 0);
530     OS << "\n";
531
532     // sub-shapes
533
534     Standard_Integer l = 0;
535     TopoDS_Iterator its(S,Standard_False,Standard_False);
536     while (its.More()) {
537       Write(its.Value(),OS);
538       l++;
539       if (l == 10) {
540         OS << "\n";
541         l = 0;
542       }
543       its.Next();
544     }
545     Write(TopoDS_Shape(),OS); // Null shape to end the list
546     OS << "\n";
547   }
548   
549   OS << endl;
550   OS.precision(prec);
551   OS.imbue (anOldLocale);
552
553   PS.Relieve();
554   if (!myProgress.IsNull()) {
555     myProgress->EndScope();
556     myProgress->Show();
557     if (myProgress->UserBreak())
558       OS << "Interrupted by the user"<<endl;
559   }
560 }
561
562 //=======================================================================
563 //function : ReadShapeEnum
564 //purpose  : 
565 //=======================================================================
566
567 static TopAbs_ShapeEnum ReadShapeEnum(Standard_IStream& IS)
568 {
569   char buffer[255];
570   IS >> buffer;
571
572   switch (buffer[0]) {
573
574   case 'V' :
575     return TopAbs_VERTEX;
576
577   case 'E' :
578     return TopAbs_EDGE;
579
580   case 'W' :
581     return TopAbs_WIRE;
582
583   case 'F' :
584     return TopAbs_FACE;
585
586   case 'S' :
587     if (buffer[1] == 'h')
588       return TopAbs_SHELL;
589     else
590       return TopAbs_SOLID;
591
592   case 'C' :
593     if (buffer[1] == 'S')
594       return TopAbs_COMPSOLID;
595     else
596       return TopAbs_COMPOUND;
597
598   }
599   return TopAbs_COMPOUND;
600 }
601
602 //=======================================================================
603 //function : Read
604 //purpose  : 
605 //=======================================================================
606
607 void  TopTools_ShapeSet::Read(Standard_IStream& IS)
608 {
609   // always use C locale for reading shapes
610   std::locale anOldLocale = IS.imbue (std::locale::classic());
611
612   Clear();
613
614   // Check the version
615   char vers[101];
616   do {
617     IS.getline(vers,100,'\n');
618     // BUC60769 PTV 18.10.2000: remove possible '\r' at the end of the line
619     //Standard_Integer lv = strlen(vers);
620     //char *pm;
621     //if(pm = strchr(vers,'\r'))
622     //  *pm ='\0';
623     
624     for (Standard_Size lv = (strlen(vers)- 1); lv > 1 && (vers[lv] == '\r' || vers[lv] == '\n') ;lv--) 
625       vers[lv] = '\0';
626     
627   } while ( ! IS.fail() && strcmp(vers,Version) && strcmp(vers,Version2) );
628   if (IS.fail()) {
629     cout << "File was not written with this version of the topology"<<endl;
630     IS.imbue (anOldLocale);
631     return;
632   }
633   if (strcmp(vers,Version2) == 0) SetFormatNb(2);
634   else SetFormatNb(1);
635
636   //-----------------------------------------
637   // read the locations
638   //-----------------------------------------
639
640   //OCC19559
641   if (!myProgress.IsNull() && myProgress->UserBreak()) {
642     cout << "Interrupted by the user"<<endl;
643     // on remet le LC_NUMERIC a la precedente valeur
644     IS.imbue (anOldLocale);
645     return;
646   }
647   if ( !myProgress.IsNull() ) 
648     myProgress->NewScope ( 10, "Locations" );
649   myLocations.SetProgress(myProgress);
650   myLocations.Read(IS);
651   if ( !myProgress.IsNull() ) {
652     myProgress->EndScope();
653     myProgress->Show();
654   }
655   //OCC19559
656   if (!myProgress.IsNull() && myProgress->UserBreak()) {
657     cout << "Interrupted by the user"<<endl;
658     // on remet le LC_NUMERIC a la precedente valeur
659     IS.imbue (anOldLocale);
660     return;
661   }
662
663   //-----------------------------------------
664   // read the geometry
665   //-----------------------------------------
666   if ( !myProgress.IsNull() ) 
667     myProgress->NewScope ( 75, "Geometry" );
668   ReadGeometry(IS);
669   if ( !myProgress.IsNull() ) {
670     myProgress->EndScope();
671     myProgress->Show();
672   }
673
674   //-----------------------------------------
675   // read the shapes
676   //-----------------------------------------
677
678   char buffer[255];
679   IS >> buffer;
680   if (strcmp(buffer,"TShapes")) {
681     cout << "Not a TShape table"<<endl;
682     // on remet le LC_NUMERIC a la precedente valeur
683     IS.imbue (anOldLocale);
684     return;
685   }
686
687   Standard_Integer i, nbShapes;
688   IS >> nbShapes;
689
690   //OCC19559
691   if ( !myProgress.IsNull() ) 
692     myProgress->NewScope ( 15, "Shapes" );
693   Message_ProgressSentry PS(myProgress, "Shapes", 0, nbShapes, 1);
694   for (i = 1; i <= nbShapes && PS.More(); i++, PS.Next() ) {
695     if ( !myProgress.IsNull() ) 
696       myProgress->Show();
697     TopoDS_Shape S;
698     
699     //Read type and create empty shape.
700
701     TopAbs_ShapeEnum T = ReadShapeEnum(IS);
702     ReadGeometry(T,IS,S);
703     
704     // Set the flags
705     IS >> buffer;
706
707     // sub-shapes
708     TopoDS_Shape SS;
709     do {
710       Read(SS,IS,nbShapes);
711       if (!SS.IsNull())
712         AddShapes(S,SS);
713     } while(!SS.IsNull());
714
715     S.Free      (buffer[0] == '1');
716     S.Modified  (buffer[1] == '1');
717
718     if (myFormatNb == 2)
719       S.Checked   (buffer[2] == '1');
720     else
721       S.Checked   (Standard_False);     // force check at reading.. 
722
723     S.Orientable(buffer[3] == '1');
724     S.Closed    (buffer[4] == '1');
725     S.Infinite  (buffer[5] == '1');
726     S.Convex    (buffer[6] == '1');
727
728     // check
729
730     if (myFormatNb == 1)
731       Check(T,S);
732
733     myShapes.Add(S);
734   }
735   if (!myProgress.IsNull()) {
736     myProgress->EndScope();
737     myProgress->Show();
738   }
739
740   // on remet le LC_NUMERIC a la precedente valeur
741   IS.imbue (anOldLocale);
742 }
743
744 //=======================================================================
745 //function : Dump
746 //purpose  : 
747 //=======================================================================
748
749 void  TopTools_ShapeSet::Dump(const TopoDS_Shape& S,
750                               Standard_OStream& OS)const 
751 {
752   if (S.IsNull()) OS << "Null shape\n";
753   OS << "Shape : " << myShapes.FindIndex(S.Located(TopLoc_Location()));
754   OS << ", ";
755   PrintOrientation(S.Orientation(),OS,Standard_False);
756   if (!S.Location().IsIdentity())
757     OS <<", location : " << myLocations.Index(S.Location());
758   OS << "\n";
759 }
760
761
762 //=======================================================================
763 //function : Write
764 //purpose  : 
765 //=======================================================================
766
767 void  TopTools_ShapeSet::Write(const TopoDS_Shape& S, 
768                                Standard_OStream& OS)const 
769 {
770   if (S.IsNull()) OS << "*";
771   else {
772     PrintOrientation(S.Orientation(),OS,Standard_True);
773     OS << myShapes.Extent() - myShapes.FindIndex(S.Located(TopLoc_Location())) + 1;
774     OS << " " << myLocations.Index(S.Location()) << " ";
775   }    
776 }
777
778 //=======================================================================
779 //function : Read
780 //purpose  : 
781 //=======================================================================
782
783 void  TopTools_ShapeSet::Read(TopoDS_Shape& S, 
784                               Standard_IStream& IS)const 
785 {
786   Read(S,IS,myShapes.Extent());
787 }
788
789 //=======================================================================
790 //function : Read
791 //purpose  : 
792 //=======================================================================
793
794 void  TopTools_ShapeSet::Read(TopoDS_Shape& S, 
795                               Standard_IStream& IS,
796                               const Standard_Integer nbshapes)const 
797 {
798   if(nbshapes < 1)
799   {
800     S = TopoDS_Shape();
801     return;
802   }
803   char buffer[255];
804   IS >> buffer;
805   if (buffer[0] == '*') 
806     S = TopoDS_Shape();
807   else {
808     S = myShapes(nbshapes - atoi(buffer+1) + 1);
809     switch (buffer[0]) {
810
811     case '+' :
812       S.Orientation(TopAbs_FORWARD);
813       break;
814
815     case '-' :
816       S.Orientation(TopAbs_REVERSED);
817       break;
818
819     case 'i' :
820       S.Orientation(TopAbs_INTERNAL);
821       break;
822
823     case 'e' :
824       S.Orientation(TopAbs_EXTERNAL);
825       break;
826     }
827
828     Standard_Integer l;
829     IS >> l;
830     S.Location(myLocations.Location(l));
831   }
832 }
833
834 //=======================================================================
835 //function : AddGeometry
836 //purpose  : 
837 //=======================================================================
838
839 void TopTools_ShapeSet::AddGeometry(const TopoDS_Shape&)
840 {
841 }
842
843 //=======================================================================
844 //function : DumpGeometry
845 //purpose  : 
846 //=======================================================================
847
848 void  TopTools_ShapeSet::DumpGeometry(Standard_OStream&) const 
849 {
850 }
851
852
853 //=======================================================================
854 //function : WriteGeometry
855 //purpose  : 
856 //=======================================================================
857
858 void  TopTools_ShapeSet::WriteGeometry(Standard_OStream&) 
859 {
860 }
861
862
863 //=======================================================================
864 //function : ReadGeometry
865 //purpose  : 
866 //=======================================================================
867
868 void  TopTools_ShapeSet::ReadGeometry(Standard_IStream&)
869 {
870 }
871
872
873 //=======================================================================
874 //function : DumpGeometry
875 //purpose  : 
876 //=======================================================================
877
878 void  TopTools_ShapeSet::DumpGeometry(const TopoDS_Shape&, 
879                                       Standard_OStream&)const 
880 {
881 }
882
883
884 //=======================================================================
885 //function : WriteGeometry
886 //purpose  : 
887 //=======================================================================
888
889 void  TopTools_ShapeSet::WriteGeometry(const TopoDS_Shape&, 
890                                        Standard_OStream&)const 
891 {
892 }
893
894
895 //=======================================================================
896 //function : ReadGeometry
897 //purpose  : 
898 //=======================================================================
899
900 void  TopTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum,
901                                       Standard_IStream& ,
902                                       TopoDS_Shape&)
903 {
904 }
905
906
907
908
909 //=======================================================================
910 //function : AddShapes
911 //purpose  : 
912 //=======================================================================
913
914 void  TopTools_ShapeSet::AddShapes(TopoDS_Shape&,
915                                    const TopoDS_Shape&)
916 {
917 }
918
919
920
921 //=======================================================================
922 //function : Check
923 //purpose  : 
924 //=======================================================================
925
926 void  TopTools_ShapeSet::Check(const TopAbs_ShapeEnum,
927                                TopoDS_Shape&)
928 {
929 }
930
931 //=======================================================================
932 //function : NbShapes
933 //purpose  : 
934 //=======================================================================
935
936 Standard_Integer  TopTools_ShapeSet::NbShapes() const
937 {
938   return myShapes.Extent();
939 }
940
941 //=======================================================================
942 //function : GetProgress
943 //purpose  : 
944 //=======================================================================
945
946 Handle(Message_ProgressIndicator) TopTools_ShapeSet::GetProgress() const
947 {
948   return myProgress;
949 }
950
951 //=======================================================================
952 //function : SetProgress
953 //purpose  : 
954 //=======================================================================
955
956 void TopTools_ShapeSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
957 {
958   myProgress = PR;
959 }
960
961