0024510: Remove unused local variables
[occt.git] / src / GccAna / GccAna_Circ2d2TanOn_9.cxx
CommitLineData
b311480e 1// Created on: 1992-01-02
2// Created by: Remi GILET
3// Copyright (c) 1992-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <GccAna_Circ2d2TanOn.jxx>
18
19#include <ElCLib.hxx>
20#include <gp_Dir2d.hxx>
21#include <gp_Ax2d.hxx>
22#include <IntAna2d_AnaIntersection.hxx>
23#include <IntAna2d_IntPoint.hxx>
24#include <GccAna_Lin2dBisec.hxx>
25#include <gp.hxx>
26#include <GccEnt_BadQualifier.hxx>
27
28GccAna_Circ2d2TanOn::
29 GccAna_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 ,
30 const GccEnt_QualifiedLin& Qualified2 ,
31 const gp_Circ2d& OnCirc ,
35e08fe8 32 const Standard_Real ):
7fd59977 33 cirsol(1,4) ,
34 qualifier1(1,4) ,
35 qualifier2(1,4),
36 TheSame1(1,4) ,
37 TheSame2(1,4) ,
38 pnttg1sol(1,4) ,
39 pnttg2sol(1,4) ,
40 pntcen(1,4) ,
41 par1sol(1,4) ,
42 par2sol(1,4) ,
43 pararg1(1,4) ,
44 pararg2(1,4) ,
45 parcen3(1,4)
46{
47 TheSame1.Init(0);
48 TheSame2.Init(0);
49 WellDone = Standard_False;
50 NbrSol = 0;
51
52 gp_Dir2d dirx(1.,0.);
7fd59977 53 if (!(Qualified1.IsEnclosed() ||
54 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
55 !(Qualified2.IsEnclosed() ||
56 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
57 GccEnt_BadQualifier::Raise();
58 return;
59 }
60 gp_Lin2d L1(Qualified1.Qualified());
61 gp_Lin2d L2(Qualified2.Qualified());
62 GccAna_Lin2dBisec Bis(L1,L2);
63 Standard_Integer i=0,j=0;
64 Standard_Integer nbsol = 0;
65 Standard_Real sgn = 1.;
66 Standard_Real s = 1.;
67 Standard_Boolean ok = Standard_False;
68 gp_Dir2d D1(L1.Direction());
69 gp_Dir2d D2(L2.Direction());
70 gp_Dir2d Dnor1(-D1.Y(),D1.X());
71 gp_Dir2d Dnor2(-D2.Y(),D2.X());
72 gp_XY XYnor1(-D1.Y(),D1.X());
73 gp_XY XYnor2(-D2.Y(),D2.X());
74 gp_Pnt2d originL1(L1.Location());
75 gp_Pnt2d originL2(L2.Location());
76 gp_XY Dloc(originL1.XY()-originL2.XY());
77 if (D1.Angle(D2) <= gp::Resolution()) {
78 if (Qualified1.IsEnclosed()) {
79 if (Dloc.Dot(XYnor1) <= 0.) { ok = Standard_True; }
80 else { ok = Standard_False; }
81 }
82 else if (Qualified1.IsOutside()) {
83 if (Dloc.Dot(XYnor1) >= 0.) { ok = Standard_True; }
84 else { ok = Standard_False; }
85 }
86 else {ok = Standard_True; }
87 if (Qualified2.IsEnclosed()) {
88 if (Dloc.Dot(XYnor2) >= 0.) { ok = Standard_True; }
89 else { ok = Standard_False; }
90 }
91 else if (Qualified2.IsOutside()) {
92 if (Dloc.Dot(XYnor2) <= 0.) { ok = Standard_True; }
93 else { ok = Standard_False; }
94 }
95 else {ok = Standard_True; }
96 if ( ok ) {
97 IntAna2d_AnaIntersection Intp(Bis.ThisSolution(1),OnCirc);
98 if (Intp.IsDone()) {
99 WellDone = Standard_True;
100 if (!Intp.IsEmpty()) {
101 for (Standard_Integer l = 1 ; l <= Intp.NbPoints() ; l++) {
102 NbrSol++;
103 gp_Pnt2d pt(Intp.Point(l).Value());
104 gp_Ax2d axe(pt,dirx);
105 cirsol(NbrSol) = gp_Circ2d(axe,L1.Distance(pt));
106// ===============================================
107 gp_Dir2d dc1(originL1.XY()-pt.XY());
108 gp_Dir2d dc2(originL2.XY()-pt.XY());
109 if (!Qualified1.IsUnqualified()) {
110 qualifier1(NbrSol) = Qualified1.Qualifier();
111 }
112 else if (dc1.Dot(Dnor1) > 0.0) {
113 qualifier1(NbrSol) = GccEnt_outside;
114 }
115 else { qualifier1(NbrSol) = GccEnt_enclosed; }
116 if (!Qualified2.IsUnqualified()) {
117 qualifier2(NbrSol) = Qualified2.Qualifier();
118 }
119 else if (dc2.Dot(Dnor2) > 0.0) {
120 qualifier2(NbrSol) = GccEnt_outside;
121 }
122 else { qualifier2(NbrSol) = GccEnt_enclosed; }
123 }
124 }
125 }
126 }
127 }
128 else if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) {
129//============================================================
130 if (Bis.IsDone()) {
131 if (Bis.NbSolutions() == 2) {
132 nbsol = 1;
133 i = 2;
134 j = 1;
135 sgn = -1.;
136 }
137 }
138 }
139 else if (Qualified1.IsEnclosed() && Qualified2.IsOutside()) {
140//===========================================================
141 if (Bis.IsDone()) {
142 if (Bis.NbSolutions() >= 1) {
143 nbsol = 1;
144 i = 1;
145 j = 1;
146 if (D1.Angle(D2) >= 0.0) { sgn = -1.; }
147 }
148 }
149 }
150 else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) {
151//===========================================================
152 if (Bis.IsDone()) {
153 if (Bis.NbSolutions() >= 1) {
154 nbsol = 1;
155 i = 1;
156 j = 1;
157 if (D1.Angle(D2) <= 0.0) { sgn = -1.; }
158 }
159 }
160 }
161 else if (Qualified1.IsOutside() && Qualified2.IsOutside()) {
162//==========================================================
163 if (Bis.IsDone()) {
164 if (Bis.NbSolutions() >= 1) {
165 nbsol = 1;
166 i = 2;
167 j = 1;
168 }
169 }
170 }
171 else if (Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) {
172//=============================================================
173 if (Bis.IsDone()) {
174 nbsol = 2;
175 if (Bis.NbSolutions() >= 1) {
176 i = 1;
177 j = 2;
178 }
179 if (D1.Angle(D2) >= 0.0) { s = -1.; }
180 else { sgn = -1.; }
181 }
182 }
183 else if (Qualified1.IsUnqualified() && Qualified2.IsOutside()) {
184//==============================================================
185 if (Bis.IsDone()) {
186 nbsol = 2;
187 if (Bis.NbSolutions() >= 1) {
188 i = 1;
189 j = 2;
190 }
191 if (D1.Angle(D2) >= 0.0) {
192 s = -1.;
193 sgn = -1.;
194 }
195 }
196 }
197 else if (Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) {
198//===============================================================
199 if (Bis.IsDone()) {
200 nbsol = 2;
201 if (Bis.NbSolutions() >= 1) {
202 i = 1;
203 j = 2;
204 }
205 if (D1.Angle(D2) >= 0.0) { sgn = -1.; }
206 else { s = -1.; }
207 }
208 }
209 else if (Qualified1.IsOutside() && Qualified2.IsUnqualified()) {
210//==============================================================
211 if (Bis.IsDone()) {
212 nbsol = 2;
213 if (Bis.NbSolutions() >= 1) {
214 i = 1;
215 j = 2;
216 }
217 if (D1.Angle(D2) <= 0.0) {
218 s = -1.;
219 sgn = -1.;
220 }
221 }
222 }
223 else if (Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) {
224//==================================================================
225 nbsol = 4;
226 i = 1;
227 j = 2;
228 }
229 if (nbsol >= 1) {
230 if (Bis.IsDone()) {
231 Standard_Integer kk = 0;
232 for (Standard_Integer k = i ; k <= i+j-1 ; k++) {
233 kk++;
234 IntAna2d_AnaIntersection Intp(Bis.ThisSolution(k),OnCirc);
235 if (Intp.IsDone()) {
236 if (!Intp.IsEmpty()) {
237 for (Standard_Integer l = 1 ; l <= Intp.NbPoints() ; l++) {
238 gp_Vec2d V(Intp.Point(l).Value(),
239 Bis.ThisSolution(k).Location());
240 if ((kk==1 && sgn*V.Dot(Bis.ThisSolution(k).Direction())>=0.0)||
241 (kk==2 && sgn*s*V.Dot(Bis.ThisSolution(k).Direction())>=0.0)
242 || nbsol == 4) {
243 NbrSol++;
244 gp_Pnt2d pt(Intp.Point(i).Value());
245 gp_Ax2d axe(pt,dirx);
246 cirsol(NbrSol) = gp_Circ2d(axe,
247// ===============================
248 L1.Distance(Intp.Point(l).Value()));
249// ===================================
250 gp_Dir2d dc1(originL1.XY()-pt.XY());
251 gp_Dir2d dc2(originL2.XY()-pt.XY());
252 if (!Qualified1.IsUnqualified()) {
253 qualifier1(NbrSol) = Qualified1.Qualifier();
254 }
255 else if (dc1.Dot(Dnor1) > 0.0) {
256 qualifier1(NbrSol) = GccEnt_outside;
257 }
258 else { qualifier1(NbrSol) = GccEnt_enclosed; }
259 if (!Qualified2.IsUnqualified()) {
260 qualifier2(NbrSol) = Qualified2.Qualifier();
261 }
262 else if (dc2.Dot(Dnor2) > 0.0) {
263 qualifier2(NbrSol) = GccEnt_outside;
264 }
265 else { qualifier2(NbrSol) = GccEnt_enclosed; }
266 }
267 }
268 }
269 WellDone = Standard_True;
270 }
271 }
272 }
273 }
274 if (NbrSol > 0) {
275 for (i =1 ; i <= NbrSol ; i++) {
276 gp_Pnt2d pbid(cirsol(i).Location());
277 Standard_Real Radius = cirsol(i).Radius();
278 gp_Dir2d dc2(originL1.XY()-pbid.XY());
279 Standard_Real sign = dc2.Dot(gp_Dir2d(-L1.Direction().Y(),
280 L1.Direction().X()));
281 dc2 = gp_Dir2d(sign*gp_XY(-L1.Direction().Y(),L1.Direction().X()));
282 pnttg1sol(i) = gp_Pnt2d(pbid.XY()+Radius*dc2.XY());
283 dc2 = gp_Dir2d(originL2.XY()-pbid.XY());
284 sign = dc2.Dot(gp_Dir2d(-L2.Direction().Y(),L2.Direction().X()));
285 dc2 = gp_Dir2d(sign*gp_XY(-L2.Direction().Y(),L2.Direction().X()));
286 pnttg2sol(i) = gp_Pnt2d(pbid.XY()+Radius*dc2.XY());
287 pntcen(i) = pbid;
288 par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
289 pararg1(i)=ElCLib::Parameter(L1,pnttg1sol(i));
290 par2sol(i)=ElCLib::Parameter(cirsol(i),pnttg2sol(i));
291 pararg2(i)=ElCLib::Parameter(L2,pnttg2sol(i));
292 parcen3(i)=ElCLib::Parameter(OnCirc,pntcen(i));
293 }
294 }
295}
296