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