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