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