0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Extrema / Extrema_ExtCC2d.cxx
1 // Created on: 1994-07-06
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1994-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
18 #include <Adaptor2d_Curve2d.hxx>
19 #include <ElCLib.hxx>
20 #include <Extrema_Curve2dTool.hxx>
21 #include <Extrema_ECC2d.hxx>
22 #include <Extrema_ExtCC2d.hxx>
23 #include <Extrema_ExtElC.hxx>
24 #include <Extrema_ExtElC2d.hxx>
25 #include <Extrema_POnCurv2d.hxx>
26 #include <Extrema_SequenceOfPOnCurv2d.hxx>
27 #include <Geom2d_Circle.hxx>
28 #include <Geom2d_Curve.hxx>
29 #include <Geom2d_Ellipse.hxx>
30 #include <Geom2d_Hyperbola.hxx>
31 #include <Geom2d_Line.hxx>
32 #include <Geom2d_Parabola.hxx>
33 #include <Geom2d_TrimmedCurve.hxx>
34 #include <GeomAbs_CurveType.hxx>
35 #include <gp_Pnt2d.hxx>
36 #include <Precision.hxx>
37 #include <Standard_OutOfRange.hxx>
38 #include <StdFail_NotDone.hxx>
39
40 Extrema_ExtCC2d::Extrema_ExtCC2d()
41 : myIsFindSingleSolution(Standard_False)
42 {
43 }
44
45
46 Extrema_ExtCC2d::Extrema_ExtCC2d(const Adaptor2d_Curve2d&       C1,
47                                  const Adaptor2d_Curve2d&       C2,
48                                  const Standard_Real TolC1,
49                                  const Standard_Real TolC2)
50 : myIsFindSingleSolution(Standard_False)
51 {
52   Initialize(C2, Extrema_Curve2dTool::FirstParameter(C2), Extrema_Curve2dTool::LastParameter(C2), TolC1, TolC2);
53   Perform(C1, Extrema_Curve2dTool::FirstParameter(C1), Extrema_Curve2dTool::LastParameter(C1));
54 }
55
56 Extrema_ExtCC2d::Extrema_ExtCC2d(const Adaptor2d_Curve2d&        C1, 
57                                  const Adaptor2d_Curve2d&        C2,
58                                  const Standard_Real  U1,
59                                  const Standard_Real  U2,
60                                  const Standard_Real  V1,
61                                  const Standard_Real  V2,
62                                  const Standard_Real  TolC1,
63                                  const Standard_Real  TolC2)
64 : myIsFindSingleSolution(Standard_False)
65 {
66   Initialize(C2, V1, V2, TolC1, TolC2);
67   Perform(C1, U1, U2);
68 }
69
70
71
72 void Extrema_ExtCC2d::Initialize(const Adaptor2d_Curve2d&        C2,
73                                   const Standard_Real  V1,
74                                   const Standard_Real  V2,
75                                   const Standard_Real  TolC1,
76                                   const Standard_Real  TolC2)
77 {
78   myC = (Standard_Address)&C2;
79   myv1 = V1;
80   myv2 = V2;
81   mytolc1 = TolC1;
82   mytolc2 = TolC2;
83 }
84
85
86
87 void Extrema_ExtCC2d::Perform (const Adaptor2d_Curve2d&       C1,
88                                 const Standard_Real U1,
89                                 const Standard_Real U2)
90 {
91   mypoints.Clear();
92   mySqDist.Clear();
93   GeomAbs_CurveType type1 = Extrema_Curve2dTool::GetType(C1), type2 = Extrema_Curve2dTool::GetType(*((Adaptor2d_Curve2d*)myC));
94   Standard_Real U11, U12, U21, U22, Tol = Min(mytolc1, mytolc2);
95 //  Extrema_POnCurv2d P1, P2;
96   mynbext = 0;
97   inverse = Standard_False;
98   myIsPar = Standard_False;
99
100   U11 = U1;
101   U12 = U2;
102   U21 = myv1;
103   U22 = myv2;
104   P1f = Extrema_Curve2dTool::Value(C1, U11);
105   P1l = Extrema_Curve2dTool::Value(C1, U12);
106   P2f = Extrema_Curve2dTool::Value(*((Adaptor2d_Curve2d*)myC), U21);
107   P2l = Extrema_Curve2dTool::Value(*((Adaptor2d_Curve2d*)myC), U22);
108
109
110   switch(type1) {
111     //
112     //  La premiere courbe est un cercle:
113     //
114   case GeomAbs_Circle: {
115
116     switch(type2) {
117       case GeomAbs_Line: {
118         inverse = Standard_True;
119         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Circle(C1), Tol);
120         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0.);
121         }
122         break;
123       case GeomAbs_Circle: {
124         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1), Extrema_Curve2dTool::Circle(*((Adaptor2d_Curve2d*)myC)));
125         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 2*M_PI);
126         }
127         break;
128       case GeomAbs_Ellipse: {
129         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1), Extrema_Curve2dTool::Ellipse(*((Adaptor2d_Curve2d*)myC)));
130         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 2*M_PI );
131         }
132         break;
133       case GeomAbs_Parabola: {
134         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1), Extrema_Curve2dTool::Parabola(*((Adaptor2d_Curve2d*)myC)));
135         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0.);
136       }
137         break;
138       case GeomAbs_Hyperbola: {
139         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1), Extrema_Curve2dTool::Hyperbola(*((Adaptor2d_Curve2d*)myC)));
140         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0. );
141       }
142         break;
143       default: {
144           Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
145           aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
146           aParamSolver.Perform();
147           Standard_Real Period2 = 0.;
148           if (Extrema_Curve2dTool::IsPeriodic(*((Adaptor2d_Curve2d*)myC))) Period2 = Extrema_Curve2dTool::Period(*((Adaptor2d_Curve2d*)myC));
149           Results(aParamSolver, U11, U12, U21, U22, 2*M_PI,Period2);
150         }
151         break;
152       };  // switch(type2)
153     }
154     break;
155
156     //
157     // La premiere courbe est une ellipse:
158     //
159   case GeomAbs_Ellipse: {
160
161     switch(type2) {
162       case GeomAbs_Line: {
163         inverse = Standard_True;
164         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Ellipse(C1));
165         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 0.);
166         }
167         break;
168       case GeomAbs_Circle: {
169         inverse = Standard_True;
170         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Ellipse(C1));
171         Results(Xtrem, U11, U12, U21, U22, 2*M_PI, 2*M_PI);
172         }
173         break;
174       case GeomAbs_Ellipse:
175         {
176         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
177         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
178         aParamSolver.Perform();
179         Results(aParamSolver, U11, U12, U21, U22,2*M_PI, 2*M_PI);
180         }
181         break;
182       case GeomAbs_Parabola: {
183         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(C1), Extrema_Curve2dTool::Parabola(*((Adaptor2d_Curve2d*)myC)));
184         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
185         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
186         aParamSolver.Perform();
187         Results(aParamSolver, U11, U12, U21, U22, 2*M_PI, 0.);
188       }
189         break;
190       case GeomAbs_Hyperbola: {
191         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(C1), Extrema_Curve2dTool::Hyperbola(*((Adaptor2d_Curve2d*)myC)));
192         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
193         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
194         aParamSolver.Perform();
195         Results(aParamSolver, U11, U12, U21, U22, 2*M_PI, 0.);
196       }
197         break;
198       default: {
199         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
200         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
201         aParamSolver.Perform();
202         Standard_Real Period2 = 0.;
203         if (Extrema_Curve2dTool::IsPeriodic(*((Adaptor2d_Curve2d*)myC))) Period2 = Extrema_Curve2dTool::Period(*((Adaptor2d_Curve2d*)myC));
204         Results(aParamSolver, U11, U12, U21, U22, 2*M_PI,Period2);
205         }
206         break;
207       };  // switch(type2)
208     }
209     break;
210
211     //
212     // La premiere courbe est une parabole: 
213     //
214   case GeomAbs_Parabola: {
215
216     switch(type2) {
217       case GeomAbs_Line: {
218         inverse = Standard_True;
219         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Parabola(C1));
220         Results(Xtrem, U11, U12, U21, U22, 0., 0.);
221         }
222         break;
223       case GeomAbs_Circle: {
224         inverse = Standard_True;
225         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Parabola(C1));
226         Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI);
227         }
228         break;
229       case GeomAbs_Ellipse: {
230         //inverse = Standard_True;
231         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Parabola(C1));
232         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
233         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
234         aParamSolver.Perform();
235         Results(aParamSolver, U11, U12, U21, U22, 0., 2*M_PI);
236         }
237         break;
238       case GeomAbs_Parabola: {
239         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Parabola(C1), Extrema_Curve2dTool::Parabola(*((Adaptor2d_Curve2d*)myC)));
240         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
241         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
242         aParamSolver.Perform();
243         Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
244       }
245         break;
246       case GeomAbs_Hyperbola: {
247         //inverse = Standard_True;
248         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Hyperbola(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Parabola(C1));
249         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
250         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
251         aParamSolver.Perform();
252         Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
253       }
254         break;
255       default: {
256         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
257         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
258         aParamSolver.Perform();
259         Standard_Real Period2 = 0.;
260         if (Extrema_Curve2dTool::IsPeriodic(*((Adaptor2d_Curve2d*)myC))) Period2 = Extrema_Curve2dTool::Period(*((Adaptor2d_Curve2d*)myC));
261         Results(aParamSolver, U11, U12, U21, U22, 0., Period2);
262         }
263         break;
264       };  // switch(type2)
265     }
266     break;
267
268     //
269     // La premiere courbe est une hyperbole:
270     //
271   case GeomAbs_Hyperbola: {
272
273     switch(type2) {
274       case GeomAbs_Line: {
275         inverse = Standard_True;
276         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Hyperbola(C1));
277         Results(Xtrem, U11, U12, U21, U22, 0., 0.);
278         }
279         break;
280       case GeomAbs_Circle: {
281         inverse = Standard_True;
282         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Hyperbola(C1));
283         Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI);
284         }
285         break;
286       case GeomAbs_Ellipse: {
287         //inverse = Standard_True;
288         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(*((Adaptor2d_Curve2d*)myC)), Extrema_Curve2dTool::Hyperbola(C1));
289         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
290         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
291         aParamSolver.Perform();
292         Results(aParamSolver, U11, U12, U21, U22, 0., 2*M_PI );
293         }
294         break;
295       case GeomAbs_Parabola: {
296         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Hyperbola(C1), Extrema_Curve2dTool::Parabola(*((Adaptor2d_Curve2d*)myC)));
297         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
298         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
299         aParamSolver.Perform();
300         Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
301       }
302         break;
303       case GeomAbs_Hyperbola: {
304         //Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Hyperbola(C1), Extrema_Curve2dTool::Hyperbola(*((Adaptor2d_Curve2d*)myC)));
305         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
306         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
307         aParamSolver.Perform();
308         Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
309       }
310         break;
311       default: {
312         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
313         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
314         aParamSolver.Perform();
315         Standard_Real Period2 = 0.;
316         if (Extrema_Curve2dTool::IsPeriodic(*((Adaptor2d_Curve2d*)myC))) Period2 = Extrema_Curve2dTool::Period(*((Adaptor2d_Curve2d*)myC));
317         Results(aParamSolver, U11, U12, U21, U22, 0., Period2);
318         }
319         break;
320       };  // switch(type2)
321     }
322     break;
323
324     //
325     // La premiere courbe est une Line:
326     //
327   case GeomAbs_Line: {
328
329     switch(type2) {
330       case GeomAbs_Line: {
331         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1), Extrema_Curve2dTool::Line(*((Adaptor2d_Curve2d*)myC)), Tol);
332         Results(Xtrem, U11, U12, U21, U22, 0., 0.);
333         } 
334         break;
335       case GeomAbs_Circle: {
336         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1), Extrema_Curve2dTool::Circle(*((Adaptor2d_Curve2d*)myC)), Tol);
337         Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI);
338         }
339         break;
340       case GeomAbs_Ellipse: {
341         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1), Extrema_Curve2dTool::Ellipse(*((Adaptor2d_Curve2d*)myC)));
342         Results(Xtrem, U11, U12, U21, U22, 0., 2*M_PI);
343         }
344         break;
345       case GeomAbs_Parabola: {
346         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1), Extrema_Curve2dTool::Parabola(*((Adaptor2d_Curve2d*)myC)));
347         Results(Xtrem, U11, U12, U21, U22, 0., 0.);
348       }
349         break;
350       case GeomAbs_Hyperbola: {
351         Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1), Extrema_Curve2dTool::Hyperbola(*((Adaptor2d_Curve2d*)myC)));
352         Results(Xtrem, U11, U12, U21, U22, 0., 0.);
353       }
354         break;
355       default: {
356         Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
357         aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
358         aParamSolver.Perform();
359         Standard_Real Period2 = 0.;
360         if (Extrema_Curve2dTool::IsPeriodic(*((Adaptor2d_Curve2d*)myC))) Period2 = Extrema_Curve2dTool::Period(*((Adaptor2d_Curve2d*)myC));
361         Results(aParamSolver, U11, U12, U21, U22, 0., Period2);
362         }
363         break;
364       };  // switch(type2)
365     }
366     break;
367
368     //
369     // La premiere courbe est une BezierCurve ou une BSplineCurve:
370     //
371   default: {
372     Extrema_ECC2d aParamSolver(C1, *((Adaptor2d_Curve2d*)myC));
373     aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
374     aParamSolver.Perform();
375     Standard_Real Period1 = 0.;
376     if (Extrema_Curve2dTool::IsPeriodic(C1)) Period1 = Extrema_Curve2dTool::Period(C1);
377     Standard_Real Period2 = 0.;
378     if (Extrema_Curve2dTool::IsPeriodic(*((Adaptor2d_Curve2d*)myC))) Period2 = Extrema_Curve2dTool::Period(*((Adaptor2d_Curve2d*)myC));
379     Results(aParamSolver, U11, U12, U21, U22, Period1, Period2);
380     }
381     break;
382
383   };
384     
385 }
386
387
388 Standard_Boolean Extrema_ExtCC2d::IsDone() const
389 {
390   return myDone;
391 }
392
393
394 Standard_Real Extrema_ExtCC2d::SquareDistance(const Standard_Integer N) const 
395 {
396   if(!myDone) throw StdFail_NotDone();
397   if ((N <= 0) || (N > mynbext)) throw Standard_OutOfRange();
398   return mySqDist.Value(N);
399 }
400
401
402 Standard_Integer Extrema_ExtCC2d::NbExt() const
403 {
404   if(!myDone) throw StdFail_NotDone();
405   return mynbext;
406 }
407
408
409 void Extrema_ExtCC2d::Points(const Standard_Integer N, 
410                               Extrema_POnCurv2d& P1,
411                               Extrema_POnCurv2d& P2) const
412 {
413   if(!myDone) throw StdFail_NotDone();
414   if ((N <= 0) || (N > mynbext)) throw Standard_OutOfRange();
415   P1 = mypoints.Value(2*N-1);
416   P2 = mypoints.Value(2*N);
417 }
418
419
420
421 void Extrema_ExtCC2d::TrimmedSquareDistances(Standard_Real& dist11,
422                                         Standard_Real& dist12,
423                                         Standard_Real& dist21,
424                                         Standard_Real& dist22,
425                                         gp_Pnt2d&      P11,
426                                         gp_Pnt2d&      P12,
427                                         gp_Pnt2d&      P21,
428                                         gp_Pnt2d&      P22) const 
429 {
430   dist11 = mydist11;
431   dist12 = mydist12;
432   dist21 = mydist21;
433   dist22 = mydist22;
434   P11 = P1f;
435   P12 = P1l;
436   P21 = P2f;
437   P22 = P2l;
438 }
439
440
441
442 void Extrema_ExtCC2d::Results(const Extrema_ExtElC2d&  AlgExt,
443                                const Standard_Real      Ut11,
444                                const Standard_Real      Ut12,
445                                const Standard_Real      Ut21,
446                                const Standard_Real      Ut22,
447                                const Standard_Real      Period1,
448                                const Standard_Real      Period2)
449 {
450   Standard_Integer i, NbExt;
451   Standard_Real Val, U, U2;
452   Extrema_POnCurv2d P1, P2;
453   
454   myDone = AlgExt.IsDone();
455   myIsPar = AlgExt.IsParallel();
456   if (myDone) {
457     if (!myIsPar) {
458       NbExt = AlgExt.NbExt();
459       for (i = 1; i <= NbExt; i++) {
460         // Verification de la validite des parametres pour le cas trimme:
461         AlgExt.Points(i, P1, P2);
462         if (!inverse) {
463           U = P1.Parameter();
464           if (Period1 != 0.0) U = ElCLib::InPeriod(U,Ut11,Ut11+Period1);
465           U2 = P2.Parameter();
466           if (Period2 != 0.0) U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2);
467         }
468         else {
469           U2 = P1.Parameter();
470           if (Period2 != 0.0) U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2);
471           U = P2.Parameter();
472           if (Period1 != 0.0) U = ElCLib::InPeriod(U,Ut11,Ut11+Period1);
473         }
474         if ((U  >= Ut11 - Precision::PConfusion())  && 
475             (U  <= Ut12 + Precision::PConfusion())  &&
476             (U2 >= Ut21 - Precision::PConfusion())  &&
477             (U2 <= Ut22 + Precision::PConfusion())) {
478           mynbext++;
479           Val = AlgExt.SquareDistance(i);
480           mySqDist.Append(Val);
481           if (!inverse) {
482             P1.SetValues(U, P1.Value());
483             P2.SetValues(U2, P2.Value());
484             mypoints.Append(P1);
485             mypoints.Append(P2);
486           }
487           else {
488             P1.SetValues(U2, P1.Value());
489             P2.SetValues(U, P2.Value());
490             mypoints.Append(P2);
491             mypoints.Append(P1);
492           }
493         }
494       }
495     }
496
497     mydist11 = P1f.SquareDistance(P2f);
498     mydist12 = P1f.SquareDistance(P2l);
499     mydist21 = P1l.SquareDistance(P2f);
500     mydist22 = P1l.SquareDistance(P2l);
501   }
502 }
503
504
505 void Extrema_ExtCC2d::Results(const Extrema_ECC2d& AlgExt,
506                               const Standard_Real  Ut11,
507                               const Standard_Real  Ut12,
508                               const Standard_Real  Ut21,
509                               const Standard_Real  Ut22,
510                               const Standard_Real  Period1,
511                               const Standard_Real  Period2)
512 {
513   Standard_Integer i, NbExt;
514   Standard_Real Val, U, U2;
515   Extrema_POnCurv2d P1, P2;
516
517   myDone = AlgExt.IsDone();
518   if (myDone)
519   {
520     myIsPar = AlgExt.IsParallel();
521     NbExt = AlgExt.NbExt();
522     for (i = 1; i <= NbExt; i++)
523     {
524       // Verification de la validite des parametres pour le cas trimme:
525       AlgExt.Points(i, P1, P2);
526       U = P1.Parameter();
527       if (Period1 != 0.0) 
528         U = ElCLib::InPeriod(U,Ut11,Ut11+Period1);
529       U2 = P2.Parameter();
530       if (Period2 != 0.0) 
531         U2 = ElCLib::InPeriod(U2,Ut21,Ut21+Period2);
532
533       if ((U  >= Ut11 - Precision::PConfusion())  && 
534         (U  <= Ut12 + Precision::PConfusion())  &&
535         (U2 >= Ut21 - Precision::PConfusion())  &&
536         (U2 <= Ut22 + Precision::PConfusion()))
537       {
538         mynbext++;
539         Val = AlgExt.SquareDistance(i);
540         P1.SetValues(U, P1.Value());
541         P2.SetValues(U2, P2.Value());
542         mySqDist.Append(Val);
543         mypoints.Append(P1);
544         mypoints.Append(P2);
545       }
546     }
547
548     mydist11 = P1f.SquareDistance(P2f);
549     mydist12 = P1f.SquareDistance(P2l);
550     mydist21 = P1l.SquareDistance(P2f);
551     mydist22 = P1l.SquareDistance(P2l);
552   }
553 }
554
555
556 Standard_Boolean Extrema_ExtCC2d::IsParallel() const
557 {
558   if (!myDone) throw StdFail_NotDone();
559   return myIsPar;
560 }
561
562 //=======================================================================
563 //function : SetSingleSolutionFlag
564 //purpose  : 
565 //=======================================================================
566 void Extrema_ExtCC2d::SetSingleSolutionFlag(const Standard_Boolean theFlag)
567 {
568   myIsFindSingleSolution = theFlag;
569 }
570
571 //=======================================================================
572 //function : GetSingleSolutionFlag
573 //purpose  : 
574 //=======================================================================
575 Standard_Boolean Extrema_ExtCC2d::GetSingleSolutionFlag() const
576 {
577   return myIsFindSingleSolution;
578 }