0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GccAna / GccAna_Circ2d3Tan_3.cxx
CommitLineData
7fd59977 1// File GccAna_Circ2d3Tan_3.cxx, REG 08/07/91
2
3#include <ElCLib.hxx>
4#include <GccAna_Circ2d3Tan.jxx>
5#include <IntAna2d_AnaIntersection.hxx>
6#include <IntAna2d_IntPoint.hxx>
7#include <gp_Lin2d.hxx>
8#include <gp_Circ2d.hxx>
9#include <gp_Dir2d.hxx>
10#include <TColStd_Array1OfReal.hxx>
11#include <GccAna_Lin2dBisec.hxx>
12#include <GccEnt_BadQualifier.hxx>
13
14//=========================================================================
0d969553
Y
15// Creation of a circle tangent to three straight lines. +
16// Create Bissectrices at Qualified1 and Qualified2 and +
17// Bissectrices at Qualified1 and Qualified3. +
18// Intersect bissectrices calculated in this way ==> Center points +
19// Choose the center point that corresponds to qualifiers and +
20// construct the solution of radius equal to the distance between the +
21// chosen center point and straight line Qualified1. +
7fd59977 22//=========================================================================
23
24GccAna_Circ2d3Tan::
25 GccAna_Circ2d3Tan (const GccEnt_QualifiedLin& Qualified1,
26 const GccEnt_QualifiedLin& Qualified2,
27 const GccEnt_QualifiedLin& Qualified3,
28 const Standard_Real
29#ifdef DEB
30 Tolerance
31#endif
32 ):
33
34//=========================================================================
0d969553 35// Initialization of fields. +
7fd59977 36//=========================================================================
37
38 cirsol(1,4) ,
39 qualifier1(1,4) ,
40 qualifier2(1,4) ,
41 qualifier3(1,4) ,
42 TheSame1(1,4) ,
43 TheSame2(1,4) ,
44 TheSame3(1,4) ,
45 pnttg1sol(1,4) ,
46 pnttg2sol(1,4) ,
47 pnttg3sol(1,4) ,
48 par1sol(1,4) ,
49 par2sol(1,4) ,
50 par3sol(1,4) ,
51 pararg1(1,4) ,
52 pararg2(1,4) ,
53 pararg3(1,4)
54{
55
56 TheSame1.Init(0);
57 TheSame2.Init(0);
58 TheSame3.Init(0);
59 gp_Dir2d dirx(1.0,0.0);
7fd59977 60 WellDone = Standard_False;
61 NbrSol = 0;
62 if (!(Qualified1.IsEnclosed() ||
63 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
64 !(Qualified2.IsEnclosed() ||
65 Qualified2.IsOutside() || Qualified2.IsUnqualified()) ||
66 !(Qualified3.IsEnclosed() ||
67 Qualified3.IsOutside() || Qualified3.IsUnqualified())) {
68 GccEnt_BadQualifier::Raise();
69 return;
70 }
71
72//=========================================================================
0d969553 73// Processing. +
7fd59977 74//=========================================================================
75
76 gp_Lin2d L1(Qualified1.Qualified());
77 gp_Lin2d L2(Qualified2.Qualified());
78 gp_Lin2d L3(Qualified3.Qualified());
79 gp_Pnt2d origin1(L1.Location());
80 gp_Dir2d dir1(L1.Direction());
81 gp_Dir2d normL1(-dir1.Y(),dir1.X());
82 gp_Pnt2d origin2(L2.Location());
83 gp_Dir2d dir2(L2.Direction());
84 gp_Dir2d normL2(-dir2.Y(),dir2.X());
85 gp_Pnt2d origin3(L3.Location());
86 gp_Dir2d dir3(L3.Direction());
87 gp_Dir2d normL3(-dir3.Y(),dir3.X());
88 Standard_Real xloc1 = origin1.X();
89 Standard_Real xloc2 = origin2.X();
90 Standard_Real xloc3 = origin3.X();
91 Standard_Real yloc1 = origin1.Y();
92 Standard_Real yloc2 = origin2.Y();
93 Standard_Real yloc3 = origin3.Y();
94 Standard_Real xdir1 = dir1.X();
95 Standard_Real xdir2 = dir2.X();
96 Standard_Real xdir3 = dir3.X();
97 Standard_Real ydir1 = dir1.Y();
98 Standard_Real ydir2 = dir2.Y();
99 Standard_Real ydir3 = dir3.Y();
100 GccAna_Lin2dBisec Bisec1(L1,L2);
101 GccAna_Lin2dBisec Bisec2(L1,L3);
102 Standard_Integer ncote1=0;
103 Standard_Integer ncote2=0;
104 Standard_Integer ncote3=0;
105 TColStd_Array1OfReal cote1(1,2);
106 TColStd_Array1OfReal cote2(1,2);
107 TColStd_Array1OfReal cote3(1,2);
108 Standard_Integer nbsol = 0;
109 if (Bisec1.IsDone() && Bisec2.IsDone()) {
110 for (Standard_Integer i = 1 ; i <= Bisec1.NbSolutions() ; i++) {
111 for (Standard_Integer j = 1 ; j <= Bisec2.NbSolutions() ; j++) {
112 IntAna2d_AnaIntersection Intp(Bisec1.ThisSolution(i),
113 Bisec2.ThisSolution(j));
114 if (Intp.IsDone()) {
115 if (!Intp.IsEmpty()) {
116 for (Standard_Integer k = 1 ; k <= Intp.NbPoints() ; k++) {
117 nbsol++;
118 Standard_Real Radius = (L1.Distance(Intp.Point(k).Value())+
119 L2.Distance(Intp.Point(k).Value())+
120 L3.Distance(Intp.Point(k).Value()))/3.0;
121 gp_Pnt2d Center(Intp.Point(k).Value());
122 Standard_Real cx = Center.X();
123 Standard_Real cy = Center.Y();
124 cirsol(nbsol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
125// ======================================================
126 gp_Dir2d dc1(origin1.XY()-Center.XY());
127 if (!Qualified1.IsUnqualified()) {
128 qualifier1(nbsol) = Qualified1.Qualifier();
129 }
130 else if (dc1.Dot(normL1) > 0.0) {
131 qualifier1(nbsol) = GccEnt_outside;
132 }
133 else { qualifier1(nbsol) = GccEnt_enclosed; }
134 gp_Dir2d dc2(origin2.XY()-Center.XY());
135 if (!Qualified2.IsUnqualified()) {
136 qualifier2(nbsol) = Qualified2.Qualifier();
137 }
138 else if (dc2.Dot(normL2) > 0.0) {
139 qualifier2(nbsol) = GccEnt_outside;
140 }
141 else { qualifier2(nbsol) = GccEnt_enclosed; }
142 gp_Dir2d dc3(origin3.XY()-Center.XY());
143 if (!Qualified3.IsUnqualified()) {
144 qualifier3(nbsol) = Qualified3.Qualifier();
145 }
146 else if (dc3.Dot(normL3) > 0.0) {
147 qualifier3(nbsol) = GccEnt_outside;
148 }
149 else { qualifier3(nbsol) = GccEnt_enclosed; }
150
151 Standard_Real cross1=gp_Dir2d(-ydir1,xdir1)
152 .Dot(gp_Dir2d(xloc1-cx,yloc1-cy));
153 Standard_Real cross2=gp_Dir2d(-ydir2,xdir2)
154 .Dot(gp_Dir2d(xloc2-cx,yloc2-cy));
155 Standard_Real cross3=gp_Dir2d(-ydir3,xdir3)
156 .Dot(gp_Dir2d(xloc3-cx,yloc3-cy));
157 if (cross1 != 0.0) {
158 cross1 = cross1/Abs(cross1);
159 }
160 pnttg1sol(nbsol) = gp_Pnt2d(gp_XY(cx,cy)+
161 cross1*Radius*gp_XY(-ydir1,xdir1));
162 if (cross2 != 0.0) {
163 cross2 = cross2/Abs(cross2);
164 }
165 pnttg2sol(nbsol) = gp_Pnt2d(gp_XY(cx,cy)+
166 cross2*Radius*gp_XY(-ydir2,xdir2));
167 if (cross3 != 0.0) {
168 cross3 = cross3/Abs(cross3);
169 }
170 pnttg3sol(nbsol) = gp_Pnt2d(gp_XY(cx,cy)+
171 cross3*Radius*gp_XY(-ydir3,xdir3));
172 par1sol(nbsol)=ElCLib::Parameter(cirsol(nbsol),
173 pnttg1sol(nbsol));
174 pararg1(nbsol)=ElCLib::Parameter(L1,pnttg1sol(nbsol));
175 par2sol(nbsol)=ElCLib::Parameter(cirsol(nbsol),
176 pnttg2sol(nbsol));
177 pararg2(nbsol)=ElCLib::Parameter(L2,pnttg2sol(nbsol));
178 par3sol(nbsol)=ElCLib::Parameter(cirsol(nbsol),
179 pnttg3sol(nbsol));
180 pararg3(nbsol)=ElCLib::Parameter(L3,pnttg3sol(nbsol));
181 }
182 }
183 WellDone = Standard_True;
184 }
185 }
186 }
187 }
188 if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed() &&
189// =========================================================
190 Qualified3.IsEnclosed()) {
191// ========================
192 ncote1 = 1;
193 ncote2 = 1;
194 ncote3 = 1;
195 cote1(1) = 1.0;
196 cote2(1) = 1.0;
197 cote3(1) = 1.0;
198 }
199 else if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed() &&
200// ==============================================================
201 Qualified3.IsOutside()) {
202// =======================
203 ncote1 = 1;
204 ncote2 = 1;
205 ncote3 = 1;
206 cote1(1) = 1.0;
207 cote2(1) = 1.0;
208 cote3(1) = -1.0;
209 }
210 else if (Qualified1.IsEnclosed() && Qualified2.IsOutside() &&
211// =============================================================
212 Qualified3.IsEnclosed()) {
213// ========================
214 ncote1 = 1;
215 ncote2 = 1;
216 ncote3 = 1;
217 cote1(1) = 1.0;
218 cote2(1) = -1.0;
219 cote3(1) = 1.0;
220 }
221 else if (Qualified1.IsEnclosed() && Qualified2.IsOutside() &&
222// =============================================================
223 Qualified3.IsOutside()) {
224// =======================
225 ncote1 = 1;
226 ncote2 = 1;
227 ncote3 = 1;
228 cote1(1) = 1.0;
229 cote2(1) = -1.0;
230 cote3(1) = -1.0;
231 }
232 else if (Qualified1.IsOutside() && Qualified2.IsEnclosed() &&
233// =============================================================
234 Qualified3.IsEnclosed()) {
235// ========================
236 ncote1 = 1;
237 ncote2 = 1;
238 ncote3 = 1;
239 cote1(1) = -1.0;
240 cote2(1) = 1.0;
241 cote3(1) = 1.0;
242 }
243 else if (Qualified1.IsOutside() && Qualified2.IsEnclosed() &&
244// =============================================================
245 Qualified3.IsOutside()) {
246// =======================
247 ncote1 = 1;
248 ncote2 = 1;
249 ncote3 = 1;
250 cote1(1) = -1.0;
251 cote2(1) = 1.0;
252 cote3(1) = -1.0;
253 }
254 else if (Qualified1.IsOutside() && Qualified2.IsOutside() &&
255// ============================================================
256 Qualified3.IsEnclosed()) {
257// ========================
258 ncote1 = 1;
259 ncote2 = 1;
260 ncote3 = 1;
261 cote1(1) = -1.0;
262 cote2(1) = -1.0;
263 cote3(1) = 1.0;
264 }
265 else if (Qualified1.IsOutside() && Qualified2.IsOutside() &&
266// ============================================================
267 Qualified3.IsOutside()) {
268// =======================
269 ncote1 = 1;
270 ncote2 = 1;
271 ncote3 = 1;
272 cote1(1) = -1.0;
273 cote2(1) = -1.0;
274 cote3(1) = -1.0;
275 }
276 else {
277 if (Qualified1.IsUnqualified()) {
278// ====================================
279 ncote1 = 2;
280 cote1(1) = 1.0;
281 cote1(2) = -1.0;
282 if (Qualified2.IsUnqualified()) {
283// ===============================
284 ncote2 = 2;
285 cote2(1) = 1.0;
286 cote2(2) = -1.0;
287 if (Qualified3.IsUnqualified()) {
288// ===============================
289 ncote3 = 2;
290 cote2(1) = 1.0;
291 cote2(2) = -1.0;
292 NbrSol = nbsol;
293 WellDone = Standard_True;
294 }
295 else if (Qualified3.IsEnclosed()) {
296// ===============================
297 ncote3 = 1;
298 cote3(1) = 1.0;
299 }
300 else if (Qualified3.IsOutside()) {
301// ================================
302 ncote3 = 1;
303 cote3(1) = -1.0;
304 }
305 }
306 else if (Qualified2.IsEnclosed()) {
307// =================================
308 ncote2 = 1;
309 cote2(1) = 1.0;
310 if (Qualified3.IsUnqualified()) {
311// ===============================
312 ncote3 = 2;
313 cote3(1) = 1.0;
314 cote3(1) = -1.0;
315 }
316 else if (Qualified3.IsEnclosed()) {
317// =================================
318 ncote3 = 1;
319 cote3(1) = 1.0;
320 }
321 else if (Qualified3.IsOutside()) {
322// ================================
323 ncote3 = 1;
324 cote3(1) = -1.0;
325 }
326 }
327 else if (Qualified2.IsOutside()) {
328// ================================
329 ncote2 = 1;
330 cote2(1) = -1.0;
331 if (Qualified3.IsUnqualified()) {
332// ===============================
333 ncote3 = 2;
334 cote3(1) = 1.0;
335 cote3(2) = -1.0;
336 }
337 else if (Qualified3.IsEnclosed()) {
338// =================================
339 ncote3 = 1;
340 cote3(1) = 1.0;
341 }
342 else if (Qualified3.IsOutside()) {
343// ================================
344 ncote3 = 1;
345 cote3(1) = -1.0;
346 }
347 }
348 }
349 else if (Qualified2.IsUnqualified()) {
350// ===================================
351 ncote2 = 2;
352 cote2(1) = 1.0;
353 cote2(2) = -1.0;
354 if (Qualified1.IsEnclosed()) {
355// ============================
356 ncote1 = 1;
357 cote1(1) = 1.0;
358 if (Qualified3.IsUnqualified()) {
359// ===============================
360 ncote3 = 2;
361 cote3(1) = -1.0;
362 cote3(1) = -1.0;
363 }
364 else if (Qualified3.IsEnclosed()) {
365// =================================
366 ncote3 = 1;
367 cote3(1) = 1.0;
368 }
369 else if (Qualified3.IsOutside()) {
370// ================================
371 ncote3 = 1;
372 cote3(1) = -1.0;
373 }
374 }
375 else if (Qualified1.IsOutside()) {
376// ================================
377 ncote1 = 1;
378 cote1(1) = 1.0;
379 if (Qualified3.IsUnqualified()) {
380// ===============================
381 ncote3 = 2;
382 cote3(1) = 1.0;
383 cote3(2) = -1.0;
384 }
385 else if (Qualified3.IsEnclosed()) {
386// =================================
387 ncote3 = 1;
388 cote3(1) = 1.0;
389 }
390 else if (Qualified3.IsOutside()) {
391// ================================
392 ncote3 = 1;
393 cote3(1) = -1.0;
394 }
395 }
396 }
397 else if (Qualified3.IsUnqualified()) {
398// ===================================
399 ncote3 = 2;
400 cote3(1) = 1.0;
401 cote3(2) = -1.0;
402 if (Qualified1.IsEnclosed()) {
403// ============================
404 ncote1 = 1;
405 cote1(1) = 1.0;
406 if (Qualified2.IsEnclosed()) {
407// ============================
408 ncote2 = 1;
409 cote2(1) = 1.0;
410 }
411 else if (Qualified2.IsOutside()) {
412// ===============================
413 ncote2 = 1;
414 cote2(1) = -1.0;
415 }
416 }
417 else if (Qualified1.IsOutside()) {
418// ================================
419 ncote1 = 1;
420 cote1(1) = -1.0;
421 if (Qualified2.IsEnclosed()) {
422// ============================
423 ncote2 = 1;
424 cote2(1) = 1.0;
425 }
426 else if (Qualified2.IsOutside()) {
427// ===============================
428 ncote2 = 1;
429 cote2(1) = -1.0;
430 }
431 }
432 }
433 }
434 if (NbrSol > 0) { return; }
435 for (Standard_Integer i = 1 ; i <= nbsol ; i++) {
436 for (Standard_Integer j1 = 1 ; j1 <= ncote1 ; j1++) {
437 for (Standard_Integer j2 = 1 ; j2 <= ncote2 ; j2++) {
438 for (Standard_Integer j3 = 1 ; j3 <= ncote3 ; j3++) {
439 if ((cote2(j2)*((cirsol(i).Location().X()-origin2.X())*
440 (-dir2.Y())+(cirsol(i).Location().Y()-
441 origin2.Y())*(dir2.X())) > 0.0) &&
442 (cote3(j3)*((cirsol(i).Location().X()-origin3.X())*
443 (-dir3.Y())+(cirsol(i).Location().Y()-
444 origin3.Y())*(dir3.X())) > 0.0) &&
445 (cote1(j1)*((cirsol(i).Location().X()-origin1.X())*
446 (-dir1.Y())+(cirsol(i).Location().Y()-
447 origin1.Y())*(dir1.X())) > 0.0)) {
448 NbrSol++;
449 cirsol(NbrSol) = gp_Circ2d(cirsol(i));
450// =====================================
451 Standard_Real Radius = cirsol(NbrSol).Radius();
452 gp_Pnt2d Center(cirsol(NbrSol).Location());
453 gp_Dir2d dc(origin1.XY()-Center.XY());
454 Standard_Real sign = dc.Dot(gp_Dir2d(-dir1.Y(),dir1.X()));
455 dc = gp_Dir2d(sign*gp_XY(-dir1.Y(),dir1.X()));
456 pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc.XY());
457 dc = gp_Dir2d(origin2.XY()-Center.XY());
458 sign = dc.Dot(gp_Dir2d(-dir2.Y(),dir2.X()));
459 dc = gp_Dir2d(sign*gp_XY(-dir2.Y(),dir2.X()));
460 pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc.XY());
461 dc = gp_Dir2d(origin3.XY()-Center.XY());
462 sign = dc.Dot(gp_Dir2d(-dir3.Y(),dir3.X()));
463 dc = gp_Dir2d(sign*gp_XY(-dir3.Y(),dir3.X()));
464 pnttg3sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dc.XY());
465 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
466 pnttg1sol(NbrSol));
467 pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol));
468 par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
469 pnttg2sol(NbrSol));
470 pararg2(NbrSol)=ElCLib::Parameter(L2,pnttg2sol(NbrSol));
471 par3sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
472 pnttg3sol(NbrSol));
473 pararg3(NbrSol)=ElCLib::Parameter(L3,pnttg3sol(NbrSol));
474 }
475 }
476 }
477 }
478 }
479 }