0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[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
7fd59977 17
42cf5bc1 18#include <Geom2d_BezierCurve.hxx>
19#include <Geom2d_BSplineCurve.hxx>
7fd59977 20#include <Geom2d_Circle.hxx>
42cf5bc1 21#include <Geom2d_Curve.hxx>
7fd59977 22#include <Geom2d_Ellipse.hxx>
7fd59977 23#include <Geom2d_Hyperbola.hxx>
42cf5bc1 24#include <Geom2d_Line.hxx>
7fd59977 25#include <Geom2d_OffsetCurve.hxx>
42cf5bc1 26#include <Geom2d_Parabola.hxx>
27#include <Geom2d_TrimmedCurve.hxx>
28#include <GeomTools.hxx>
29#include <GeomTools_Curve2dSet.hxx>
30#include <GeomTools_UndefinedTypeHandler.hxx>
7fd59977 31#include <gp_Circ2d.hxx>
32#include <gp_Elips2d.hxx>
7fd59977 33#include <gp_Hypr2d.hxx>
42cf5bc1 34#include <gp_Lin2d.hxx>
35#include <gp_Parab2d.hxx>
36#include <Message_ProgressIndicator.hxx>
7fd59977 37#include <Message_ProgressSentry.hxx>
42cf5bc1 38#include <Standard_ErrorHandler.hxx>
39#include <Standard_Failure.hxx>
40#include <Standard_OutOfRange.hxx>
41#include <Standard_Stream.hxx>
42#include <TColgp_Array1OfPnt2d.hxx>
43#include <TColStd_Array1OfInteger.hxx>
44#include <TColStd_Array1OfReal.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++) {
04232180 312 if (!compact) OS << "\n "<<std::setw(2)<<i<<" : ";
7fd59977 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++) {
04232180 372 if (!compact) OS << "\n "<<std::setw(2)<<i<<" : ";
7fd59977 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++) {
04232180 382 if (!compact) OS << "\n "<<std::setw(2)<<i<<" : ";
7fd59977 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
04232180 471 // std::cout << "****** UNKNOWN CURVE2d TYPE ******" << std::endl;
7fd59977 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++) {
04232180 488 OS << std::setw(4) << i << " : ";
7fd59977 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);
aa00364d 712 Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
7fd59977 713 C = new Geom2d_TrimmedCurve(BC,p1,p2);
714 return IS;
715}
716
717//=======================================================================
718//function : ReadCurve2d
719//purpose :
720//=======================================================================
721
722static Standard_IStream& operator>>(Standard_IStream& IS,
723 Handle(Geom2d_OffsetCurve)& C)
724{
725 Standard_Real p=0.;
71598a83 726 GeomTools::GetReal(IS, p);
aa00364d 727 Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
7fd59977 728 C = new Geom2d_OffsetCurve(BC,p);
729 return IS;
730}
731
732//=======================================================================
733//function : ReadCurve2d
734//purpose :
735//=======================================================================
736
aa00364d 737Handle(Geom2d_Curve) GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS)
7fd59977 738{
739 Standard_Integer ctype;
740
aa00364d 741 Handle(Geom2d_Curve) C;
7fd59977 742 try {
743 OCC_CATCH_SIGNALS
744 IS >> ctype;
745 switch (ctype) {
746
747 case LINE :
748 {
749 Handle(Geom2d_Line) CC;
750 IS >> CC;
751 C = CC;
752 }
753 break;
754
755 case CIRCLE :
756 {
757 Handle(Geom2d_Circle) CC;
758 IS >> CC;
759 C = CC;
760 }
761 break;
762
763 case ELLIPSE :
764 {
765 Handle(Geom2d_Ellipse) CC;
766 IS >> CC;
767 C = CC;
768 }
769 break;
770
771 case PARABOLA :
772 {
773 Handle(Geom2d_Parabola) CC;
774 IS >> CC;
775 C = CC;
776 }
777 break;
778
779 case HYPERBOLA :
780 {
781 Handle(Geom2d_Hyperbola) CC;
782 IS >> CC;
783 C = CC;
784 }
785 break;
786
787 case BEZIER :
788 {
789 Handle(Geom2d_BezierCurve) CC;
790 IS >> CC;
791 C = CC;
792 }
793 break;
794
795 case BSPLINE :
796 {
797 Handle(Geom2d_BSplineCurve) CC;
798 IS >> CC;
799 C = CC;
800 }
801 break;
802
803 case TRIMMED :
804 {
805 Handle(Geom2d_TrimmedCurve) CC;
806 IS >> CC;
807 C = CC;
808 }
809 break;
810
811 case OFFSET :
812 {
813 Handle(Geom2d_OffsetCurve) CC;
814 IS >> CC;
815 C = CC;
816 }
817 break;
818
819 default:
820 {
821 Handle(Geom2d_Curve) CC;
822 GeomTools::GetUndefinedTypeHandler()->ReadCurve2d(ctype,IS,CC);
823 C = CC;
824 }
825 break;
826 }
827 }
9775fa61 828 catch(Standard_Failure const& anException) {
0797d9d3 829#ifdef OCCT_DEBUG
04232180 830 std::cout <<"EXCEPTION in GeomTools_Curve2dSet::ReadCurve2d(..)!!!" << std::endl;
831 std::cout << anException << std::endl;
7fd59977 832#endif
9775fa61 833 (void)anException;
7fd59977 834 }
aa00364d 835 return C;
7fd59977 836}
837
838//=======================================================================
839//function : Read
840//purpose :
841//=======================================================================
842
843void GeomTools_Curve2dSet::Read(Standard_IStream& IS)
844{
845 char buffer[255];
846 IS >> buffer;
847 if (strcmp(buffer,"Curve2ds")) {
04232180 848 std::cout << "Not a Curve2d table"<<std::endl;
7fd59977 849 return;
850 }
851
7fd59977 852 Standard_Integer i, nbcurve;
853 IS >> nbcurve;
854 //OCC19559
855 Handle(Message_ProgressIndicator) progress = GetProgress();
856 Message_ProgressSentry PS(progress, "2D Curves", 0, nbcurve, 1);
7fd59977 857 for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
aa00364d 858 Handle(Geom2d_Curve) C = GeomTools_Curve2dSet::ReadCurve2d (IS);
7fd59977 859 myMap.Add(C);
860 }
861}
862
863//=======================================================================
864//function : GetProgress
865//purpose :
866//=======================================================================
867
868Handle(Message_ProgressIndicator) GeomTools_Curve2dSet::GetProgress() const
869{
870 return myProgress;
871}
872
873//=======================================================================
874//function : SetProgress
875//purpose :
876//=======================================================================
877
878void GeomTools_Curve2dSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
879{
880 myProgress = PR;
881}
882
883