0022627: Change OCCT memory management defaults
[occt.git] / src / GccAna / GccAna_Circ2d2TanOn_5.cxx
1 // File:        GccAna_Circ2d2TanOn_5.cxx
2 // Created:     Thu Jan  2 15:55:26 1992
3 // Author:      Remi GILET
4 //              <reg@topsn3>
5
6 #include <GccAna_Circ2d2TanOn.jxx>
7
8 #include <ElCLib.hxx>
9 #include <gp_Dir2d.hxx>
10 #include <gp_Ax2d.hxx>
11 #include <IntAna2d_AnaIntersection.hxx>
12 #include <IntAna2d_IntPoint.hxx>
13
14 //=========================================================================
15 //   Creation of a circle passing by : 2 points Point1 and Point2.        +
16 //                        Centered on  : 1 straight line OnLine.                  +
17 //   with a Tolerance of precision  : Tolerance.                        +
18 //                                                                        +
19 //   Create L1 straight line of points equidistant from Point1 and Point2.     +
20 //   Then create solutions cirsol such as :                        +
21 //   cirsol is all circle with center at the intersections of  +
22 //   L1 with OnLine and the radius the distance between Point1 and the point   +
23 //   calculated above.                                                   +
24 //=========================================================================
25
26 GccAna_Circ2d2TanOn::
27    GccAna_Circ2d2TanOn (const gp_Pnt2d&      Point1     , 
28                         const gp_Pnt2d&      Point2     ,
29                         const gp_Lin2d&      OnLine     ,
30                         const Standard_Real  Tolerance  ):
31    cirsol(1,2)      ,
32    qualifier1(1,2)  ,
33    qualifier2(1,2),
34    TheSame1(1,2)  ,
35    TheSame2(1,2)  ,
36    pnttg1sol(1,2)   ,
37    pnttg2sol(1,2)   ,
38    pntcen(1,2)      ,
39    par1sol(1,2)     ,
40    par2sol(1,2)     ,
41    pararg1(1,2)     ,
42    pararg2(1,2)     ,
43    parcen3(1,2)     
44 {
45   TheSame1.Init(0);
46   TheSame2.Init(0);
47   WellDone = Standard_False;
48   NbrSol = 0;
49   
50   gp_Dir2d dirx(1.,0.);
51   Standard_Real dist   = Point1.Distance(Point2);
52   if (dist < Abs(Tolerance)) { WellDone = Standard_True; }
53   else {
54     gp_Lin2d L1(gp_Pnt2d((Point1.XY()+Point2.XY())/2.0),
55                 gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X()));
56     IntAna2d_AnaIntersection Intp(L1,OnLine);
57     if (Intp.IsDone()) {
58       if (!Intp.IsEmpty()) {
59         for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
60           NbrSol++;
61           gp_Ax2d axe(Intp.Point(i).Value(),dirx);
62           cirsol(NbrSol)=gp_Circ2d(axe,Point1.Distance(Intp.Point(i).Value()));
63 //        ====================================================================
64           qualifier1(NbrSol) = GccEnt_noqualifier;
65           qualifier2(NbrSol) = GccEnt_noqualifier;
66           pnttg1sol(NbrSol) = Point1;
67           pnttg2sol(NbrSol) = Point2;
68           pntcen(NbrSol) = cirsol(NbrSol).Location();
69           pararg1(NbrSol) = 0.;
70           pararg2(NbrSol) = 0.;
71           par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg1sol(NbrSol));
72           par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg2sol(NbrSol));
73           parcen3(NbrSol)=ElCLib::Parameter(OnLine,pntcen(NbrSol));
74         }
75       }
76       WellDone = Standard_True;
77     }
78   }
79 }
80
81
82
83
84
85