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