0022312: Translation of french commentaries in OCCT files
[occt.git] / src / GccAna / GccAna_Circ2d3Tan_2.cxx
CommitLineData
7fd59977 1// File GccAna_Circ2d3Tan_2.cxx, REG 08/07/91
2
3#include <GccAna_Circ2d3Tan.jxx>
4
5#include <IntAna2d_AnaIntersection.hxx>
6#include <IntAna2d_IntPoint.hxx>
7#include <gp_Lin2d.hxx>
8#include <ElCLib.hxx>
9#include <gp_Circ2d.hxx>
10#include <gp_Dir2d.hxx>
11#include <TColStd_Array1OfReal.hxx>
12#include <GccAna_CircLin2dBisec.hxx>
13#include <GccAna_Lin2dBisec.hxx>
14#include <GccInt_IType.hxx>
15#include <GccInt_BLine.hxx>
16#include <GccInt_BParab.hxx>
17#include <IntAna2d_Conic.hxx>
18#include <GccEnt_BadQualifier.hxx>
19
20//=========================================================================
0d969553 21// Creation of a circle tangent to a circle and two straight lines. +
7fd59977 22//=========================================================================
23
24GccAna_Circ2d3Tan::GccAna_Circ2d3Tan (const GccEnt_QualifiedCirc& Qualified1 ,
25 const GccEnt_QualifiedLin& Qualified2 ,
26 const GccEnt_QualifiedLin& Qualified3 ,
27 const Standard_Real Tolerance )
28
29//=========================================================================
0d969553 30// Initialisation of fields. +
7fd59977 31//=========================================================================
32
33:cirsol(1,8) ,
34qualifier1(1,8) ,
35qualifier2(1,8) ,
36qualifier3(1,8) ,
37TheSame1(1,8) ,
38TheSame2(1,8) ,
39TheSame3(1,8) ,
40pnttg1sol(1,8) ,
41pnttg2sol(1,8) ,
42pnttg3sol(1,8) ,
43par1sol(1,8) ,
44par2sol(1,8) ,
45par3sol(1,8) ,
46pararg1(1,8) ,
47pararg2(1,8) ,
48pararg3(1,8)
49{
50
51 TheSame1.Init(0);
52
53 gp_Dir2d dirx(1.0,0.0);
54 Standard_Real Tol = Abs(Tolerance);
55 WellDone = Standard_False;
56 NbrSol = 0;
57 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
58 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
59 !(Qualified2.IsEnclosed() ||
60 Qualified2.IsOutside() || Qualified2.IsUnqualified()) ||
61 !(Qualified3.IsEnclosed() ||
62 Qualified3.IsOutside() || Qualified3.IsUnqualified())) {
63 GccEnt_BadQualifier::Raise();
64 return;
65 }
66
67//=========================================================================
0d969553 68// Processing. +
7fd59977 69//=========================================================================
70
71 gp_Circ2d C1 = Qualified1.Qualified();
72 gp_Lin2d L2 = Qualified2.Qualified();
73 gp_Lin2d L3 = Qualified3.Qualified();
74 Standard_Real R1 = C1.Radius();
75 gp_Pnt2d center1(C1.Location());
76 gp_Pnt2d origin2(L2.Location());
77 gp_Dir2d dir2(L2.Direction());
78 gp_Dir2d normL2(-dir2.Y(),dir2.X());
79 gp_Pnt2d origin3(L3.Location());
80 gp_Dir2d dir3(L3.Direction());
81 gp_Dir2d normL3(-dir3.Y(),dir3.X());
82
83 TColStd_Array1OfReal Radius(1,2);
84 GccAna_CircLin2dBisec Bis1(C1,L2);
85 GccAna_Lin2dBisec Bis2(L2,L3);
86 if (Bis1.IsDone() && Bis2.IsDone()) {
87 Standard_Integer nbsolution1 = Bis1.NbSolutions();
88 Standard_Integer nbsolution2 = Bis2.NbSolutions();
89 for (Standard_Integer i = 1 ; i <= nbsolution1; i++) {
90 Handle(GccInt_Bisec) Sol1 = Bis1.ThisSolution(i);
91 GccInt_IType typ1 = Sol1->ArcType();
92 IntAna2d_AnaIntersection Intp;
93 for (Standard_Integer k = 1 ; k <= nbsolution2; k++) {
94 if (typ1 == GccInt_Lin) {
95 Intp.Perform(Sol1->Line(),Bis2.ThisSolution(k));
96 }
97 else if (typ1 == GccInt_Par) {
98 Intp.Perform(Bis2.ThisSolution(k),IntAna2d_Conic(Sol1->Parabola()));
99 }
100 if (Intp.IsDone()) {
101 if ((!Intp.IsEmpty())&&(!Intp.ParallelElements())&&
102 (!Intp.IdenticalElements())) {
103 for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) {
104 gp_Pnt2d Center(Intp.Point(j).Value());
105 Standard_Real dist1 = Center.Distance(center1);
106 Standard_Real dist2 = L2.Distance(Center);
107 Standard_Real dist3 = L3.Distance(Center);
108 Standard_Integer nbsol1 = 0;
109 Standard_Integer nbsol2 = 0;
110 Standard_Integer nbsol3 = 0;
111 Standard_Boolean ok = Standard_False;
112 if (Qualified1.IsEnclosed()) {
113 if (dist1-R1 < Tolerance) {
114 Radius(1) = Abs(R1-dist1);
115 nbsol1 = 1;
116 ok = Standard_True;
117 }
118 }
119 else if (Qualified1.IsOutside()) {
120 if (R1-dist1 < Tolerance) {
121 Radius(1) = Abs(R1-dist1);
122 nbsol1 = 1;
123 ok = Standard_True;
124 }
125 }
126 else if (Qualified1.IsEnclosing()) {
127 ok = Standard_True;
128 nbsol1 = 1;
129 Radius(1) = Abs(R1-dist1);
130 }
131 else if (Qualified1.IsUnqualified()) {
132 ok = Standard_True;
133 nbsol1 = 2;
134 Radius(1) = Abs(R1-dist1);
135 Radius(2) = R1+dist1;
136 }
137 if (Qualified2.IsEnclosed() && ok) {
138 if ((((origin2.X()-Center.X())*(-dir2.Y()))+
139 ((origin2.Y()-Center.Y())*(dir2.X())))<=0){
140 for (Standard_Integer ii = 1 ; ii <= nbsol1 ; ii++) {
141 if (Abs(dist2-Radius(ii)) < Tol) {
142 ok = Standard_True;
143 nbsol2 = 1;
144 Radius(1) = Radius(ii);
145 }
146 }
147 }
148 }
149 else if (Qualified2.IsOutside() && ok) {
150 if ((((origin2.X()-Center.X())*(-dir2.Y()))+
151 ((origin2.Y()-Center.Y())*(dir2.X())))>=0){
152 for (Standard_Integer ii = 1 ; ii <= nbsol1 ; ii++) {
153 if (Abs(dist2-Radius(ii)) < Tol) {
154 ok = Standard_True;
155 nbsol2 = 1;
156 Radius(1) = Radius(ii);
157 }
158 }
159 }
160 }
161 else if (Qualified2.IsUnqualified() && ok) {
162 for (Standard_Integer ii = 1 ; ii <= nbsol1 ; ii++) {
163 if (Abs(dist2-Radius(ii)) < Tol) {
164 ok = Standard_True;
165 nbsol2 = 1;
166 Radius(1) = Radius(ii);
167 }
168 }
169 }
170 if (Qualified3.IsEnclosed() && ok) {
171 if ((((origin3.X()-Center.X())*(-dir3.Y()))+
172 ((origin3.Y()-Center.Y())*(dir3.X())))<=0){
173 if (Abs(dist3-Radius(1)) < Tol) {
174 ok = Standard_True;
175 nbsol3 = 1;
176 }
177 }
178 }
179 else if (Qualified3.IsOutside() && ok) {
180 if ((((origin3.X()-Center.X())*(-dir3.Y()))+
181 ((origin3.Y()-Center.Y())*(dir3.X())))>=0){
182 if (Abs(dist3-Radius(1)) < Tol) {
183 ok = Standard_True;
184 nbsol3 = 1;
185 }
186 }
187 }
188 else if (Qualified3.IsUnqualified() && ok) {
189 if (Abs(dist3-Radius(1)) < Tol) {
190 ok = Standard_True;
191 nbsol3 = 1;
192 }
193 }
194 if (ok) {
195 for (k = 1 ; k <= nbsol3 ; k++) {
196 NbrSol++;
197 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(k));
198// ==========================================================
199 Standard_Real distcc1 = Center.Distance(center1);
200 if (!Qualified1.IsUnqualified()) {
201 qualifier1(NbrSol) = Qualified1.Qualifier();
202 }
203 else if (Abs(distcc1+Radius(k)-R1) < Tol) {
204 qualifier1(NbrSol) = GccEnt_enclosed;
205 }
206 else if (Abs(distcc1-R1-Radius(k)) < Tol) {
207 qualifier1(NbrSol) = GccEnt_outside;
208 }
209 else { qualifier1(NbrSol) = GccEnt_enclosing; }
210 gp_Dir2d dc2(origin2.XY()-Center.XY());
211 if (!Qualified2.IsUnqualified()) {
212 qualifier2(NbrSol) = Qualified2.Qualifier();
213 }
214 else if (dc2.Dot(normL2) > 0.0) {
215 qualifier2(NbrSol) = GccEnt_outside;
216 }
217 else { qualifier2(NbrSol) = GccEnt_enclosed; }
218 gp_Dir2d dc3(origin3.XY()-Center.XY());
219 if (!Qualified3.IsUnqualified()) {
220 qualifier3(NbrSol) = Qualified3.Qualifier();
221 }
222 else if (dc3.Dot(normL3) > 0.0) {
223 qualifier3(NbrSol) = GccEnt_outside;
224 }
225 else { qualifier3(NbrSol) = GccEnt_enclosed; }
226 if (Center.Distance(center1) <= Tolerance &&
227 Abs(Radius(k)-R1) <= Tolerance) {
228 TheSame1(NbrSol) = 1;
229 }
230 else {
231 TheSame1(NbrSol) = 0;
232 gp_Dir2d dc(center1.XY()-Center.XY());
233 pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius(k)*dc.XY());
234 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
235 pnttg1sol(NbrSol));
236 pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol));
237 }
238 TheSame2(NbrSol) = 0;
239 TheSame3(NbrSol) = 0;
240 gp_Dir2d dc(origin2.XY()-Center.XY());
241 Standard_Real sign = dc.Dot(gp_Dir2d(-dir2.Y(),dir2.X()));
242 dc = gp_Dir2d(sign*gp_XY(-dir2.Y(),dir2.X()));
243 pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius(k)*dc.XY());
244 par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
245 pnttg2sol(NbrSol));
246 pararg2(NbrSol)=ElCLib::Parameter(L2,pnttg2sol(NbrSol));
247 dc = gp_Dir2d(origin3.XY()-Center.XY());
248 sign = dc.Dot(gp_Dir2d(-dir3.Y(),dir3.X()));
249 dc = gp_Dir2d(sign*gp_XY(-dir3.Y(),dir3.X()));
250 pnttg3sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius(k)*dc.XY());
251 par3sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
252 pnttg3sol(NbrSol));
253 pararg3(NbrSol)=ElCLib::Parameter(L3,pnttg3sol(NbrSol));
254 }
255 }
256 }
257 }
258 WellDone = Standard_True;
259 }
260 }
261 }
262 }
263 }
264
265