b311480e |
1 | // Created on: 1992-10-21 |
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 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <GccAna_Circ2d2TanOn.hxx> |
7fd59977 |
19 | #include <GccEnt_BadQualifier.hxx> |
7fd59977 |
20 | #include <GccEnt_QualifiedCirc.hxx> |
21 | #include <GccEnt_QualifiedLin.hxx> |
42cf5bc1 |
22 | #include <Geom2d_Circle.hxx> |
23 | #include <Geom2d_Line.hxx> |
24 | #include <Geom2d_Point.hxx> |
25 | #include <Geom2dAdaptor_Curve.hxx> |
26 | #include <Geom2dGcc_Circ2d2TanOn.hxx> |
27 | #include <Geom2dGcc_Circ2d2TanOnGeo.hxx> |
28 | #include <Geom2dGcc_Circ2d2TanOnIter.hxx> |
29 | #include <Geom2dGcc_QCurve.hxx> |
30 | #include <Geom2dGcc_QualifiedCurve.hxx> |
31 | #include <gp_Circ2d.hxx> |
32 | #include <gp_Pnt2d.hxx> |
33 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
34 | #include <StdFail_NotDone.hxx> |
35 | |
36 | Geom2dGcc_Circ2d2TanOn:: |
37 | Geom2dGcc_Circ2d2TanOn (const Geom2dGcc_QualifiedCurve& Qualified1 , |
38 | const Geom2dGcc_QualifiedCurve& Qualified2 , |
39 | const Geom2dAdaptor_Curve& OnCurve , |
40 | const Standard_Real Tolerance , |
41 | const Standard_Real Param1 , |
42 | const Standard_Real Param2 , |
43 | const Standard_Real ParamOn ): |
d533dafb |
44 | WellDone(Standard_False), |
7fd59977 |
45 | cirsol(1,8) , |
46 | qualifier1(1,8), |
47 | qualifier2(1,8), |
48 | TheSame1(1,8) , |
49 | TheSame2(1,8) , |
50 | pnttg1sol(1,8), |
51 | pnttg2sol(1,8), |
52 | pntcen(1,8) , |
53 | par1sol(1,8) , |
54 | par2sol(1,8) , |
55 | pararg1(1,8) , |
56 | pararg2(1,8) , |
d533dafb |
57 | parcen3(1,8) |
7fd59977 |
58 | { |
59 | Geom2dAdaptor_Curve C1 = Qualified1.Qualified(); |
60 | Geom2dAdaptor_Curve C2 = Qualified2.Qualified(); |
61 | GeomAbs_CurveType Type1 = C1.GetType(); |
62 | GeomAbs_CurveType Type2 = C2.GetType(); |
63 | GeomAbs_CurveType Type3 = OnCurve.GetType(); |
64 | Handle(Geom2d_Curve) CC1 = C1.Curve(); |
65 | Handle(Geom2d_Curve) CC2 = C2.Curve(); |
66 | Handle(Geom2d_Curve) Con = OnCurve.Curve(); |
67 | |
68 | //============================================================================= |
69 | // Appel a GccAna. + |
70 | //============================================================================= |
71 | |
72 | Invert = Standard_False; |
73 | NbrSol = 0; |
74 | if ((Type1 == GeomAbs_Line || Type1 == GeomAbs_Circle) && |
75 | (Type2 == GeomAbs_Line || Type2 == GeomAbs_Circle)) { |
76 | if (Type3 == GeomAbs_Line || Type3 == GeomAbs_Circle) { |
77 | if (Type1 == GeomAbs_Circle) { |
78 | Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1); |
79 | gp_Circ2d c1(CCC1->Circ2d()); |
80 | GccEnt_QualifiedCirc Qc1 = |
81 | GccEnt_QualifiedCirc(c1,Qualified1.Qualifier()); |
82 | if (Type2 == GeomAbs_Circle) { |
83 | Handle(Geom2d_Circle) CCC2 = Handle(Geom2d_Circle)::DownCast(CC2); |
84 | gp_Circ2d c2(CCC2->Circ2d()); |
85 | if (Type3 == GeomAbs_Circle) { |
86 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
87 | GccAna_Circ2d2TanOn CircAna(Qc1, |
88 | GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()), |
89 | CCon->Circ2d(),Tolerance); |
90 | WellDone = CircAna.IsDone(); |
8009d070 |
91 | if (WellDone) |
92 | { |
93 | NbrSol = CircAna.NbSolutions(); |
94 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
95 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
96 | } |
97 | Results(CircAna); |
98 | } |
7fd59977 |
99 | } |
100 | else { |
101 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
102 | GccAna_Circ2d2TanOn CircAna(Qc1, |
103 | GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()), |
104 | LLon->Lin2d(),Tolerance); |
105 | WellDone = CircAna.IsDone(); |
8009d070 |
106 | if (WellDone) |
107 | { |
108 | NbrSol = CircAna.NbSolutions(); |
109 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
110 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
111 | } |
112 | Results(CircAna); |
113 | } |
7fd59977 |
114 | } |
115 | } |
116 | else { |
117 | Handle(Geom2d_Line) LL2 = Handle(Geom2d_Line)::DownCast(CC2); |
118 | gp_Lin2d l2(LL2->Lin2d()); |
119 | if (Type3 == GeomAbs_Circle) { |
120 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
121 | GccAna_Circ2d2TanOn CircAna(Qc1, |
122 | GccEnt_QualifiedLin(l2,Qualified2.Qualifier()), |
123 | CCon->Circ2d(),Tolerance); |
124 | WellDone = CircAna.IsDone(); |
8009d070 |
125 | if (WellDone) |
126 | { |
127 | NbrSol = CircAna.NbSolutions(); |
128 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
129 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
130 | } |
131 | Results(CircAna); |
132 | } |
7fd59977 |
133 | } |
134 | else { |
135 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
136 | GccAna_Circ2d2TanOn CircAna(Qc1, |
137 | GccEnt_QualifiedLin(l2,Qualified2.Qualifier()), |
138 | LLon->Lin2d(),Tolerance); |
139 | WellDone = CircAna.IsDone(); |
8009d070 |
140 | if (WellDone) |
141 | { |
142 | NbrSol = CircAna.NbSolutions(); |
143 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
144 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
145 | } |
146 | Results(CircAna); |
147 | } |
7fd59977 |
148 | } |
149 | } |
150 | } |
151 | else { |
152 | Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1); |
153 | gp_Lin2d l1(LL1->Lin2d()); |
154 | GccEnt_QualifiedLin Ql1 = |
155 | GccEnt_QualifiedLin(l1,Qualified1.Qualifier()); |
156 | if (Type2 == GeomAbs_Circle) { |
157 | Handle(Geom2d_Circle) CCC2 = Handle(Geom2d_Circle)::DownCast(CC2); |
158 | gp_Circ2d c2(CCC2->Circ2d()); |
159 | if (Type3 == GeomAbs_Circle) { |
160 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
161 | GccAna_Circ2d2TanOn CircAna(GccEnt_QualifiedCirc(c2, |
162 | Qualified2.Qualifier()), |
163 | Ql1,CCon->Circ2d(),Tolerance); |
164 | WellDone = CircAna.IsDone(); |
8009d070 |
165 | if (WellDone) |
166 | { |
167 | NbrSol = CircAna.NbSolutions(); |
168 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
169 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
170 | } |
171 | Results(CircAna); |
172 | Invert = Standard_True; |
173 | } |
7fd59977 |
174 | } |
175 | else { |
176 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
177 | GccAna_Circ2d2TanOn CircAna(GccEnt_QualifiedCirc(c2, |
178 | Qualified2.Qualifier()), |
179 | Ql1,LLon->Lin2d(),Tolerance); |
180 | WellDone = CircAna.IsDone(); |
8009d070 |
181 | if (WellDone) |
182 | { |
183 | NbrSol = CircAna.NbSolutions(); |
184 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
185 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
186 | } |
187 | Results(CircAna); |
188 | Invert = Standard_True; |
189 | } |
7fd59977 |
190 | } |
191 | } |
192 | else { |
193 | Handle(Geom2d_Line) LL2 = Handle(Geom2d_Line)::DownCast(CC2); |
194 | gp_Lin2d l2(LL2->Lin2d()); |
195 | if (Type3 == GeomAbs_Circle) { |
196 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
197 | GccAna_Circ2d2TanOn CircAna(Ql1, |
198 | GccEnt_QualifiedLin(l2,Qualified2.Qualifier()), |
199 | CCon->Circ2d(),Tolerance); |
200 | WellDone = CircAna.IsDone(); |
8009d070 |
201 | if (WellDone) |
202 | { |
203 | NbrSol = CircAna.NbSolutions(); |
204 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
205 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
206 | } |
207 | Results(CircAna); |
208 | } |
7fd59977 |
209 | } |
210 | else { |
211 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
212 | GccAna_Circ2d2TanOn CircAna(Ql1, |
213 | GccEnt_QualifiedLin(l2,Qualified2.Qualifier()), |
214 | LLon->Lin2d(),Tolerance); |
215 | WellDone = CircAna.IsDone(); |
8009d070 |
216 | if (WellDone) |
217 | { |
218 | NbrSol = CircAna.NbSolutions(); |
219 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
220 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
221 | } |
222 | Results(CircAna); |
223 | } |
7fd59977 |
224 | } |
225 | } |
226 | } |
227 | } |
228 | |
229 | //============================================================================= |
230 | // Appel a GccGeo. + |
231 | //============================================================================= |
232 | |
233 | else { |
234 | if (Type1 == GeomAbs_Circle) { |
235 | Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1); |
236 | gp_Circ2d c1(CCC1->Circ2d()); |
237 | GccEnt_QualifiedCirc Qc1 = |
238 | GccEnt_QualifiedCirc(c1,Qualified1.Qualifier()); |
239 | if (Type2 == GeomAbs_Circle) { |
240 | Handle(Geom2d_Circle) CCC2 = Handle(Geom2d_Circle)::DownCast(CC2); |
241 | gp_Circ2d c2(CCC2->Circ2d()); |
242 | GccEnt_QualifiedCirc Qc2 = |
243 | GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()); |
578ce4be |
244 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Qc2,OnCurve,Tolerance); |
7fd59977 |
245 | WellDone = CircGeo.IsDone(); |
8009d070 |
246 | if (WellDone) |
247 | { |
248 | NbrSol = CircGeo.NbSolutions(); |
249 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
250 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
251 | } |
252 | Results(CircGeo); |
253 | } |
7fd59977 |
254 | } |
255 | else { |
256 | Handle(Geom2d_Line) LL2 = Handle(Geom2d_Line)::DownCast(CC2); |
257 | gp_Lin2d l2(LL2->Lin2d()); |
258 | GccEnt_QualifiedLin Ql2 = |
259 | GccEnt_QualifiedLin(l2,Qualified2.Qualifier()); |
578ce4be |
260 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Ql2,OnCurve,Tolerance); |
7fd59977 |
261 | WellDone = CircGeo.IsDone(); |
8009d070 |
262 | if (WellDone) |
263 | { |
264 | NbrSol = CircGeo.NbSolutions(); |
265 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
266 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
267 | } |
268 | Results(CircGeo); |
269 | } |
7fd59977 |
270 | } |
271 | } |
272 | else { |
273 | Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1); |
274 | gp_Lin2d l1(LL1->Lin2d()); |
275 | GccEnt_QualifiedLin Ql1 = |
276 | GccEnt_QualifiedLin(l1,Qualified1.Qualifier()); |
277 | if (Type2 == GeomAbs_Circle) { |
278 | Handle(Geom2d_Circle) CCC2 = Handle(Geom2d_Circle)::DownCast(CC2); |
279 | gp_Circ2d c2(CCC2->Circ2d()); |
280 | GccEnt_QualifiedCirc Qc2 = |
281 | GccEnt_QualifiedCirc(c2,Qualified2.Qualifier()); |
578ce4be |
282 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc2,Ql1,OnCurve,Tolerance); |
7fd59977 |
283 | WellDone = CircGeo.IsDone(); |
8009d070 |
284 | if (WellDone) |
285 | { |
286 | NbrSol = CircGeo.NbSolutions(); |
287 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
288 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
289 | } |
290 | Results(CircGeo); |
291 | Invert = Standard_True; |
292 | } |
7fd59977 |
293 | } |
294 | else { |
295 | Handle(Geom2d_Line) LL2 = Handle(Geom2d_Line)::DownCast(CC2); |
296 | gp_Lin2d l2(LL2->Lin2d()); |
297 | GccEnt_QualifiedLin Ql2 = |
298 | GccEnt_QualifiedLin(l2,Qualified2.Qualifier()); |
578ce4be |
299 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Ql1,Ql2,OnCurve,Tolerance); |
7fd59977 |
300 | WellDone = CircGeo.IsDone(); |
8009d070 |
301 | if (WellDone) |
302 | { |
303 | NbrSol = CircGeo.NbSolutions(); |
304 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
305 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
306 | } |
307 | Results(CircGeo); |
308 | } |
7fd59977 |
309 | } |
310 | } |
311 | } |
312 | } |
7fd59977 |
313 | else { |
0b85f9a6 |
314 | Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); |
315 | Geom2dGcc_QCurve Qc2(C2,Qualified2.Qualifier()); |
7fd59977 |
316 | if ((Type3 == GeomAbs_Circle || Type3 == GeomAbs_Line)) { |
317 | if (Type3 == GeomAbs_Circle) { |
318 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
54e37688 |
319 | Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,CCon->Circ2d(), |
7fd59977 |
320 | Param1,Param2,ParamOn,Tolerance); |
321 | WellDone = Circ.IsDone(); |
8009d070 |
322 | if (WellDone) |
323 | { |
324 | NbrSol = 1; |
325 | cirsol(1) = Circ.ThisSolution(); |
326 | if (Circ.IsTheSame1()) { TheSame1(1) = 1; } |
327 | else {TheSame1(1) = 0; } |
328 | if (Circ.IsTheSame2()) { TheSame2(1) = 1; } |
329 | else {TheSame2(1) = 0; } |
330 | Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1)); |
331 | Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); |
332 | } |
7fd59977 |
333 | } |
334 | else { |
335 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
54e37688 |
336 | Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,LLon->Lin2d(), |
7fd59977 |
337 | Param1,Param2,ParamOn,Tolerance); |
338 | WellDone = Circ.IsDone(); |
8009d070 |
339 | if (WellDone) |
340 | { |
341 | NbrSol = 1; |
342 | cirsol(1) = Circ.ThisSolution(); |
343 | if (Circ.IsTheSame1()) { TheSame1(1) = 1; } |
344 | else {TheSame1(1) = 0; } |
345 | if (Circ.IsTheSame2()) { TheSame2(1) = 1; } |
346 | else {TheSame2(1) = 0; } |
347 | Circ.WhichQualifier(qualifier1(1),qualifier2(1)); |
348 | Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1)); |
349 | Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); |
350 | } |
7fd59977 |
351 | } |
352 | } |
54e37688 |
353 | Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Qc2,OnCurve, |
7fd59977 |
354 | Param1,Param2,ParamOn,Tolerance); |
355 | WellDone = Circ.IsDone(); |
8009d070 |
356 | if (WellDone) |
357 | { |
358 | NbrSol = 1; |
359 | cirsol(1) = Circ.ThisSolution(); |
360 | if (Circ.IsTheSame1()) { TheSame1(1) = 1; } |
361 | else {TheSame1(1) = 0; } |
362 | if (Circ.IsTheSame2()) { TheSame2(1) = 1; } |
363 | else {TheSame2(1) = 0; } |
364 | Circ.WhichQualifier(qualifier1(1),qualifier2(1)); |
365 | Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1)); |
366 | Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); |
367 | } |
7fd59977 |
368 | } |
369 | } |
370 | |
371 | Geom2dGcc_Circ2d2TanOn:: |
372 | Geom2dGcc_Circ2d2TanOn (const Geom2dGcc_QualifiedCurve& Qualified1 , |
373 | const Handle(Geom2d_Point)& Point , |
374 | const Geom2dAdaptor_Curve& OnCurve , |
375 | const Standard_Real Tolerance , |
376 | const Standard_Real Param1 , |
377 | const Standard_Real ParamOn ): |
d533dafb |
378 | WellDone(Standard_False), |
7fd59977 |
379 | cirsol(1,8) , |
380 | qualifier1(1,8), |
381 | qualifier2(1,8), |
382 | TheSame1(1,8) , |
383 | TheSame2(1,8) , |
384 | pnttg1sol(1,8), |
385 | pnttg2sol(1,8), |
386 | pntcen(1,8) , |
387 | par1sol(1,8) , |
388 | par2sol(1,8) , |
389 | pararg1(1,8) , |
390 | pararg2(1,8) , |
d533dafb |
391 | parcen3(1,8) |
7fd59977 |
392 | { |
393 | Geom2dAdaptor_Curve C1 = Qualified1.Qualified(); |
394 | GeomAbs_CurveType Type1 = C1.GetType(); |
395 | GeomAbs_CurveType Type3 = OnCurve.GetType(); |
396 | Handle(Geom2d_Curve) CC1 = C1.Curve(); |
397 | Handle(Geom2d_Curve) Con = OnCurve.Curve(); |
398 | |
399 | //============================================================================= |
400 | // Appel a GccAna. + |
401 | //============================================================================= |
402 | |
403 | Invert = Standard_False; |
404 | NbrSol = 0; |
405 | if (Type1 == GeomAbs_Line || Type1 == GeomAbs_Circle) { |
406 | if (Type3 == GeomAbs_Line || Type3 == GeomAbs_Circle) { |
407 | gp_Pnt2d pnt(Point->Pnt2d()); |
408 | if (Type1 == GeomAbs_Circle) { |
409 | Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1); |
410 | gp_Circ2d c1(CCC1->Circ2d()); |
411 | GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier()); |
412 | if (Type3 == GeomAbs_Circle) { |
413 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
414 | GccAna_Circ2d2TanOn CircAna(Qc1,pnt,CCon->Circ2d(),Tolerance); |
415 | WellDone = CircAna.IsDone(); |
8009d070 |
416 | if (WellDone) |
417 | { |
418 | NbrSol = CircAna.NbSolutions(); |
419 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
420 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
421 | } |
422 | Results(CircAna); |
423 | } |
7fd59977 |
424 | } |
425 | else if (Type3 == GeomAbs_Line) { |
426 | Handle(Geom2d_Line) CCon = Handle(Geom2d_Line)::DownCast(Con); |
427 | GccAna_Circ2d2TanOn CircAna(Qc1,pnt,CCon->Lin2d(),Tolerance); |
428 | WellDone = CircAna.IsDone(); |
8009d070 |
429 | if (WellDone) |
430 | { |
431 | NbrSol = CircAna.NbSolutions(); |
432 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
433 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
434 | } |
435 | Results(CircAna); |
436 | } |
7fd59977 |
437 | } |
438 | } |
439 | else { |
440 | Handle(Geom2d_Line) LLL1 = Handle(Geom2d_Line)::DownCast(CC1); |
441 | gp_Lin2d l1(LLL1->Lin2d()); |
442 | GccEnt_QualifiedLin Ql1(l1,Qualified1.Qualifier()); |
443 | if (Type3 == GeomAbs_Circle) { |
444 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
445 | GccAna_Circ2d2TanOn CircAna(Ql1,pnt,CCon->Circ2d(),Tolerance); |
446 | WellDone = CircAna.IsDone(); |
8009d070 |
447 | if (WellDone) |
448 | { |
449 | NbrSol = CircAna.NbSolutions(); |
450 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
451 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
452 | } |
453 | Results(CircAna); |
454 | } |
7fd59977 |
455 | } |
456 | else if (Type3 == GeomAbs_Line) { |
457 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
458 | GccAna_Circ2d2TanOn CircAna(Ql1,pnt,LLon->Lin2d(),Tolerance); |
459 | WellDone = CircAna.IsDone(); |
8009d070 |
460 | if (WellDone) |
461 | { |
462 | NbrSol = CircAna.NbSolutions(); |
463 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
464 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
465 | } |
466 | Results(CircAna); |
467 | } |
7fd59977 |
468 | } |
469 | } |
470 | } |
471 | //============================================================================= |
472 | // Appel a GccGeo. + |
473 | //============================================================================= |
474 | |
475 | else { |
476 | if (Type1 == GeomAbs_Circle) { |
477 | Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1); |
478 | gp_Circ2d c1(CCC1->Circ2d()); |
479 | GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier()); |
578ce4be |
480 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Qc1,Point->Pnt2d(),OnCurve,Tolerance); |
7fd59977 |
481 | WellDone = CircGeo.IsDone(); |
8009d070 |
482 | if (WellDone) |
483 | { |
484 | NbrSol = CircGeo.NbSolutions(); |
485 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
486 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
487 | } |
488 | Results(CircGeo); |
489 | } |
7fd59977 |
490 | } |
491 | else { |
492 | Handle(Geom2d_Line) LLL1 = Handle(Geom2d_Line)::DownCast(CC1); |
493 | gp_Lin2d l1(LLL1->Lin2d()); |
494 | GccEnt_QualifiedLin Ql1(l1,Qualified1.Qualifier()); |
578ce4be |
495 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Ql1,Point->Pnt2d(),OnCurve,Tolerance); |
7fd59977 |
496 | WellDone = CircGeo.IsDone(); |
8009d070 |
497 | if (WellDone) |
498 | { |
499 | NbrSol = CircGeo.NbSolutions(); |
500 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
501 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
502 | } |
503 | Results(CircGeo); |
504 | } |
7fd59977 |
505 | } |
506 | } |
54e37688 |
507 | } |
7fd59977 |
508 | else { |
0b85f9a6 |
509 | Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); |
7fd59977 |
510 | if ((Type3 == GeomAbs_Circle || Type3 == GeomAbs_Line)) { |
511 | if (Type3 == GeomAbs_Circle) { |
512 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
54e37688 |
513 | Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),CCon->Circ2d(), |
7fd59977 |
514 | Param1,ParamOn,Tolerance); |
515 | WellDone = Circ.IsDone(); |
8009d070 |
516 | if (WellDone) |
517 | { |
518 | NbrSol = 1; |
519 | cirsol(1) = Circ.ThisSolution(); |
520 | if (Circ.IsTheSame1()) { TheSame1(1) = 1; } |
521 | else {TheSame1(1) = 0; } |
522 | Circ.WhichQualifier(qualifier1(1),qualifier2(1)); |
523 | Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1)); |
524 | Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); |
525 | } |
7fd59977 |
526 | } |
527 | else { |
528 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
54e37688 |
529 | Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),LLon->Lin2d(), |
7fd59977 |
530 | Param1,ParamOn,Tolerance); |
531 | WellDone = Circ.IsDone(); |
8009d070 |
532 | if (WellDone) |
533 | { |
534 | NbrSol = 1; |
535 | cirsol(1) = Circ.ThisSolution(); |
536 | if (Circ.IsTheSame1()) { TheSame1(1) = 1; } |
537 | else {TheSame1(1) = 0; } |
538 | Circ.WhichQualifier(qualifier1(1),qualifier2(1)); |
539 | Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1)); |
540 | Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); |
541 | } |
7fd59977 |
542 | } |
543 | } |
544 | else { |
54e37688 |
545 | Geom2dGcc_Circ2d2TanOnIter Circ(Qc1,Point->Pnt2d(),OnCurve, |
7fd59977 |
546 | Param1,ParamOn,Tolerance); |
547 | WellDone = Circ.IsDone(); |
8009d070 |
548 | if (WellDone) |
549 | { |
550 | NbrSol = 1; |
551 | cirsol(1) = Circ.ThisSolution(); |
552 | if (Circ.IsTheSame1()) { TheSame1(1) = 1; } |
553 | else {TheSame1(1) = 0; } |
554 | if (Circ.IsTheSame2()) { TheSame2(1) = 1; } |
555 | else {TheSame2(1) = 0; } |
556 | Circ.WhichQualifier(qualifier1(1),qualifier2(1)); |
557 | Circ.Tangency1(par1sol(1),pararg1(1),pnttg1sol(1)); |
558 | Circ.Tangency2(par2sol(1),pararg2(1),pnttg2sol(1)); |
559 | } |
7fd59977 |
560 | } |
561 | } |
562 | } |
563 | |
564 | Geom2dGcc_Circ2d2TanOn:: |
565 | Geom2dGcc_Circ2d2TanOn (const Handle(Geom2d_Point)& Point1 , |
566 | const Handle(Geom2d_Point)& Point2 , |
567 | const Geom2dAdaptor_Curve& OnCurve , |
568 | const Standard_Real Tolerance ): |
d533dafb |
569 | WellDone(Standard_False), |
7fd59977 |
570 | cirsol(1,8) , |
571 | qualifier1(1,8), |
572 | qualifier2(1,8), |
573 | TheSame1(1,8) , |
574 | TheSame2(1,8) , |
575 | pnttg1sol(1,8), |
576 | pnttg2sol(1,8), |
577 | pntcen(1,8) , |
578 | par1sol(1,8) , |
579 | par2sol(1,8) , |
580 | pararg1(1,8) , |
581 | pararg2(1,8) , |
d533dafb |
582 | parcen3(1,8) |
7fd59977 |
583 | { |
584 | GeomAbs_CurveType Type3 = OnCurve.GetType(); |
585 | Handle(Geom2d_Curve) Con = OnCurve.Curve(); |
586 | |
587 | //============================================================================= |
588 | // Appel a GccAna. + |
589 | //============================================================================= |
590 | |
591 | Invert = Standard_False; |
592 | NbrSol = 0; |
593 | if (Type3 == GeomAbs_Line || Type3 == GeomAbs_Circle) { |
594 | gp_Pnt2d pnt1(Point1->Pnt2d()); |
595 | gp_Pnt2d pnt2(Point2->Pnt2d()); |
596 | if (Type3 == GeomAbs_Circle) { |
597 | Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con); |
598 | GccAna_Circ2d2TanOn CircAna(pnt1,pnt2,CCon->Circ2d(),Tolerance); |
599 | WellDone = CircAna.IsDone(); |
8009d070 |
600 | if (WellDone) |
601 | { |
602 | NbrSol = CircAna.NbSolutions(); |
603 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
604 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
605 | } |
606 | Results(CircAna); |
7fd59977 |
607 | } |
7fd59977 |
608 | } |
609 | else { |
610 | Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con); |
611 | GccAna_Circ2d2TanOn CircAna(pnt1,pnt2,LLon->Lin2d(),Tolerance); |
612 | WellDone = CircAna.IsDone(); |
8009d070 |
613 | if (WellDone) |
614 | { |
615 | NbrSol = CircAna.NbSolutions(); |
616 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
617 | CircAna.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
618 | } |
619 | Results(CircAna); |
7fd59977 |
620 | } |
7fd59977 |
621 | } |
622 | } |
623 | |
624 | //============================================================================= |
625 | // Appel a GccGeo. + |
626 | //============================================================================= |
627 | |
628 | else { |
578ce4be |
629 | Geom2dGcc_Circ2d2TanOnGeo CircGeo(Point1->Pnt2d(),Point2->Pnt2d(), |
7fd59977 |
630 | OnCurve,Tolerance); |
631 | WellDone = CircGeo.IsDone(); |
8009d070 |
632 | if (WellDone) |
633 | { |
634 | NbrSol = CircGeo.NbSolutions(); |
635 | for(Standard_Integer i=1; i<=NbrSol; i++) { |
636 | CircGeo.WhichQualifier(i,qualifier1(i),qualifier2(i)); |
637 | } |
638 | Results(CircGeo); |
7fd59977 |
639 | } |
7fd59977 |
640 | } |
641 | } |
642 | |
643 | void Geom2dGcc_Circ2d2TanOn::Results(const GccAna_Circ2d2TanOn& Circ) |
644 | { |
645 | for (Standard_Integer j = 1; j <= NbrSol; j++) { |
646 | cirsol(j) = Circ.ThisSolution(j); |
647 | if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; } |
648 | else {TheSame1(j) = 0; } |
649 | if (Circ.IsTheSame2(j)) { TheSame2(j) = 1; } |
650 | else {TheSame2(j) = 0; } |
651 | Circ.WhichQualifier(j,qualifier1(j),qualifier2(j)); |
652 | Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j)); |
653 | Circ.Tangency2(j,par2sol(j),pararg2(j),pnttg2sol(j)); |
654 | Circ.CenterOn3(j,parcen3(j),pntcen(j)); |
655 | } |
656 | } |
657 | |
578ce4be |
658 | void Geom2dGcc_Circ2d2TanOn::Results(const Geom2dGcc_Circ2d2TanOnGeo& Circ) |
7fd59977 |
659 | { |
660 | for (Standard_Integer j = 1; j <= NbrSol; j++) { |
661 | cirsol(j) = Circ.ThisSolution(j); |
662 | if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; } |
663 | else {TheSame1(j) = 0; } |
664 | if (Circ.IsTheSame2(j)) { TheSame2(j) = 1; } |
665 | else {TheSame2(j) = 0; } |
666 | Circ.WhichQualifier(j,qualifier1(j),qualifier2(j)); |
667 | Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j)); |
668 | Circ.Tangency2(j,par2sol(j),pararg2(j),pnttg2sol(j)); |
669 | Circ.CenterOn3(j,parcen3(j),pntcen(j)); |
670 | } |
671 | } |
672 | |
673 | Standard_Boolean Geom2dGcc_Circ2d2TanOn:: |
674 | IsDone () const { return WellDone; } |
675 | |
676 | Standard_Integer Geom2dGcc_Circ2d2TanOn:: |
677 | NbSolutions () const |
678 | { |
679 | return NbrSol; |
680 | } |
681 | |
682 | gp_Circ2d Geom2dGcc_Circ2d2TanOn:: |
683 | ThisSolution (const Standard_Integer Index) const |
684 | { |
9775fa61 |
685 | if (!WellDone) { throw StdFail_NotDone(); } |
686 | if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
687 | return cirsol(Index); |
688 | } |
689 | |
690 | void Geom2dGcc_Circ2d2TanOn:: |
691 | WhichQualifier (const Standard_Integer Index , |
692 | GccEnt_Position& Qualif1 , |
693 | GccEnt_Position& Qualif2) const |
694 | { |
9775fa61 |
695 | if (!WellDone) { throw StdFail_NotDone(); } |
696 | else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
697 | else { |
698 | if (Invert) { |
699 | Qualif1 = qualifier2(Index); |
700 | Qualif2 = qualifier1(Index); |
701 | } |
702 | else { |
703 | Qualif1 = qualifier1(Index); |
704 | Qualif2 = qualifier2(Index); |
705 | } |
706 | } |
707 | } |
708 | |
709 | void Geom2dGcc_Circ2d2TanOn:: |
710 | Tangency1 (const Standard_Integer Index, |
711 | Standard_Real& ParSol, |
712 | Standard_Real& ParArg, |
713 | gp_Pnt2d& PntSol) const |
714 | { |
9775fa61 |
715 | if (!WellDone) { throw StdFail_NotDone(); } |
716 | else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
717 | else { |
718 | if (Invert) { |
719 | if (TheSame2(Index) == 0) { |
720 | ParSol = par2sol(Index); |
721 | ParArg = pararg2(Index); |
722 | PntSol = pnttg2sol(Index); |
723 | } |
9775fa61 |
724 | else { throw StdFail_NotDone(); } |
7fd59977 |
725 | } |
726 | else { |
727 | if (TheSame1(Index) == 0) { |
728 | ParSol = par1sol(Index); |
729 | ParArg = pararg1(Index); |
730 | PntSol = pnttg1sol(Index); |
731 | } |
9775fa61 |
732 | else { throw StdFail_NotDone(); } |
7fd59977 |
733 | } |
734 | } |
735 | } |
736 | |
737 | void Geom2dGcc_Circ2d2TanOn:: |
738 | Tangency2 (const Standard_Integer Index, |
739 | Standard_Real& ParSol, |
740 | Standard_Real& ParArg, |
741 | gp_Pnt2d& PntSol) const |
742 | { |
9775fa61 |
743 | if (!WellDone) { throw StdFail_NotDone(); } |
744 | else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
745 | else { |
746 | if (!Invert) { |
747 | if (TheSame2(Index) == 0) { |
748 | ParSol = par2sol(Index); |
749 | ParArg = pararg2(Index); |
750 | PntSol = pnttg2sol(Index); |
751 | } |
9775fa61 |
752 | else { throw StdFail_NotDone(); } |
7fd59977 |
753 | } |
754 | else { |
755 | if (TheSame1(Index) == 0) { |
756 | ParSol = par1sol(Index); |
757 | ParArg = pararg1(Index); |
758 | PntSol = pnttg1sol(Index); |
759 | } |
9775fa61 |
760 | else { throw StdFail_NotDone(); } |
7fd59977 |
761 | } |
762 | } |
763 | } |
764 | |
765 | void Geom2dGcc_Circ2d2TanOn:: |
766 | CenterOn3 (const Standard_Integer Index, |
767 | Standard_Real& ParArg, |
768 | gp_Pnt2d& PntSol) const |
769 | { |
9775fa61 |
770 | if (!WellDone) { throw StdFail_NotDone(); } |
771 | else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
772 | else { |
773 | ParArg = parcen3(Index); |
774 | PntSol = pntcen(Index); |
775 | } |
776 | } |
777 | |
778 | Standard_Boolean Geom2dGcc_Circ2d2TanOn:: |
779 | IsTheSame1 (const Standard_Integer Index) const |
780 | { |
9775fa61 |
781 | if (!WellDone) { throw StdFail_NotDone(); } |
782 | if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
783 | if (Invert) { |
784 | if (TheSame2(Index) == 0) { return Standard_False; } |
785 | else { return Standard_True; } |
786 | } |
787 | else { |
788 | if (TheSame1(Index) == 0) { return Standard_False; } |
789 | else { return Standard_True; } |
790 | } |
7fd59977 |
791 | } |
792 | |
793 | Standard_Boolean Geom2dGcc_Circ2d2TanOn:: |
794 | IsTheSame2 (const Standard_Integer Index) const |
795 | { |
9775fa61 |
796 | if (!WellDone) { throw StdFail_NotDone(); } |
797 | if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
798 | if (!Invert) { |
799 | if (TheSame2(Index) == 0) { return Standard_False; } |
800 | else { return Standard_True; } |
801 | } |
802 | else { |
803 | if (TheSame1(Index) == 0) { return Standard_False; } |
804 | else { return Standard_True; } |
805 | } |
d3f26155 |
806 | // return Standard_True; |
7fd59977 |
807 | } |