7fd59977 |
1 | // File GccAna_Circ2d3Tan.cxx_9, REG 08/07/91 |
2 | |
3 | #include <GccAna_Circ2d3Tan.jxx> |
4 | |
5 | #include <ElCLib.hxx> |
6 | #include <IntAna2d_AnaIntersection.hxx> |
7 | #include <IntAna2d_IntPoint.hxx> |
8 | #include <gp_Lin2d.hxx> |
9 | #include <gp_Circ2d.hxx> |
10 | #include <gp_Dir2d.hxx> |
11 | #include <GccAna_Lin2dBisec.hxx> |
12 | #include <GccEnt_BadQualifier.hxx> |
13 | |
14 | //========================================================================= |
15 | // Creation d un cercle passant par trois points. + |
16 | // Trois cas de figures : + |
17 | // 1/ Les trois points sont confondus. + |
18 | // ----------------------------------- + |
19 | // Le resultat est le cercle centre en Point1 de rayon zero. + |
20 | // 2/ Deux des trois points sont confondus. + |
21 | // ---------------------------------------- + |
22 | // On cree la mediatrice a deux points non confondus ainsi que la + |
23 | // droite passant par ces deux points. + |
24 | // La solution a pour centre l intersection de ces deux droite et + |
25 | // pour rayon la distance entre ce centre et l un des trois points. + |
26 | // 3/ Les trois points sont distinct. + |
27 | // ---------------------------------- + |
28 | // |
29 | //========================================================================= |
30 | |
31 | GccAna_Circ2d3Tan:: |
32 | GccAna_Circ2d3Tan (const gp_Pnt2d& Point1 , |
33 | const gp_Pnt2d& Point2 , |
34 | const gp_Pnt2d& Point3 , |
35 | const Standard_Real Tolerance ): |
36 | |
37 | //========================================================================= |
38 | // Initialisation des champs. + |
39 | //========================================================================= |
40 | |
41 | cirsol(1,1) , |
42 | qualifier1(1,1) , |
43 | qualifier2(1,1) , |
44 | qualifier3(1,1) , |
45 | TheSame1(1,1) , |
46 | TheSame2(1,1) , |
47 | TheSame3(1,1) , |
48 | pnttg1sol(1,1) , |
49 | pnttg2sol(1,1) , |
50 | pnttg3sol(1,1) , |
51 | par1sol(1,1) , |
52 | par2sol(1,1) , |
53 | par3sol(1,1) , |
54 | pararg1(1,1) , |
55 | pararg2(1,1) , |
56 | pararg3(1,1) |
57 | { |
58 | |
59 | gp_Dir2d dirx(1.0,0.0); |
60 | WellDone = Standard_False; |
61 | NbrSol = 0; |
62 | |
63 | //========================================================================= |
64 | // Traitement. + |
65 | //========================================================================= |
66 | |
67 | Standard_Real dist1 = Point1.Distance(Point2); |
68 | Standard_Real dist2 = Point1.Distance(Point3); |
69 | Standard_Real dist3 = Point2.Distance(Point3); |
70 | |
71 | qualifier1(1) = GccEnt_noqualifier; |
72 | qualifier2(1) = GccEnt_noqualifier; |
73 | qualifier3(1) = GccEnt_noqualifier; |
74 | |
75 | if ((dist1 < Tolerance) && (dist2 < Tolerance) && (dist3 < Tolerance)) { |
76 | NbrSol++; |
77 | WellDone = Standard_True; |
78 | cirsol(1) = gp_Circ2d(gp_Ax2d(Point1,dirx),0.0); |
79 | // =============================================== |
80 | TheSame1(1) = 0; |
81 | TheSame2(1) = 0; |
82 | TheSame3(1) = 0; |
83 | pnttg1sol(1) = Point1; |
84 | pnttg2sol(1) = Point2; |
85 | pnttg3sol(1) = Point3; |
86 | par1sol(1) =0.0; |
87 | par2sol(1) =0.0; |
88 | par3sol(1) =0.0; |
89 | pararg1(1) =0.0; |
90 | pararg2(1) =0.0; |
91 | pararg3(1) =0.0; |
92 | } |
93 | else { |
94 | gp_Lin2d L1; |
95 | gp_Lin2d L2; |
96 | if (dist1 >= Tolerance) { |
97 | L1 = gp_Lin2d(gp_Pnt2d((Point1.XY()+Point2.XY())/2.0), |
98 | gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X())); |
99 | } |
100 | if (dist2 >= Tolerance) { |
101 | L2 = gp_Lin2d(gp_Pnt2d((Point1.XY()+Point3.XY())/2.0), |
102 | gp_Dir2d(Point1.Y()-Point3.Y(),Point3.X()-Point1.X())); |
103 | } |
104 | if (dist2 <= Tolerance) { |
105 | L2 = gp_Lin2d(Point1, |
106 | gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X())); |
107 | } |
108 | else if (dist1 <= Tolerance) { |
109 | L1 = gp_Lin2d(Point1, |
110 | gp_Dir2d(Point1.Y()-Point3.Y(),Point3.X()-Point1.X())); |
111 | } |
112 | else if (dist3 <= Tolerance) { |
113 | L2 = gp_Lin2d(Point1, |
114 | gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X())); |
115 | } |
116 | IntAna2d_AnaIntersection Intp(L1,L2); |
117 | if (Intp.IsDone()) { |
118 | if (!Intp.IsEmpty()) { |
119 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { |
120 | NbrSol++; |
121 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Intp.Point(i).Value(),dirx), |
122 | // =============================================================== |
123 | Point1.Distance(Intp.Point(i).Value())); |
124 | // ======================================= |
125 | |
126 | TheSame1(NbrSol) = 0; |
127 | TheSame2(NbrSol) = 0; |
128 | TheSame3(NbrSol) = 0; |
129 | pnttg1sol(NbrSol) = Point1; |
130 | pnttg2sol(NbrSol) = Point2; |
131 | pnttg3sol(NbrSol) = Point3; |
132 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg1sol(NbrSol)); |
133 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg2sol(NbrSol)); |
134 | par3sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg3sol(NbrSol)); |
135 | pararg1(NbrSol) =0.0; |
136 | pararg2(NbrSol) =0.0; |
137 | pararg3(NbrSol) =0.0; |
138 | } |
139 | } |
140 | WellDone = Standard_True; |
141 | } |
142 | } |
143 | } |
144 | |