0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GccGeo / GccGeo_Circ2dTanOnRad.gxx
1 // File GccGeo_Circ2dTanOnRad.cxx, REG 19/07/91
2
3 //========================================================================
4 //       circulaire tangent a un element de type :  - Cercle.            +
5 //                                                  - Ligne.             +
6 //                                                  - Point.             +
7 //                  centre sur un deuxieme element de type :  - Cercle.  +
8 //                                                            - Ligne.   +
9 //                  de rayon donne : Radius.                             +
10 //========================================================================
11
12 #include <ElCLib.hxx>
13 #include <math_DirectPolynomialRoots.hxx>
14 #include <TColStd_Array1OfReal.hxx>
15 #include <Standard_NegativeValue.hxx>
16 #include <gp_Dir2d.hxx>
17 #include <Standard_OutOfRange.hxx>
18 #include <StdFail_NotDone.hxx>
19 #include <GccEnt_BadQualifier.hxx>
20 #include <IntRes2d_Domain.hxx>
21 #include <IntRes2d_IntersectionPoint.hxx>
22
23 //=========================================================================
24 //  Cercle tangent  :  a un cercle Qualified1 (C1).                       +
25 //         centre   :  sur une droite OnLine.                             +
26 //         de rayon :  Radius.                                            +
27 //                                                                        + 
28 //  On initialise le tableau de solutions cirsol ainsi que tous les       +
29 //  champs.                                                               +
30 //  On elimine en fonction du qualifieur les cas ne presentant pas de     +
31 //  solutions.                                                            +
32 //  On resoud l equation du second degre indiquant que le point de centre +
33 //  recherche (xc,yc) est a une distance Radius du cercle C1 et           +
34 //                        sur la droite OnLine.                           +
35 //  Les solutions sont representees par les cercles :                     +
36 //                   - de centre Pntcen(xc,yc)                            +
37 //                   - de rayon Radius.                                   +
38 //=========================================================================
39
40 GccGeo_Circ2dTanOnRad::
41    GccGeo_Circ2dTanOnRad (const TheQCurve&    Qualified1, 
42                           const gp_Lin2d&     OnLine    ,
43                           const Standard_Real Radius    ,
44                           const Standard_Real Tolerance ):
45
46 //=========================================================================
47 // Initialisation des champs.                                             +
48 //=========================================================================
49
50    cirsol(1,8)     ,
51    qualifier1(1,8) ,
52    TheSame1(1,8)   ,
53    pnttg1sol(1,8)  ,
54    pntcen3(1,8)    ,
55    par1sol(1,8)    ,
56    pararg1(1,8)    ,
57    parcen3(1,8)    
58 {
59
60 //=========================================================================
61 // Traitement.                                                            +
62 //=========================================================================
63
64    gp_Dir2d dirx(1.0,0.0);
65    Standard_Real Tol = Abs(Tolerance);
66    Standard_Real thefirst = -100000.;
67    Standard_Real thelast  =  100000.;
68    Standard_Real firstparam;
69    Standard_Real lastparam;
70    WellDone = Standard_False;
71    NbrSol = 0;
72    if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || 
73          Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
74      GccEnt_BadQualifier::Raise();
75      return;
76    }
77    Standard_Integer nbrcote1 = 0;
78    TColStd_Array1OfReal Coef(1,2);
79    TheCurve Cu1 = Qualified1.Qualified();
80
81    if (Radius < 0.0) { Standard_NegativeValue::Raise(); }
82    else {
83      if (Qualified1.IsEnclosed()) {
84 //    ===========================
85        nbrcote1 = 1;
86        Coef(1) = Radius;
87      }
88      else if(Qualified1.IsOutside()) {
89 //   ===============================
90        nbrcote1 = 1;
91        Coef(1) = -Radius;
92      }
93      else if(Qualified1.IsUnqualified()) {
94 //   ===================================
95        nbrcote1 = 2;
96        Coef(1) = Radius;
97        Coef(2) = -Radius;
98      }
99      IntRes2d_Domain D1;
100      TheIntConicCurve Intp;
101      for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
102        Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1);
103        TheParGenCurve C2(HCu1,Coef(jcote1));
104        firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst);
105        lastparam  = Min(TheCurvePGTool::LastParameter(C2),thelast);
106        IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol,
107                           TheCurvePGTool::Value(C2,lastparam),lastparam,Tol);
108        Intp.Perform(OnLine,D1,C2,D2,Tol,Tol);
109        if (Intp.IsDone()) {
110          if (!Intp.IsEmpty()) {
111            for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
112              NbrSol++;
113              gp_Pnt2d Center(Intp.Point(i).Value());
114              cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
115 //           =======================================================
116              qualifier1(NbrSol) = Qualified1.Qualifier();
117              TheSame1(NbrSol) = 0;
118              pararg1(NbrSol) = Intp.Point(i).ParamOnSecond();
119              parcen3(NbrSol) = Intp.Point(i).ParamOnFirst();
120              par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
121                                               pnttg1sol(NbrSol));
122              pnttg1sol(NbrSol) = gp_Pnt2d(TheTool::Value(Cu1,pararg1(NbrSol)));
123              pntcen3(NbrSol) = Center;
124            }
125          }
126          WellDone = Standard_True;
127        }
128      }
129    }
130  }
131
132 //=========================================================================
133 //  Cercle tangent  :  a un cercle Qualified1 (C1).                       +
134 //         centre   :  sur une droite OnLine.                             +
135 //         de rayon :  Radius.                                            +
136 //                                                                        + 
137 //  On initialise le tableau de solutions cirsol ainsi que tous les       +
138 //  champs.                                                               +
139 //  On elimine en fonction du qualifieur les cas ne presentant pas de     +
140 //  solutions.                                                            +
141 //  On resoud l equation du second degre indiquant que le point de centre +
142 //  recherche (xc,yc) est a une distance Radius du cercle C1 et           +
143 //                        sur la droite OnLine.                           +
144 //  Les solutions sont representees par les cercles :                     +
145 //                   - de centre Pntcen(xc,yc)                            +
146 //                   - de rayon Radius.                                   +
147 //=========================================================================
148
149 GccGeo_Circ2dTanOnRad::
150    GccGeo_Circ2dTanOnRad (const TheQCurve&    Qualified1,
151                           const gp_Circ2d&    OnCirc    , 
152                           const Standard_Real Radius    ,
153                           const Standard_Real Tolerance ):
154
155 //=========================================================================
156 // Initialisation des champs.                                             +
157 //=========================================================================
158
159    cirsol(1,8)     ,
160    qualifier1(1,8) ,
161    TheSame1(1,8)   ,
162    pnttg1sol(1,8)  ,
163    pntcen3(1,8)    ,
164    par1sol(1,8)    ,
165    pararg1(1,8)    ,
166    parcen3(1,8)    
167 {
168
169 //=========================================================================
170 // Traitement.                                                            +
171 //=========================================================================
172
173    gp_Dir2d dirx(1.0,0.0);
174    Standard_Real thefirst = -100000.;
175    Standard_Real thelast  =  100000.;
176    Standard_Real firstparam;
177    Standard_Real lastparam;
178    Standard_Real Tol = Abs(Tolerance);
179    Standard_Integer nbrcote1=0;
180    WellDone = Standard_False;
181    NbrSol = 0;
182    if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || 
183          Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
184      GccEnt_BadQualifier::Raise();
185      return;
186    }
187    TColStd_Array1OfReal cote1(1,2);
188    TheCurve Cu1 = Qualified1.Qualified();
189
190    if (Radius < 0.0) {
191      Standard_NegativeValue::Raise();
192    }
193    else {
194      if (Qualified1.IsEnclosed()) {
195 //    ===========================
196        nbrcote1 = 1;
197        cote1(1) = Radius;
198      }
199      else if(Qualified1.IsOutside()) {
200 //   ===============================
201        nbrcote1 = 1;
202        cote1(1) = -Radius;
203      }
204      else if(Qualified1.IsUnqualified()) {
205 //   ===================================
206        nbrcote1 = 2;
207        cote1(1) = Radius;
208        cote1(2) = -Radius;
209      }
210      IntRes2d_Domain D1(ElCLib::Value(0.,OnCirc),   0.,Tol,
211                         ElCLib::Value(2.*M_PI,OnCirc),2.*M_PI,Tol);
212      D1.SetEquivalentParameters(0.,2.*M_PI);
213      TheIntConicCurve Intp;
214      for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
215        Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1);
216        TheParGenCurve C2(HCu1,cote1(jcote1));
217        firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst);
218        lastparam  = Min(TheCurvePGTool::LastParameter(C2),thelast);
219        IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol,
220                           TheCurvePGTool::Value(C2,lastparam),lastparam,Tol);
221        Intp.Perform(OnCirc,D1,C2,D2,Tol,Tol);
222        if (Intp.IsDone()) {
223          if (!Intp.IsEmpty()) {
224            for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
225              NbrSol++;
226              gp_Pnt2d Center(Intp.Point(i).Value());
227              cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
228 //           =======================================================
229              qualifier1(NbrSol) = Qualified1.Qualifier();
230              TheSame1(NbrSol) = 0;
231              pararg1(NbrSol) = Intp.Point(i).ParamOnSecond();
232              parcen3(NbrSol) = Intp.Point(i).ParamOnFirst();
233              par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
234                                               pnttg1sol(NbrSol));
235              pnttg1sol(NbrSol) = gp_Pnt2d(TheTool::Value(Cu1,pararg1(NbrSol)));
236              pntcen3(NbrSol) = Center;
237            }
238          }
239          WellDone = Standard_True;
240        }
241      }
242    }
243  }
244
245 //=========================================================================
246 //  Cercle tangent  :  a un cercle Qualified1 (C1).                       +
247 //         centre   :  sur une droite OnLine.                             +
248 //         de rayon :  Radius.                                            +
249 //                                                                        + 
250 //  On initialise le tableau de solutions cirsol ainsi que tous les       +
251 //  champs.                                                               +
252 //  On elimine en fonction du qualifieur les cas ne presentant pas de     +
253 //  solutions.                                                            +
254 //  On resoud l equation du second degre indiquant que le point de centre +
255 //  recherche (xc,yc) est a une distance Radius du cercle C1 et           +
256 //                        sur la droite OnLine.                           +
257 //  Les solutions sont representees par les cercles :                     +
258 //                   - de centre Pntcen(xc,yc)                            +
259 //                   - de rayon Radius.                                   +
260 //=========================================================================
261
262 GccGeo_Circ2dTanOnRad::
263    GccGeo_Circ2dTanOnRad (const GccEnt_QualifiedCirc& Qualified1,
264                           const TheCurve&             OnCurv    ,
265                           const Standard_Real         Radius    ,
266                           const Standard_Real         Tolerance ):
267
268 //=========================================================================
269 // Initialisation des champs.                                             +
270 //=========================================================================
271
272    cirsol(1,8)     ,
273    qualifier1(1,8) ,
274    TheSame1(1,8)   ,
275    pnttg1sol(1,8)  ,
276    pntcen3(1,8)    ,
277    par1sol(1,8)    ,
278    pararg1(1,8)    ,
279    parcen3(1,8)    
280 {
281
282 //=========================================================================
283 // Traitement.                                                            +
284 //=========================================================================
285
286    gp_Dir2d dirx(1.0,0.0);
287    Standard_Real thefirst = -100000.;
288    Standard_Real thelast  =  100000.;
289    Standard_Real firstparam;
290    Standard_Real lastparam;
291    Standard_Real Tol = Abs(Tolerance);
292    Standard_Integer nbrcote1=0;
293    WellDone = Standard_False;
294    NbrSol = 0;
295    if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || 
296          Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
297      GccEnt_BadQualifier::Raise();
298      return;
299    }
300    TColStd_Array1OfReal cote1(1,2);
301    gp_Circ2d C1 = Qualified1.Qualified();
302    gp_Pnt2d center1(C1.Location());
303    Standard_Real R1 = C1.Radius();
304
305    if (Radius < 0.0) {
306      Standard_NegativeValue::Raise();
307    }
308    else {
309      if (Qualified1.IsEnclosed()) {
310 //    ===========================
311        nbrcote1 = 1;
312        cote1(1) = Radius;
313      }
314      else if(Qualified1.IsOutside()) {
315 //   ===============================
316        nbrcote1 = 1;
317        cote1(1) = -Radius;
318      }
319      else if(Qualified1.IsUnqualified()) {
320 //   ===================================
321        nbrcote1 = 2;
322        cote1(1) = Radius;
323        cote1(2) = -Radius;
324      }
325      TheIntConicCurve Intp;
326      for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
327        gp_Circ2d Circ(C1.XAxis(),R1 + cote1(jcote1));
328        IntRes2d_Domain D1(ElCLib::Value(0.,Circ),   0.,Tol,
329                           ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol);
330        D1.SetEquivalentParameters(0.,2.*M_PI);
331        firstparam = Max(TheTool::FirstParameter(OnCurv),thefirst);
332        lastparam  = Min(TheTool::LastParameter(OnCurv),thelast);
333        IntRes2d_Domain D2(TheTool::Value(OnCurv,firstparam),firstparam,Tol,
334                           TheTool::Value(OnCurv,lastparam),lastparam,Tol);
335        Intp.Perform(Circ,D1,OnCurv,D2,Tol,Tol);
336        if (Intp.IsDone()) {
337          if (!Intp.IsEmpty()) {
338            for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
339              NbrSol++;
340              gp_Pnt2d Center(Intp.Point(i).Value());
341              cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
342 //           =======================================================
343              Standard_Real distcc1 = Center.Distance(center1);
344              if (!Qualified1.IsUnqualified()) { 
345                qualifier1(NbrSol) = Qualified1.Qualifier();
346              }
347              else if (Abs(distcc1+Radius-R1) < Tol) {
348                qualifier1(NbrSol) = GccEnt_enclosed;
349              }
350              else if (Abs(distcc1-R1-Radius) < Tol) {
351                qualifier1(NbrSol) = GccEnt_outside;
352              }
353              else { qualifier1(NbrSol) = GccEnt_enclosing; }
354              TheSame1(NbrSol) = 0;
355              pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
356              parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
357              par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
358                                                     pnttg1sol(NbrSol));
359              pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1);
360              pntcen3(NbrSol) = Center;
361            }
362          }
363          WellDone = Standard_True;
364        }
365      }
366    }
367  }
368
369 //=========================================================================
370 //  Cercle tangent  :  a un cercle Qualified1 (C1).                       +
371 //         centre   :  sur une droite OnLine.                             +
372 //         de rayon :  Radius.                                            +
373 //                                                                        + 
374 //  On initialise le tableau de solutions cirsol ainsi que tous les       +
375 //  champs.                                                               +
376 //  On elimine en fonction du qualifieur les cas ne presentant pas de     +
377 //  solutions.                                                            +
378 //  On resoud l equation du second degre indiquant que le point de centre +
379 //  recherche (xc,yc) est a une distance Radius du cercle C1 et           +
380 //                        sur la droite OnLine.                           +
381 //  Les solutions sont representees par les cercles :                     +
382 //                   - de centre Pntcen(xc,yc)                            +
383 //                   - de rayon Radius.                                   +
384 //=========================================================================
385
386 GccGeo_Circ2dTanOnRad::
387    GccGeo_Circ2dTanOnRad (const GccEnt_QualifiedLin& Qualified1,
388                           const TheCurve&            OnCurv    ,
389                           const Standard_Real        Radius    ,
390                           const Standard_Real        Tolerance ):
391
392 //=========================================================================
393 // Initialisation des champs.                                             +
394 //=========================================================================
395
396    cirsol(1,8)     ,
397    qualifier1(1,8) ,
398    TheSame1(1,8)   ,
399    pnttg1sol(1,8)  ,
400    pntcen3(1,8)    ,
401    par1sol(1,8)    ,
402    pararg1(1,8)    ,
403    parcen3(1,8)    
404 {
405
406 //=========================================================================
407 // Traitement.                                                            +
408 //=========================================================================
409
410    gp_Dir2d dirx(1.0,0.0);
411    Standard_Real thefirst = -100000.;
412    Standard_Real thelast  =  100000.;
413    Standard_Real firstparam;
414    Standard_Real lastparam;
415    Standard_Real Tol = Abs(Tolerance);
416    WellDone = Standard_False;
417    NbrSol = 0;
418    if (!(Qualified1.IsEnclosed() ||
419          Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
420      GccEnt_BadQualifier::Raise();
421      return;
422    }
423    Standard_Integer nbrcote1=0;
424    TColStd_Array1OfReal cote1(1,2);
425    gp_Lin2d L1 = Qualified1.Qualified();
426    gp_Pnt2d origin1(L1.Location());
427    gp_Dir2d dir1(L1.Direction());
428    gp_Dir2d norm1(-dir1.Y(),dir1.X());
429
430    if (Radius < 0.0) {
431      Standard_NegativeValue::Raise();
432    }
433    else {
434      if (Qualified1.IsEnclosed()) {
435 //    ===========================
436        nbrcote1 = 1;
437        cote1(1) = Radius;
438      }
439      else if(Qualified1.IsOutside()) {
440 //   ===============================
441        nbrcote1 = 1;
442        cote1(1) = -Radius;
443      }
444      else if(Qualified1.IsUnqualified()) {
445 //   ===================================
446        nbrcote1 = 2;
447        cote1(1) = Radius;
448        cote1(2) = -Radius;
449      }
450      TheIntConicCurve Intp;
451      for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
452        gp_Pnt2d Point(dir1.XY()+cote1(jcote1)*norm1.XY());
453        gp_Lin2d Line(Point,dir1); // ligne avec deport.
454        IntRes2d_Domain D1;
455        firstparam = Max(TheTool::FirstParameter(OnCurv),thefirst);
456        lastparam  = Min(TheTool::LastParameter(OnCurv),thelast);
457        IntRes2d_Domain D2(TheTool::Value(OnCurv,firstparam),firstparam,Tol,
458                           TheTool::Value(OnCurv,lastparam),lastparam,Tol);
459        Intp.Perform(Line,D1,OnCurv,D2,Tol,Tol);
460        if (Intp.IsDone()) {
461          if (!Intp.IsEmpty()) {
462            for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
463              NbrSol++;
464              gp_Pnt2d Center(Intp.Point(i).Value());
465              cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
466 //           =======================================================
467              gp_Dir2d dc1(origin1.XY()-Center.XY());
468              if (!Qualified1.IsUnqualified()) { 
469                qualifier1(NbrSol) = Qualified1.Qualifier();
470              }
471              else if (dc1.Dot(norm1) > 0.0) {   
472                qualifier1(NbrSol) = GccEnt_outside; 
473              }
474              else { qualifier1(NbrSol) = GccEnt_enclosed; }
475              TheSame1(NbrSol) = 0;
476              pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
477              parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
478              par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
479                                               pnttg1sol(NbrSol));
480              pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1);
481              pntcen3(NbrSol) = Center;
482            }
483          }
484          WellDone = Standard_True;
485        }
486      }
487    }
488  }
489
490 //=========================================================================
491 //  Cercle tangent  :  a un cercle Qualified1 (C1).                       +
492 //         centre   :  sur une droite OnLine.                             +
493 //         de rayon :  Radius.                                            +
494 //                                                                        + 
495 //  On initialise le tableau de solutions cirsol ainsi que tous les       +
496 //  champs.                                                               +
497 //  On elimine en fonction du qualifieur les cas ne presentant pas de     +
498 //  solutions.                                                            +
499 //  On resoud l equation du second degre indiquant que le point de centre +
500 //  recherche (xc,yc) est a une distance Radius du cercle C1 et           +
501 //                        sur la droite OnLine.                           +
502 //  Les solutions sont representees par les cercles :                     +
503 //                   - de centre Pntcen(xc,yc)                            +
504 //                   - de rayon Radius.                                   +
505 //=========================================================================
506
507 GccGeo_Circ2dTanOnRad::
508    GccGeo_Circ2dTanOnRad (const TheQCurve&    Qualified1,
509                           const TheCurve&     OnCurv    ,
510                           const Standard_Real Radius    ,
511                           const Standard_Real Tolerance ):
512
513 //=========================================================================
514 // Initialisation des champs.                                             +
515 //=========================================================================
516
517    cirsol(1,8)     ,
518    qualifier1(1,8) ,
519    TheSame1(1,8)   ,
520    pnttg1sol(1,8)  ,
521    pntcen3(1,8)    ,
522    par1sol(1,8)    ,
523    pararg1(1,8)    ,
524    parcen3(1,8)    
525 {
526
527 //=========================================================================
528 // Traitement.                                                            +
529 //=========================================================================
530
531    gp_Dir2d dirx(1.0,0.0);
532    Standard_Real thefirst = -100000.;
533    Standard_Real thelast  =  100000.;
534    Standard_Real firstparam;
535    Standard_Real lastparam;
536    Standard_Real Tol = Abs(Tolerance);
537    Standard_Integer nbrcote1=0;
538    WellDone = Standard_False;
539    NbrSol = 0;
540    if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || 
541          Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
542      GccEnt_BadQualifier::Raise();
543      return;
544    }
545    TColStd_Array1OfReal cote1(1,2);
546    TheCurve Cu1 = Qualified1.Qualified();
547
548    if (Radius < 0.0) {
549      Standard_NegativeValue::Raise();
550    }
551    else {
552      if (Qualified1.IsEnclosed()) {
553 //    ===========================
554        nbrcote1 = 1;
555        cote1(1) = Radius;
556      }
557      else if(Qualified1.IsOutside()) {
558 //   ===============================
559        nbrcote1 = 1;
560        cote1(1) = -Radius;
561      }
562      else if(Qualified1.IsUnqualified()) {
563 //   ===================================
564        nbrcote1 = 2;
565        cote1(1) = Radius;
566        cote1(2) = -Radius;
567      }
568      TheIntCurveCurve Intp;
569      for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
570        Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1);
571        TheParGenCurve C1(HCu1,cote1(jcote1));
572        firstparam = Max(TheCurvePGTool::FirstParameter(C1),thefirst);
573        lastparam  = Min(TheCurvePGTool::LastParameter(C1),thelast);
574        IntRes2d_Domain D1(TheCurvePGTool::Value(C1,firstparam),firstparam,Tol,
575                           TheCurvePGTool::Value(C1,lastparam),lastparam,Tol);
576        Handle(TheHParGenCurve) HOnCurv = new TheHParGenCurve(OnCurv);
577        TheParGenCurve C2(HOnCurv);
578        firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst);
579        lastparam  = Min(TheCurvePGTool::LastParameter(C2),thelast);
580        IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol,
581                           TheCurvePGTool::Value(C2,lastparam),lastparam,Tol);
582        Intp.Perform(C1,D1,C2,D2,Tol,Tol);
583        if (Intp.IsDone()) {
584          if (!Intp.IsEmpty()) {
585            for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
586              NbrSol++;
587              gp_Pnt2d Center(Intp.Point(i).Value());
588              cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
589 //           =======================================================
590              qualifier1(NbrSol) = Qualified1.Qualifier();
591              TheSame1(NbrSol) = 0;
592              pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
593              parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
594              par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
595                                               pnttg1sol(NbrSol));
596              pnttg1sol(NbrSol) = gp_Pnt2d(TheTool::Value(Cu1,pararg1(NbrSol)));
597              pntcen3(NbrSol) = Center;
598            }
599          }
600          WellDone = Standard_True;
601        }
602      }
603    }
604  }
605
606 //=========================================================================
607 //  Cercle tangent  :  a un cercle Qualified1 (C1).                       +
608 //         centre   :  sur une droite OnLine.                             +
609 //         de rayon :  Radius.                                            +
610 //                                                                        + 
611 //  On initialise le tableau de solutions cirsol ainsi que tous les       +
612 //  champs.                                                               +
613 //  On elimine en fonction du qualifieur les cas ne presentant pas de     +
614 //  solutions.                                                            +
615 //  On resoud l equation du second degre indiquant que le point de centre +
616 //  recherche (xc,yc) est a une distance Radius du cercle C1 et           +
617 //                        sur la droite OnLine.                           +
618 //  Les solutions sont representees par les cercles :                     +
619 //                   - de centre Pntcen(xc,yc)                            +
620 //                   - de rayon Radius.                                   +
621 //=========================================================================
622
623 GccGeo_Circ2dTanOnRad::
624    GccGeo_Circ2dTanOnRad (const gp_Pnt2d&     Point1    ,
625                           const TheCurve&     OnCurv    ,
626                           const Standard_Real Radius    ,
627                           const Standard_Real Tolerance ):
628
629 //=========================================================================
630 // Initialisation des champs.                                             +
631 //=========================================================================
632
633    cirsol(1,8)     ,
634    qualifier1(1,8) ,
635    TheSame1(1,8)   ,
636    pnttg1sol(1,8)  ,
637    pntcen3(1,8)    ,
638    par1sol(1,8)    ,
639    pararg1(1,8)    ,
640    parcen3(1,8)    
641 {
642
643 //=========================================================================
644 // Traitement.                                                            +
645 //=========================================================================
646
647    gp_Dir2d dirx(1.0,0.0);
648    Standard_Real thefirst = -100000.;
649    Standard_Real thelast  =  100000.;
650    Standard_Real firstparam;
651    Standard_Real lastparam;
652    Standard_Real Tol = Abs(Tolerance);
653    WellDone = Standard_False;
654    NbrSol = 0;
655
656    if (Radius < 0.0) {
657      Standard_NegativeValue::Raise();
658    }
659    else {
660 //     gp_Dir2d Dir(-y1dir,x1dir);
661      gp_Circ2d Circ(gp_Ax2d(Point1,gp_Dir2d(1.,0.)),Radius);
662      IntRes2d_Domain D1(ElCLib::Value(0.,Circ),   0.,Tol,
663                         ElCLib::Value(2.*M_PI,Circ),2*M_PI,Tol);
664      D1.SetEquivalentParameters(0.,2.*M_PI);
665      firstparam = Max(TheTool::FirstParameter(OnCurv),thefirst);
666      lastparam  = Min(TheTool::LastParameter(OnCurv),thelast);
667      IntRes2d_Domain D2(TheTool::Value(OnCurv,firstparam),firstparam,Tol,
668                         TheTool::Value(OnCurv,lastparam),lastparam,Tol);
669      TheIntConicCurve Intp(Circ,D1,OnCurv,D2,Tol,Tol);
670      if (Intp.IsDone()) {
671        if (!Intp.IsEmpty()) {
672          for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
673            NbrSol++;
674            gp_Pnt2d Center(Intp.Point(i).Value());
675            cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
676 //         =======================================================
677            qualifier1(NbrSol) = GccEnt_noqualifier;
678            TheSame1(NbrSol) = 0;
679            pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
680            parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
681            par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
682                                             pnttg1sol(NbrSol));
683            pnttg1sol(NbrSol) = Point1;
684            pntcen3(NbrSol) = Center;
685          }
686          WellDone = Standard_True;
687        }
688      }
689    }
690  }
691
692 //=========================================================================
693
694 Standard_Boolean GccGeo_Circ2dTanOnRad::
695    IsDone () const { return WellDone; }
696
697 Standard_Integer GccGeo_Circ2dTanOnRad::
698    NbSolutions () const { return NbrSol; }
699
700 gp_Circ2d GccGeo_Circ2dTanOnRad::
701    ThisSolution (const Standard_Integer Index) const 
702 {
703   
704   if (Index > NbrSol || Index <= 0)
705     Standard_OutOfRange::Raise();
706   
707   return cirsol(Index);
708 }
709
710 void GccGeo_Circ2dTanOnRad::
711   WhichQualifier(const Standard_Integer Index   ,
712                        GccEnt_Position& Qualif1 ) const
713 {
714   if (!WellDone) { StdFail_NotDone::Raise(); }
715   else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
716   else {
717     Qualif1 = qualifier1(Index);
718   }
719 }
720
721 void GccGeo_Circ2dTanOnRad::
722    Tangency1 (const Standard_Integer Index,
723                  Standard_Real&   ParSol,
724                  Standard_Real&   ParArg,
725               gp_Pnt2d& PntSol) const{
726    if (!WellDone) {
727      StdFail_NotDone::Raise();
728    }
729    else if (Index <= 0 ||Index > NbrSol) {
730      Standard_OutOfRange::Raise();
731    }
732    else {
733      ParSol = par1sol(Index);
734      ParArg = pararg1(Index);
735      PntSol = gp_Pnt2d(pnttg1sol(Index));
736    }
737  }
738
739 void GccGeo_Circ2dTanOnRad::
740    CenterOn3 (const Standard_Integer Index,
741                     Standard_Real&   ParArg, 
742                     gp_Pnt2d&        PntSol) const {
743    if (!WellDone) {
744      StdFail_NotDone::Raise();
745    }
746    else if (Index <= 0 ||Index > NbrSol) {
747      Standard_OutOfRange::Raise();
748    }
749    else {
750      ParArg = parcen3(Index);
751      PntSol = pnttg1sol(Index);
752    }
753  }
754
755 Standard_Boolean GccGeo_Circ2dTanOnRad::
756    IsTheSame1 (const Standard_Integer Index) const
757 {
758   if (!WellDone) StdFail_NotDone::Raise();
759   if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise();
760   
761   if (TheSame1(Index) == 0) 
762     return Standard_False;
763   
764   return Standard_True;
765 }