0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / GeomTools / GeomTools_CurveSet.cxx
1 // Created on: 1993-07-19
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <Standard_Stream.hxx>
18 #include <GeomTools_CurveSet.ixx>
19 #include <GeomTools.hxx>
20 #include <GeomTools_UndefinedTypeHandler.hxx>
21
22 #include <Geom_Circle.hxx>
23 #include <Geom_Line.hxx>
24 #include <Geom_Ellipse.hxx>
25 #include <Geom_Parabola.hxx>
26 #include <Geom_Hyperbola.hxx>
27 #include <Geom_BezierCurve.hxx>
28 #include <Geom_BSplineCurve.hxx>
29 #include <Geom_TrimmedCurve.hxx>
30 #include <Geom_OffsetCurve.hxx>
31
32 #include <gp_Lin.hxx>
33 #include <gp_Circ.hxx>
34 #include <gp_Elips.hxx>
35 #include <gp_Parab.hxx>
36 #include <gp_Hypr.hxx>
37
38 #include <TColStd_Array1OfReal.hxx>
39 #include <TColStd_Array1OfInteger.hxx>
40 #include <TColgp_Array1OfPnt.hxx>
41 #include <Standard_Failure.hxx>
42 #include <Standard_ErrorHandler.hxx>
43 #include <Message_ProgressSentry.hxx>
44
45 #define LINE      1
46 #define CIRCLE    2
47 #define ELLIPSE   3
48 #define PARABOLA  4
49 #define HYPERBOLA 5
50 #define BEZIER    6
51 #define BSPLINE   7
52 #define TRIMMED   8
53 #define OFFSET    9
54
55 //=======================================================================
56 //function : GeomTools_CurveSet
57 //purpose  : 
58 //=======================================================================
59
60 GeomTools_CurveSet::GeomTools_CurveSet() 
61 {
62 }
63
64
65 //=======================================================================
66 //function : Clear
67 //purpose  : 
68 //=======================================================================
69
70 void  GeomTools_CurveSet::Clear()
71 {
72   myMap.Clear();
73 }
74
75
76 //=======================================================================
77 //function : Add
78 //purpose  : 
79 //=======================================================================
80
81 Standard_Integer  GeomTools_CurveSet::Add(const Handle(Geom_Curve)& C)
82 {
83   return  (C.IsNull()) ? 0 : myMap.Add(C);
84 }
85
86
87 //=======================================================================
88 //function : Curve
89 //purpose  : 
90 //=======================================================================
91
92 Handle(Geom_Curve)  GeomTools_CurveSet::Curve
93        (const Standard_Integer I)const 
94 {
95   if (I <= 0 || I > myMap.Extent())
96         return Handle(Geom_Curve)();
97   return Handle(Geom_Curve)::DownCast(myMap(I));
98 }
99
100
101 //=======================================================================
102 //function : Index
103 //purpose  : 
104 //=======================================================================
105
106 Standard_Integer  GeomTools_CurveSet::Index
107   (const Handle(Geom_Curve)& S)const 
108 {
109   return S.IsNull() ? 0 : myMap.FindIndex(S);
110 }
111
112
113 //=======================================================================
114 //function : Print
115 //purpose  : 
116 //=======================================================================
117
118 static void Print(const gp_Pnt P,
119                   Standard_OStream& OS,
120                   const Standard_Boolean compact)
121 {
122   OS << P.X();
123   if (!compact) OS << ",";
124   OS << " ";
125   OS << P.Y();
126   if (!compact) OS << ",";
127   OS << " ";
128   OS << P.Z();
129   OS << " ";
130 }
131
132 //=======================================================================
133 //function : Print
134 //purpose  : 
135 //=======================================================================
136
137 static void Print(const gp_Dir D,
138                   Standard_OStream& OS,
139                   const Standard_Boolean compact)
140 {
141   OS << D.X();
142   if (!compact) OS << ",";
143   OS << " ";
144   OS << D.Y();
145   if (!compact) OS << ",";
146   OS << " ";
147   OS << D.Z();
148   OS << " ";
149 }
150
151
152 //=======================================================================
153 //function : Print
154 //purpose  : 
155 //=======================================================================
156
157 static void Print(const Handle(Geom_Line)& L,
158                          Standard_OStream& OS,
159                          const Standard_Boolean compact)
160 {
161   if (compact)
162     OS << LINE << " ";
163   else
164     OS << "Line";
165
166   gp_Lin C = L->Lin();
167   if (!compact) OS << "\n  Origin :";
168   Print(C.Location(),OS,compact);
169   if (!compact) OS << "\n  Axis   :";
170   Print(C.Direction(),OS,compact);
171   if (!compact) OS << "\n";
172   OS << "\n";
173 }
174
175 //=======================================================================
176 //function : Print
177 //purpose  : 
178 //=======================================================================
179
180 static void Print(const Handle(Geom_Circle)& CC,
181                          Standard_OStream& OS,
182                          const Standard_Boolean compact)
183 {
184   if (compact)
185     OS << CIRCLE << " ";
186   else
187     OS << "Circle";
188
189   gp_Circ C = CC->Circ();
190   if (!compact) OS << "\n  Center :";
191   Print(C.Location(),OS,compact);
192   if (!compact) OS << "\n  Axis   :";
193   Print(C.Axis().Direction(),OS,compact);
194   if (!compact) OS << "\n  XAxis  :";
195   Print(C.XAxis().Direction(),OS,compact);
196   if (!compact) OS << "\n  YAxis  :";
197   Print(C.YAxis().Direction(),OS,compact);
198   if (!compact) OS << "\n  Radius :";
199   OS << C.Radius();
200   if (!compact) OS << "\n";
201   OS << "\n";
202 }
203
204 //=======================================================================
205 //function : Print
206 //purpose  : 
207 //=======================================================================
208
209 static void Print(const Handle(Geom_Ellipse)& E,
210                          Standard_OStream& OS,
211                          const Standard_Boolean compact)
212 {
213   if (compact)
214     OS << ELLIPSE << " ";
215   else
216     OS << "Ellipse";
217
218   gp_Elips C = E->Elips();
219   if (!compact) OS << "\n  Center :";
220   Print(C.Location(),OS,compact);
221   if (!compact) OS << "\n  Axis   :";
222   Print(C.Axis().Direction(),OS,compact);
223   if (!compact) OS << "\n  XAxis  :";
224   Print(C.XAxis().Direction(),OS,compact);
225   if (!compact) OS << "\n  YAxis  :";
226   Print(C.YAxis().Direction(),OS,compact);
227   if (!compact) OS << "\n  Radii  :";
228   OS << C.MajorRadius();
229   if (!compact) OS << ",";
230   OS << " ";
231   OS << C.MinorRadius();
232   if (!compact) OS << "\n";
233   OS << "\n";
234 }
235
236 //=======================================================================
237 //function : Print
238 //purpose  : 
239 //=======================================================================
240
241 static void Print(const Handle(Geom_Parabola)& P,
242                          Standard_OStream& OS,
243                          const Standard_Boolean compact)
244 {
245   if (compact)
246     OS << PARABOLA << " ";
247   else
248     OS << "Parabola";
249
250   gp_Parab C = P->Parab();
251   if (!compact) OS << "\n  Center :";
252   Print(C.Location(),OS,compact);
253   if (!compact) OS << "\n  Axis   :";
254   Print(C.Axis().Direction(),OS,compact);
255   if (!compact) OS << "\n  XAxis  :";
256   Print(C.XAxis().Direction(),OS,compact);
257   if (!compact) OS << "\n  YAxis  :";
258   Print(C.YAxis().Direction(),OS,compact);
259   if (!compact) OS << "\n  Focal  :";
260   OS << C.Focal();
261   if (!compact) OS << "\n";
262   OS << "\n";
263 }
264
265 //=======================================================================
266 //function : Print
267 //purpose  : 
268 //=======================================================================
269
270 static void Print(const Handle(Geom_Hyperbola)& H,
271                          Standard_OStream& OS,
272                          const Standard_Boolean compact)
273 {
274   if (compact)
275     OS << HYPERBOLA << " ";
276   else
277     OS << "Hyperbola";
278
279   gp_Hypr C = H->Hypr();
280   if (!compact) OS << "\n  Center :";
281   Print(C.Location(),OS,compact);
282   if (!compact) OS << "\n  Axis   :";
283   Print(C.Axis().Direction(),OS,compact);
284   if (!compact) OS << "\n  XAxis  :";
285   Print(C.XAxis().Direction(),OS,compact);
286   if (!compact) OS << "\n  YAxis  :";
287   Print(C.YAxis().Direction(),OS,compact);
288   if (!compact) OS << "\n  Radii  :";
289   OS << C.MajorRadius();
290   if (!compact) OS << ",";
291   OS << " ";
292   OS << C.MinorRadius();
293   if (!compact) OS << "\n";
294   OS << "\n";
295 }
296
297 //=======================================================================
298 //function : Print
299 //purpose  : 
300 //=======================================================================
301
302 static void Print(const Handle(Geom_BezierCurve)& B,
303                          Standard_OStream& OS,
304                          const Standard_Boolean compact)
305 {
306   if (compact)
307     OS << BEZIER << " ";
308   else
309     OS << "BezierCurve";
310
311   Standard_Boolean rational = B->IsRational();
312   if (compact)
313     OS << (rational ? 1 : 0) << " ";
314   else {
315     if (rational) 
316       OS << " rational";
317   }
318
319   // poles and weights
320   Standard_Integer i,degree = B->Degree();
321   if (!compact) OS << "\n  Degree :";
322   OS << degree << " ";
323   
324   for (i = 1; i <= degree+1; i++) {
325     if (!compact) OS << "\n  "<<setw(2)<<i<<" : ";
326     Print(B->Pole(i),OS,compact);
327     if (rational)
328       OS << " " << B->Weight(i);
329     if (compact)
330       OS << " ";
331   }
332   OS << "\n";
333   if (!compact) OS << "\n";
334 }
335
336 //=======================================================================
337 //function : Print
338 //purpose  : 
339 //=======================================================================
340
341 static void Print(const Handle(Geom_BSplineCurve)& B,
342                          Standard_OStream& OS,
343                          const Standard_Boolean compact)
344 {
345   if (compact)
346     OS << BSPLINE << " ";
347   else
348     OS << "BSplineCurve";
349
350
351   Standard_Boolean rational = B->IsRational();
352   if (compact)
353     OS << (rational ? 1 : 0) << " ";
354   else {
355     if (rational) 
356       OS << " rational";
357   }
358
359   Standard_Boolean periodic = B->IsPeriodic();
360   if (compact)
361     OS << (periodic ? 1 : 0)<< " ";
362   else {
363     if (periodic) 
364       OS << " periodic";
365   }
366
367   // poles and weights
368   Standard_Integer i,degree,nbpoles,nbknots;
369   degree = B->Degree();
370   nbpoles = B->NbPoles();
371   nbknots = B->NbKnots();
372   if (!compact) OS << "\n  Degree ";
373   else OS << " ";
374   OS << degree;
375   if (!compact) OS << ",";
376   OS << " ";
377   OS << nbpoles;
378   if (!compact) OS << " Poles,";
379   OS << " ";
380   OS << nbknots << " ";
381   if (!compact) OS << " Knots\n";
382   
383   if (!compact) OS << "Poles :\n";
384   for (i = 1; i <= nbpoles; i++) {
385     if (!compact) OS << "\n  "<<setw(2)<<i<<" : ";
386     else OS << " ";
387     Print(B->Pole(i),OS,compact);
388     if (rational)
389       OS << " " << B->Weight(i);
390   }
391   OS << "\n";
392
393   if (!compact) OS << "Knots :\n";
394   for (i = 1; i <= nbknots; i++) {
395     if (!compact) OS << "\n  "<<setw(2)<<i<<" : ";
396     OS << " " << B->Knot(i) << " " << B->Multiplicity(i);
397   }
398
399   OS << "\n";
400   if (!compact) OS << "\n";
401 }
402
403 //=======================================================================
404 //function : Print
405 //purpose  : 
406 //=======================================================================
407
408 static void Print(const Handle(Geom_TrimmedCurve)& C,
409                          Standard_OStream& OS,
410                          const Standard_Boolean compact)
411 {
412   if (compact)
413     OS << TRIMMED << " ";
414   else
415     OS << "Trimmed curve\n";
416   if (!compact) OS << "Parameters : ";
417   OS << C->FirstParameter() << " " << C->LastParameter() << "\n";
418   if (!compact) OS << "Basis curve :\n";
419   GeomTools_CurveSet::PrintCurve(C->BasisCurve(),OS,compact);
420 }
421
422 //=======================================================================
423 //function : Print
424 //purpose  : 
425 //=======================================================================
426
427 static void Print(const Handle(Geom_OffsetCurve)& C,
428                          Standard_OStream& OS,
429                          const Standard_Boolean compact)
430 {
431   if (compact)
432     OS << OFFSET << " ";
433   else
434     OS << "OffsetCurve";
435   if (!compact) OS << "Offset : ";
436   OS << C->Offset() <<  "\n";
437   if (!compact) OS << "Direction : ";
438   Print(C->Direction(),OS,compact);
439   OS << "\n";
440   if (!compact) OS << "Basis curve :\n";
441   GeomTools_CurveSet::PrintCurve(C->BasisCurve(),OS,compact);
442 }
443
444 //=======================================================================
445 //function : Print
446 //purpose  : 
447 //=======================================================================
448
449 void GeomTools_CurveSet::PrintCurve(const Handle(Geom_Curve)& C,
450                                     Standard_OStream& OS,
451                                     const Standard_Boolean compact)
452 {
453   Handle(Standard_Type) TheType = C->DynamicType();
454
455   if ( TheType ==STANDARD_TYPE(Geom_Line)) {
456     Print(Handle(Geom_Line)::DownCast(C),OS,compact);
457   }
458   else if ( TheType ==  STANDARD_TYPE(Geom_Circle)) {
459     Print(Handle(Geom_Circle)::DownCast(C),OS,compact);
460   }
461   else if ( TheType == STANDARD_TYPE(Geom_Ellipse)) {
462     Print(Handle(Geom_Ellipse)::DownCast(C),OS,compact);
463   }
464   else if ( TheType == STANDARD_TYPE(Geom_Parabola)) {
465     Print(Handle(Geom_Parabola)::DownCast(C),OS,compact);
466   }
467   else if ( TheType == STANDARD_TYPE(Geom_Hyperbola)) {
468     Print(Handle(Geom_Hyperbola)::DownCast(C),OS,compact);
469   }
470   else if ( TheType == STANDARD_TYPE(Geom_BezierCurve)) {
471     Print(Handle(Geom_BezierCurve)::DownCast(C),OS,compact);
472   }
473   else if ( TheType == STANDARD_TYPE(Geom_BSplineCurve)) {
474     Print(Handle(Geom_BSplineCurve)::DownCast(C),OS,compact);
475   }
476   else if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) {
477     Print(Handle(Geom_TrimmedCurve)::DownCast(C),OS,compact);
478   }
479   else if ( TheType == STANDARD_TYPE(Geom_OffsetCurve)) {
480     Print(Handle(Geom_OffsetCurve)::DownCast(C),OS,compact);
481   }
482   else {
483     GeomTools::GetUndefinedTypeHandler()->PrintCurve(C,OS,compact);
484     //if (!compact)
485     //  OS << "****** UNKNOWN CURVE TYPE ******\n";
486     //else 
487     //  cout << "****** UNKNOWN CURVE TYPE ******" << endl;
488   }
489 }
490
491 //=======================================================================
492 //function : Dump
493 //purpose  : 
494 //=======================================================================
495
496 void  GeomTools_CurveSet::Dump(Standard_OStream& OS)const 
497 {
498   Standard_Integer i, nbsurf = myMap.Extent();
499   OS << "\n -------\n";
500   OS << "Dump of "<< nbsurf << " Curves ";
501   OS << "\n -------\n\n";
502
503   for (i = 1; i <= nbsurf; i++) {
504     OS << setw(4) << i << " : ";
505     PrintCurve(Handle(Geom_Curve)::DownCast(myMap(i)),OS,Standard_False);
506   }
507 }
508
509
510 //=======================================================================
511 //function : Write
512 //purpose  : 
513 //=======================================================================
514
515 void  GeomTools_CurveSet::Write(Standard_OStream& OS)const 
516 {
517   std::streamsize  prec = OS.precision(17);
518
519   Standard_Integer i, nbcurve = myMap.Extent();
520   OS << "Curves "<< nbcurve << "\n";
521     //OCC19559
522   Handle(Message_ProgressIndicator) progress = GetProgress();
523   Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
524   for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
525     PrintCurve(Handle(Geom_Curve)::DownCast(myMap(i)),OS,Standard_True);
526   }
527   OS.precision(prec);
528 }
529
530
531 //=======================================================================
532 //function : ReadPnt
533 //purpose  : 
534 //=======================================================================
535
536 static Standard_IStream& operator>>(Standard_IStream& IS, gp_Pnt& P)
537 {
538   Standard_Real X=0.,Y=0.,Z=0.;
539   GeomTools::GetReal(IS, X);
540   GeomTools::GetReal(IS, Y);
541   GeomTools::GetReal(IS, Z);
542   P.SetCoord(X,Y,Z);
543   return IS;
544 }
545
546 //=======================================================================
547 //function : ReadDir
548 //purpose  : 
549 //=======================================================================
550
551 static Standard_IStream& operator>>(Standard_IStream& IS, gp_Dir& D)
552 {
553   Standard_Real X=0.,Y=0.,Z=0.;
554   GeomTools::GetReal(IS, X);
555   GeomTools::GetReal(IS, Y);
556   GeomTools::GetReal(IS, Z);
557   D.SetCoord(X,Y,Z);
558   return IS;
559 }
560
561
562 //=======================================================================
563 //function : ReadCurve
564 //purpose  : 
565 //=======================================================================
566
567 static Standard_IStream& operator>>(Standard_IStream& IS,
568                                     Handle(Geom_Line)& L)
569 {
570   gp_Pnt P(0.,0.,0.);
571   gp_Dir AX(1.,0.,0.);
572   IS >> P >> AX;
573   L = new Geom_Line(P,AX);
574   return IS;
575 }
576
577 //=======================================================================
578 //function : ReadCurve
579 //purpose  : 
580 //=======================================================================
581
582 static Standard_IStream& operator>>(Standard_IStream& IS,
583                                     Handle(Geom_Circle)& C)
584 {
585   gp_Pnt P(0.,0.,0.);
586   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
587   Standard_Real R=0.;
588   IS >> P >> A >> AX >> AY;
589   GeomTools::GetReal(IS, R);
590   C = new Geom_Circle(gp_Ax2(P,A,AX),R);
591   return IS;
592 }
593
594 //=======================================================================
595 //function : ReadCurve
596 //purpose  : 
597 //=======================================================================
598
599 static Standard_IStream& operator>>(Standard_IStream& IS,
600                                     Handle(Geom_Ellipse)& E)
601 {
602   gp_Pnt P(0.,0.,0.);
603   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
604   Standard_Real R1=0.,R2=0.;
605   IS >> P >> A >> AX >> AY;
606   GeomTools::GetReal(IS, R1);
607   GeomTools::GetReal(IS, R2);
608   E = new Geom_Ellipse(gp_Ax2(P,A,AX),R1,R2);
609   return IS;
610 }
611
612 //=======================================================================
613 //function : ReadCurve
614 //purpose  : 
615 //=======================================================================
616
617 static Standard_IStream& operator>>(Standard_IStream& IS,
618                                     Handle(Geom_Parabola)& C)
619 {
620   gp_Pnt P(0.,0.,0.);
621   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
622   Standard_Real R1=0.;
623   IS >> P >> A >> AX >> AY;
624   GeomTools::GetReal(IS, R1);
625   C = new Geom_Parabola(gp_Ax2(P,A,AX),R1);
626   return IS;
627 }
628
629 //=======================================================================
630 //function : ReadCurve
631 //purpose  : 
632 //=======================================================================
633
634 static Standard_IStream& operator>>(Standard_IStream& IS,
635                                     Handle(Geom_Hyperbola)& H)
636 {
637   gp_Pnt P(0.,0.,0.);
638   gp_Dir A(1.,0.,0.),AX(1.,0.,0.),AY(1.,0.,0.);
639   Standard_Real R1=0.,R2=0.;
640   IS >> P >> A >> AX >> AY;
641   GeomTools::GetReal(IS, R1);
642   GeomTools::GetReal(IS, R2);
643   H = new Geom_Hyperbola(gp_Ax2(P,A,AX),R1,R2);
644   return IS;
645 }
646
647 //=======================================================================
648 //function : ReadCurve
649 //purpose  : 
650 //=======================================================================
651
652 static Standard_IStream& operator>>(Standard_IStream& IS,
653                                     Handle(Geom_BezierCurve)& B)
654 {
655   Standard_Boolean rational=Standard_False;
656   IS >> rational;
657
658   // poles and weights
659   Standard_Integer i=0,degree=0;
660   IS >> degree;
661
662   TColgp_Array1OfPnt poles(1,degree+1);
663   TColStd_Array1OfReal weights(1,degree+1);
664   
665   for (i = 1; i <= degree+1; i++) {
666     IS >> poles(i);
667     if (rational)
668       GeomTools::GetReal(IS, weights(i));
669   }
670
671   if (rational)
672     B = new Geom_BezierCurve(poles,weights);
673   else
674     B = new Geom_BezierCurve(poles);
675
676   return IS;
677 }
678
679 //=======================================================================
680 //function : ReadCurve
681 //purpose  : 
682 //=======================================================================
683
684 static Standard_IStream& operator>>(Standard_IStream& IS,
685                                     Handle(Geom_BSplineCurve)& B)
686 {
687
688   Standard_Boolean rational=Standard_False,periodic=Standard_False;
689   IS >> rational >> periodic;
690
691   // poles and weights
692   Standard_Integer i=0,degree=0,nbpoles=0,nbknots=0;
693   IS >> degree >> nbpoles >> nbknots;
694
695   TColgp_Array1OfPnt poles(1,nbpoles);
696   TColStd_Array1OfReal weights(1,nbpoles);
697   
698   for (i = 1; i <= nbpoles; i++) {
699     IS >> poles(i);
700     if (rational)
701       GeomTools::GetReal(IS, weights(i));
702   }
703
704   TColStd_Array1OfReal knots(1,nbknots);
705   TColStd_Array1OfInteger mults(1,nbknots);
706
707   for (i = 1; i <= nbknots; i++) {
708     GeomTools::GetReal(IS, knots(i)); 
709     IS >> mults(i);
710   }
711
712   if (rational)
713     B = new Geom_BSplineCurve(poles,weights,knots,mults,degree,periodic);
714   else
715     B = new Geom_BSplineCurve(poles,knots,mults,degree,periodic);
716   
717   return IS;
718 }
719
720 //=======================================================================
721 //function : ReadCurve
722 //purpose  : 
723 //=======================================================================
724
725 static Standard_IStream& operator>>(Standard_IStream& IS,
726                                     Handle(Geom_TrimmedCurve)& C)
727 {
728   Standard_Real p1=0.,p2=0.;
729   GeomTools::GetReal(IS, p1);
730   GeomTools::GetReal(IS, p2);
731   Handle(Geom_Curve) BC;
732   GeomTools_CurveSet::ReadCurve(IS,BC);
733   C = new Geom_TrimmedCurve(BC,p1,p2);
734   return IS;
735 }
736
737 //=======================================================================
738 //function : ReadCurve
739 //purpose  : 
740 //=======================================================================
741
742 static Standard_IStream& operator>>(Standard_IStream& IS,
743                                     Handle(Geom_OffsetCurve)& C)
744 {
745   Standard_Real p=0.;
746   GeomTools::GetReal(IS, p);
747   gp_Dir D(1.,0.,0.);
748   IS >> D;
749   Handle(Geom_Curve) BC;
750   GeomTools_CurveSet::ReadCurve(IS,BC);
751   C = new Geom_OffsetCurve(BC,p,D);
752   return IS;
753 }
754
755 //=======================================================================
756 //function : ReadCurve
757 //purpose  : 
758 //=======================================================================
759
760 Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS,
761                                                 Handle(Geom_Curve)& C)
762 {
763   Standard_Integer ctype;
764
765   try {
766     OCC_CATCH_SIGNALS
767     IS >> ctype;
768     switch (ctype) {
769
770     case LINE :
771       {
772         Handle(Geom_Line) CC;
773         IS >> CC;
774         C = CC;
775       }
776       break;
777
778     case CIRCLE :
779       {
780         Handle(Geom_Circle) CC;
781         IS >> CC;
782         C = CC;
783       }
784       break;
785
786     case ELLIPSE :
787       {
788         Handle(Geom_Ellipse) CC;
789         IS >> CC;
790         C = CC;
791       }
792       break;
793
794     case PARABOLA :
795       {
796         Handle(Geom_Parabola) CC;
797         IS >> CC;
798         C = CC;
799       }
800       break;
801
802     case HYPERBOLA :
803       {
804         Handle(Geom_Hyperbola) CC;
805         IS >> CC;
806         C = CC;
807       }
808       break;
809
810     case BEZIER :
811       {
812         Handle(Geom_BezierCurve) CC;
813         IS >> CC;
814         C = CC;
815       }
816       break;
817
818     case BSPLINE :
819       {
820         Handle(Geom_BSplineCurve) CC;
821         IS >> CC;
822         C = CC;
823       }
824       break;
825
826     case TRIMMED :
827       {
828         Handle(Geom_TrimmedCurve) CC;
829         IS >> CC;
830         C = CC;
831       }
832       break;
833
834     case OFFSET :
835       {
836         Handle(Geom_OffsetCurve) CC;
837         IS >> CC;
838         C = CC;
839       }
840       break;
841       
842     default:
843       {
844         Handle(Geom_Curve) CC;
845         GeomTools::GetUndefinedTypeHandler()->ReadCurve(ctype,IS,CC);
846         C = CC;
847       }
848     }
849   }
850   catch(Standard_Failure) {
851 #ifdef GEOMTOOLS_DEB
852     Handle(Standard_Failure) anExc = Standard_Failure::Caught();
853     cout <<"EXCEPTION in GeomTools_CurveSet::ReadCurve(..)!!!" << endl;
854     cout << anExc << endl;
855 #endif
856     C = NULL;
857   }
858   return IS;
859 }
860
861 //=======================================================================
862 //function : Read
863 //purpose  : 
864 //=======================================================================
865
866 void  GeomTools_CurveSet::Read(Standard_IStream& IS)
867 {
868   char buffer[255];
869   IS >> buffer;
870   if (strcmp(buffer,"Curves")) {
871     cout << "Not a Curve table"<<endl;
872     return;
873   }
874
875   Handle(Geom_Curve) C;
876   Standard_Integer i, nbcurve;
877   IS >> nbcurve;
878   //OCC19559
879   Handle(Message_ProgressIndicator) progress = GetProgress();
880   Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
881   for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
882     GeomTools_CurveSet::ReadCurve(IS,C);
883     myMap.Add(C);
884   }
885 }
886
887 //=======================================================================
888 //function : GetProgress
889 //purpose  : 
890 //=======================================================================
891
892 Handle(Message_ProgressIndicator) GeomTools_CurveSet::GetProgress() const
893 {
894   return myProgress;
895 }
896
897 //=======================================================================
898 //function : SetProgress
899 //purpose  : 
900 //=======================================================================
901
902 void GeomTools_CurveSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
903 {
904   myProgress = PR;
905 }
906
907