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