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 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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 | |
578ce4be |
15 | |
42cf5bc1 |
16 | #include <Adaptor3d_OffsetCurve.hxx> |
7fd59977 |
17 | #include <ElCLib.hxx> |
42cf5bc1 |
18 | #include <GccEnt_BadQualifier.hxx> |
19 | #include <GccEnt_QualifiedCirc.hxx> |
20 | #include <GccEnt_QualifiedLin.hxx> |
21 | #include <Geom2dAdaptor_HCurve.hxx> |
22 | #include <Geom2dGcc_Circ2d2TanRadGeo.hxx> |
23 | #include <Geom2dGcc_CurveTool.hxx> |
24 | #include <Geom2dGcc_CurveToolGeo.hxx> |
25 | #include <Geom2dGcc_QCurve.hxx> |
26 | #include <Geom2dInt_GInter.hxx> |
7fd59977 |
27 | #include <gp_Ax2d.hxx> |
28 | #include <gp_Circ2d.hxx> |
29 | #include <gp_Lin2d.hxx> |
42cf5bc1 |
30 | #include <gp_Pnt2d.hxx> |
31 | #include <IntRes2d_Domain.hxx> |
32 | #include <IntRes2d_IntersectionPoint.hxx> |
7fd59977 |
33 | #include <Standard_NegativeValue.hxx> |
34 | #include <Standard_OutOfRange.hxx> |
35 | #include <StdFail_NotDone.hxx> |
36 | #include <TColStd_Array1OfReal.hxx> |
578ce4be |
37 | |
1d19db8d |
38 | static const Standard_Integer aNbSolMAX = 16; |
39 | |
7fd59977 |
40 | // circulaire tant a une courbe et une droite ,de rayon donne |
41 | //============================================================== |
42 | |
43 | //======================================================================== |
44 | // On initialise WellDone a false. + |
45 | // On recupere la courbe Cu2 et la droite L1. + |
46 | // On sort en erreur dans les cas ou la construction est impossible. + |
47 | // On fait la parallele a Cu2 dans le bon sens. + |
48 | // On fait la parallele a L1 dans le bon sens. + |
49 | // On intersecte les paralleles ==> point de centre de la solution. + |
50 | // On cree la solution qu on ajoute aux solutions deja trouvees. + |
51 | // On remplit les champs. + |
52 | //======================================================================== |
53 | |
578ce4be |
54 | Geom2dGcc_Circ2d2TanRadGeo:: |
55 | Geom2dGcc_Circ2d2TanRadGeo (const GccEnt_QualifiedLin& Qualified1, |
56 | const Geom2dGcc_QCurve& Qualified2, |
57 | const Standard_Real Radius , |
58 | const Standard_Real Tolerance ): |
7fd59977 |
59 | |
60 | //======================================================================== |
61 | // initialisation des champs. + |
62 | //======================================================================== |
63 | |
1d19db8d |
64 | cirsol(1,aNbSolMAX) , |
65 | qualifier1(1,aNbSolMAX), |
66 | qualifier2(1,aNbSolMAX), |
67 | TheSame1(1,aNbSolMAX) , |
68 | TheSame2(1,aNbSolMAX) , |
69 | pnttg1sol(1,aNbSolMAX), |
70 | pnttg2sol(1,aNbSolMAX), |
71 | par1sol(1,aNbSolMAX) , |
72 | par2sol(1,aNbSolMAX) , |
73 | pararg1(1,aNbSolMAX) , |
74 | pararg2(1,aNbSolMAX) |
7fd59977 |
75 | { |
76 | |
74f5f8df |
77 | //======================================================================== |
78 | // Traitement. + |
79 | //======================================================================== |
80 | |
81 | Standard_Real Tol = Abs(Tolerance); |
82 | Standard_Real thefirst = -100000.; |
83 | Standard_Real thelast = 100000.; |
84 | Standard_Real firstparam; |
85 | Standard_Real lastparam; |
86 | gp_Dir2d dirx(1.,0.); |
87 | TColStd_Array1OfReal cote1(1,2); |
88 | TColStd_Array1OfReal cote2(1,2); |
89 | Standard_Integer nbrcote1=0; |
90 | Standard_Integer nbrcote2=0; |
91 | WellDone = Standard_False; |
92 | NbrSol = 0; |
93 | if (!(Qualified1.IsEnclosed() || |
94 | Qualified1.IsOutside() || Qualified1.IsUnqualified()) || |
95 | !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || |
96 | Qualified2.IsOutside() || Qualified2.IsUnqualified())) { |
97 | |
98 | GccEnt_BadQualifier::Raise(); |
99 | return; |
100 | } |
101 | gp_Lin2d L1 = Qualified1.Qualified(); |
102 | Standard_Real x1dir = (L1.Direction()).X(); |
103 | Standard_Real y1dir = (L1.Direction()).Y(); |
104 | Standard_Real lxloc = (L1.Location()).X(); |
105 | Standard_Real lyloc = (L1.Location()).Y(); |
106 | gp_Pnt2d origin1(lxloc,lyloc); |
107 | gp_Dir2d normL1(-y1dir,x1dir); |
578ce4be |
108 | Geom2dAdaptor_Curve Cu2= Qualified2.Qualified(); |
74f5f8df |
109 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } |
110 | else { |
111 | if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { |
112 | // ======================================================= |
113 | nbrcote1 = 1; |
114 | nbrcote2 = 1; |
115 | cote1(1) = Radius; |
116 | cote2(1) = Radius; |
117 | } |
118 | else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { |
119 | // ========================================================== |
120 | nbrcote1 = 1; |
121 | nbrcote2 = 1; |
122 | cote1(1) = Radius; |
123 | cote2(1) = -Radius; |
124 | } |
125 | else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { |
126 | // =========================================================== |
127 | nbrcote1 = 1; |
128 | nbrcote2 = 1; |
129 | cote1(1) = -Radius; |
130 | cote2(1) = Radius; |
131 | } |
132 | else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { |
133 | // ========================================================= |
134 | nbrcote1 = 1; |
135 | nbrcote2 = 1; |
136 | cote1(1) = -Radius; |
137 | cote2(1) = -Radius; |
138 | } |
139 | if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { |
140 | // ========================================================= |
141 | nbrcote1 = 1; |
142 | nbrcote2 = 2; |
143 | cote1(1) = Radius; |
144 | cote2(1) = Radius; |
145 | cote2(2) = -Radius; |
146 | } |
147 | if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { |
148 | // ========================================================= |
149 | nbrcote1 = 2; |
150 | nbrcote2 = 1; |
151 | cote1(1) = Radius; |
152 | cote1(2) = -Radius; |
153 | cote2(1) = Radius; |
154 | } |
155 | else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { |
156 | // ============================================================= |
157 | nbrcote1 = 1; |
158 | nbrcote2 = 2; |
159 | cote1(1) = -Radius; |
160 | cote2(1) = Radius; |
161 | cote2(2) = -Radius; |
162 | } |
163 | if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { |
164 | // ======================================================== |
165 | nbrcote1 = 2; |
166 | nbrcote2 = 1; |
167 | cote1(1) = Radius; |
168 | cote1(2) = -Radius; |
169 | cote2(1) = -Radius; |
170 | } |
171 | else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { |
172 | // ================================================================= |
173 | nbrcote1 = 2; |
174 | nbrcote2 = 2; |
175 | cote1(1) = Radius; |
176 | cote1(2) = -Radius; |
177 | cote2(1) = Radius; |
178 | cote2(2) = -Radius; |
179 | } |
180 | gp_Dir2d Dir(-y1dir,x1dir); |
181 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { |
182 | gp_Pnt2d Point(L1.Location().XY()+cote1(jcote1)*Dir.XY()); |
183 | gp_Lin2d Line(Point,L1.Direction()); // ligne avec deport. |
184 | IntRes2d_Domain D1; |
185 | for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { |
578ce4be |
186 | Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); |
187 | Adaptor3d_OffsetCurve C2(HCu2,cote2(jcote2)); |
188 | firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); |
189 | lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); |
190 | IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, |
191 | Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); |
192 | Geom2dInt_TheIntConicCurveOfGInter Intp(Line,D1,C2,D2,Tol,Tol); |
74f5f8df |
193 | if (Intp.IsDone()) { |
194 | if (!Intp.IsEmpty()) { |
195 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { |
196 | NbrSol++; |
197 | gp_Pnt2d Center(Intp.Point(i).Value()); |
198 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); |
199 | // ======================================================= |
200 | gp_Dir2d dc1(origin1.XY()-Center.XY()); |
201 | qualifier2(NbrSol) = Qualified2.Qualifier(); |
202 | if (!Qualified1.IsUnqualified()) { |
203 | qualifier1(NbrSol) = Qualified1.Qualifier(); |
204 | } |
205 | else if (dc1.Dot(normL1) > 0.0) { |
206 | qualifier1(NbrSol) = GccEnt_outside; |
207 | } |
208 | else { qualifier1(NbrSol) = GccEnt_enclosed; } |
209 | TheSame1(NbrSol) = 0; |
210 | TheSame2(NbrSol) = 0; |
211 | pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); |
212 | pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); |
213 | pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1); |
578ce4be |
214 | pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); |
74f5f8df |
215 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
216 | pnttg1sol(NbrSol)); |
217 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
218 | pnttg2sol(NbrSol)); |
219 | } |
220 | } |
221 | WellDone = Standard_True; |
222 | } |
223 | } |
224 | } |
225 | } |
226 | } |
7fd59977 |
227 | |
228 | // circulaire tant a une courbe et un cercle ,de rayon donne |
229 | //============================================================= |
230 | |
231 | //======================================================================== |
232 | // On initialise WellDone a false. + |
233 | // On recupere la courbe Cu2 et le cercle C1. + |
234 | // On sort en erreur dans les cas ou la construction est impossible. + |
235 | // On fait la parallele a Cu2 dans le bon sens. + |
236 | // On fait la parallele a C1 dans le bon sens. + |
237 | // On intersecte les paralleles ==> point de centre de la solution. + |
238 | // On cree la solution qu on ajoute aux solutions deja trouvees. + |
239 | // On remplit les champs. + |
240 | //======================================================================== |
241 | |
578ce4be |
242 | Geom2dGcc_Circ2d2TanRadGeo:: |
243 | Geom2dGcc_Circ2d2TanRadGeo (const GccEnt_QualifiedCirc& Qualified1, |
244 | const Geom2dGcc_QCurve& Qualified2, |
245 | const Standard_Real Radius , |
246 | const Standard_Real Tolerance ): |
7fd59977 |
247 | |
248 | //======================================================================== |
249 | // initialisation des champs. + |
250 | //======================================================================== |
251 | |
1d19db8d |
252 | cirsol(1,aNbSolMAX) , |
253 | qualifier1(1,aNbSolMAX), |
254 | qualifier2(1,aNbSolMAX), |
255 | TheSame1(1,aNbSolMAX) , |
256 | TheSame2(1,aNbSolMAX) , |
257 | pnttg1sol(1,aNbSolMAX), |
258 | pnttg2sol(1,aNbSolMAX), |
259 | par1sol(1,aNbSolMAX) , |
260 | par2sol(1,aNbSolMAX) , |
261 | pararg1(1,aNbSolMAX) , |
262 | pararg2(1,aNbSolMAX) |
7fd59977 |
263 | { |
264 | |
74f5f8df |
265 | //======================================================================== |
266 | // Traitement. + |
267 | //======================================================================== |
268 | |
269 | Standard_Real Tol = Abs(Tolerance); |
270 | Standard_Real thefirst = -100000.; |
271 | Standard_Real thelast = 100000.; |
272 | Standard_Real firstparam; |
273 | Standard_Real lastparam; |
274 | gp_Dir2d dirx(1.,0.); |
275 | TColStd_Array1OfReal cote1(1,2); |
276 | TColStd_Array1OfReal cote2(1,2); |
277 | Standard_Integer nbrcote1=0; |
278 | Standard_Integer nbrcote2=0; |
279 | WellDone = Standard_False; |
280 | NbrSol = 0; |
281 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || |
282 | Qualified1.IsOutside() || Qualified1.IsUnqualified()) || |
283 | !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || |
284 | Qualified2.IsOutside() || Qualified2.IsUnqualified())) { |
285 | GccEnt_BadQualifier::Raise(); |
286 | return; |
287 | } |
288 | gp_Circ2d C1 = Qualified1.Qualified(); |
289 | gp_Pnt2d center1(C1.Location()); |
578ce4be |
290 | Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); |
74f5f8df |
291 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } |
292 | else { |
293 | if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { |
294 | // ======================================================= |
295 | nbrcote1 = 1; |
296 | nbrcote2 = 1; |
297 | cote1(1) = Radius; |
298 | cote2(1) = Radius; |
299 | } |
300 | else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { |
301 | // ========================================================== |
302 | nbrcote1 = 1; |
303 | nbrcote2 = 1; |
304 | cote1(1) = Radius; |
305 | cote2(1) = -Radius; |
306 | } |
307 | else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { |
308 | // =========================================================== |
309 | nbrcote1 = 1; |
310 | nbrcote2 = 1; |
311 | cote1(1) = -Radius; |
312 | cote2(1) = Radius; |
313 | } |
314 | else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { |
315 | // ========================================================= |
316 | nbrcote1 = 1; |
317 | nbrcote2 = 1; |
318 | cote1(1) = -Radius; |
319 | cote2(1) = -Radius; |
320 | } |
321 | if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { |
322 | // ========================================================= |
323 | nbrcote1 = 1; |
324 | nbrcote2 = 2; |
325 | cote1(1) = Radius; |
326 | cote2(1) = Radius; |
327 | cote2(2) = -Radius; |
328 | } |
329 | if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { |
330 | // ========================================================= |
331 | nbrcote1 = 2; |
332 | nbrcote2 = 1; |
333 | cote1(1) = Radius; |
334 | cote1(2) = -Radius; |
335 | cote2(1) = Radius; |
336 | } |
337 | else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { |
338 | // ============================================================= |
339 | nbrcote1 = 1; |
340 | nbrcote2 = 2; |
341 | cote1(1) = -Radius; |
342 | cote2(1) = Radius; |
343 | cote2(2) = -Radius; |
344 | } |
345 | if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { |
346 | // ======================================================== |
347 | nbrcote1 = 2; |
348 | nbrcote2 = 1; |
349 | cote1(1) = Radius; |
350 | cote1(2) = -Radius; |
351 | cote2(1) = -Radius; |
352 | } |
353 | else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { |
354 | // ================================================================= |
355 | nbrcote1 = 2; |
356 | nbrcote2 = 2; |
357 | cote1(1) = Radius; |
358 | cote1(2) = -Radius; |
359 | cote2(1) = Radius; |
360 | cote2(2) = -Radius; |
361 | } |
362 | Standard_Real R1 = C1.Radius(); |
578ce4be |
363 | Geom2dInt_TheIntConicCurveOfGInter Intp; |
74f5f8df |
364 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { |
365 | gp_Circ2d Circ(C1.XAxis(),R1+cote1(jcote1)); |
366 | IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, |
367 | ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); |
368 | D1.SetEquivalentParameters(0.,2.*M_PI); |
369 | for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { |
578ce4be |
370 | Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); |
371 | Adaptor3d_OffsetCurve C2(HCu2,cote2(jcote2)); |
372 | firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); |
373 | lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); |
374 | IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, |
375 | Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); |
74f5f8df |
376 | Intp.Perform(Circ,D1,C2,D2,Tol,Tol); |
377 | if (Intp.IsDone()) { |
378 | if (!Intp.IsEmpty()) { |
379 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { |
380 | NbrSol++; |
381 | gp_Pnt2d Center(Intp.Point(i).Value()); |
382 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); |
383 | // ======================================================= |
0797d9d3 |
384 | #ifdef OCCT_DEBUG |
74f5f8df |
385 | gp_Dir2d dir1(Center.XY()-center1.XY()); |
7fd59977 |
386 | #else |
74f5f8df |
387 | Center.XY() ; |
388 | center1.XY() ; |
7fd59977 |
389 | #endif |
74f5f8df |
390 | Standard_Real distcc1 = Center.Distance(center1); |
391 | if (!Qualified1.IsUnqualified()) { |
392 | qualifier1(NbrSol) = Qualified1.Qualifier(); |
393 | } |
394 | else if (Abs(distcc1+Radius-R1) < Tol) { |
395 | qualifier1(NbrSol) = GccEnt_enclosed; |
396 | } |
397 | else if (Abs(distcc1-R1-Radius) < Tol) { |
398 | qualifier1(NbrSol) = GccEnt_outside; |
399 | } |
400 | else { qualifier1(NbrSol) = GccEnt_enclosing; } |
401 | qualifier2(NbrSol) = Qualified2.Qualifier(); |
402 | TheSame1(NbrSol) = 0; |
403 | TheSame2(NbrSol) = 0; |
404 | pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); |
405 | pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); |
406 | pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1); |
578ce4be |
407 | pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); |
74f5f8df |
408 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
409 | pnttg1sol(NbrSol)); |
410 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
411 | pnttg2sol(NbrSol)); |
412 | } |
413 | } |
414 | WellDone = Standard_True; |
415 | } |
416 | } |
417 | } |
418 | } |
419 | } |
7fd59977 |
420 | |
421 | // circulaire tant a une courbe et un point ,de rayon donne |
422 | //============================================================ |
423 | |
424 | //======================================================================== |
425 | // On initialise WellDone a false. + |
426 | // On recupere la courbe Cu1 et le point P2. + |
427 | // On sort en erreur dans les cas ou la construction est impossible. + |
428 | // On fait la parallele a Cu1 dans le bon sens. + |
429 | // On fait la parallele a P2 dans le bon sens. + |
430 | // On intersecte les paralleles ==> point de centre de la solution. + |
431 | // On cree la solution qu on ajoute aux solutions deja trouvees. + |
432 | // On remplit les champs. + |
433 | //======================================================================== |
434 | |
578ce4be |
435 | Geom2dGcc_Circ2d2TanRadGeo:: |
436 | Geom2dGcc_Circ2d2TanRadGeo (const Geom2dGcc_QCurve& Qualified1, |
437 | const gp_Pnt2d& Point2 , |
438 | const Standard_Real Radius , |
439 | const Standard_Real Tolerance ): |
7fd59977 |
440 | |
441 | //======================================================================== |
442 | // initialisation des champs. + |
443 | //======================================================================== |
444 | |
1d19db8d |
445 | cirsol(1,aNbSolMAX) , |
446 | qualifier1(1,aNbSolMAX), |
447 | qualifier2(1,aNbSolMAX), |
448 | TheSame1(1,aNbSolMAX) , |
449 | TheSame2(1,aNbSolMAX) , |
450 | pnttg1sol(1,aNbSolMAX), |
451 | pnttg2sol(1,aNbSolMAX), |
452 | par1sol(1,aNbSolMAX) , |
453 | par2sol(1,aNbSolMAX) , |
454 | pararg1(1,aNbSolMAX) , |
455 | pararg2(1,aNbSolMAX) |
7fd59977 |
456 | { |
457 | |
74f5f8df |
458 | //======================================================================== |
459 | // Traitement. + |
460 | //======================================================================== |
461 | |
462 | Standard_Real Tol = Abs(Tolerance); |
463 | Standard_Real thefirst = -100000.; |
464 | Standard_Real thelast = 100000.; |
465 | Standard_Real firstparam; |
466 | Standard_Real lastparam; |
467 | gp_Dir2d dirx(1.,0.); |
468 | TColStd_Array1OfReal cote1(1,2); |
469 | Standard_Integer nbrcote1=0; |
470 | WellDone = Standard_False; |
471 | NbrSol = 0; |
472 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || |
473 | Qualified1.IsOutside() || Qualified1.IsUnqualified())) { |
474 | GccEnt_BadQualifier::Raise(); |
475 | return; |
476 | } |
578ce4be |
477 | Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); |
74f5f8df |
478 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } |
479 | else { |
480 | if (Qualified1.IsEnclosed()) { |
481 | // =========================== |
482 | nbrcote1 = 1; |
483 | cote1(1) = Radius; |
484 | } |
485 | else if(Qualified1.IsOutside()) { |
486 | // =============================== |
487 | nbrcote1 = 1; |
488 | cote1(1) = -Radius; |
489 | } |
490 | else if(Qualified1.IsUnqualified()) { |
491 | // =================================== |
492 | nbrcote1 = 2; |
493 | cote1(1) = Radius; |
494 | cote1(2) = -Radius; |
495 | } |
496 | gp_Circ2d Circ(gp_Ax2d(Point2,gp_Dir2d(1.,0.)),Radius); |
497 | IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, |
498 | ElCLib::Value(M_PI+M_PI,Circ),M_PI+M_PI,Tol); |
499 | D1.SetEquivalentParameters(0.,M_PI+M_PI); |
578ce4be |
500 | Geom2dInt_TheIntConicCurveOfGInter Intp; |
74f5f8df |
501 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { |
578ce4be |
502 | Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); |
503 | Adaptor3d_OffsetCurve Cu2(HCu1,cote1(jcote1)); |
504 | firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(Cu2),thefirst); |
505 | lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(Cu2),thelast); |
506 | IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(Cu2,firstparam),firstparam,Tol, |
507 | Geom2dGcc_CurveToolGeo::Value(Cu2,lastparam),lastparam,Tol); |
74f5f8df |
508 | Intp.Perform(Circ,D1,Cu2,D2,Tol,Tol); |
509 | if (Intp.IsDone()) { |
510 | if (!Intp.IsEmpty()) { |
511 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { |
512 | NbrSol++; |
513 | gp_Pnt2d Center(Intp.Point(i).Value()); |
514 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); |
515 | // ======================================================= |
516 | qualifier1(NbrSol) = Qualified1.Qualifier(); |
517 | qualifier2(NbrSol) = GccEnt_noqualifier; |
518 | TheSame1(NbrSol) = 0; |
519 | TheSame2(NbrSol) = 0; |
520 | pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); |
521 | pararg2(NbrSol) = 0.; |
578ce4be |
522 | pnttg1sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)); |
74f5f8df |
523 | pnttg2sol(NbrSol) = Point2; |
524 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
525 | pnttg1sol(NbrSol)); |
526 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
527 | pnttg2sol(NbrSol)); |
528 | } |
529 | } |
530 | WellDone = Standard_True; |
531 | } |
532 | } |
533 | } |
534 | } |
535 | |
1d19db8d |
536 | //======================================================================= |
537 | //function : PrecRoot |
538 | //purpose : In case, when curves has tangent zones, intersection point |
539 | // found may be precised. This function uses precision algorithm |
540 | // of Extrema Curve-Curve method (dot product between every |
541 | // tangent vector and vector between points in two curves must |
542 | // be equal to zero). |
543 | //======================================================================= |
578ce4be |
544 | static void PrecRoot(const Adaptor3d_OffsetCurve& theC1, |
545 | const Adaptor3d_OffsetCurve& theC2, |
546 | const Standard_Real theU0, |
547 | const Standard_Real theV0, |
578ce4be |
548 | Standard_Real& theUfinal, |
549 | Standard_Real& theVfinal) |
74f5f8df |
550 | { |
1d19db8d |
551 | /* |
552 | It is necessary for precision to solve the system |
553 | |
554 | \left\{\begin{matrix} |
555 | (x_{1}(u)-x_{2}(v))*{x_{1}(u)}'+(y_{1}(u)-y_{2}(v))*{y_{1}(u)}'=0\\ |
556 | (x_{1}(u)-x_{2}(v))*{x_{2}(v)}'+(y_{1}(u)-y_{2}(v))*{y_{2}(v)}'=0 |
557 | \end{matrix}\right. |
558 | |
559 | Precision of any 2*2-system (two equation and two variables) |
560 | |
561 | \left\{\begin{matrix} |
562 | S_{1}(u,v)=0\\ |
563 | S_{2}(u,v)=0 |
564 | \end{matrix}\right. |
565 | |
566 | by Newton method can be made as follows: |
567 | |
568 | u=u_{0}-\left (\frac{\frac{\partial S_{2}}{\partial v}*S_{1}- |
569 | \frac{\partial S_{1}}{\partial v}*S_{2}} |
570 | {\frac{\partial S_{1}}{\partial u}* |
571 | \frac{\partial S_{2}}{\partial v}- |
572 | \frac{\partial S_{1}}{\partial v}* |
573 | \frac{\partial S_{2}}{\partial u}} \right )_{u_{0},v_{0}}\\ |
574 | v=v_{0}-\left (\frac{\frac{\partial S_{1}}{\partial u}*S_{2}- |
575 | \frac{\partial S_{2}}{\partial u}*S_{1}} |
576 | {\frac{\partial S_{1}}{\partial u}* |
577 | \frac{\partial S_{2}}{\partial v}- |
578 | \frac{\partial S_{1}}{\partial v}* |
579 | \frac{\partial S_{2}}{\partial u}} \right )_{u_{0},v_{0}} |
580 | \end{matrix}\right. |
581 | |
582 | where u_{0} and v_{0} are initial values or values computed on previous iteration. |
583 | */ |
74f5f8df |
584 | |
1d19db8d |
585 | theUfinal = theU0; |
586 | theVfinal = theV0; |
74f5f8df |
587 | |
74f5f8df |
588 | const Standard_Integer aNbIterMax = 100; |
589 | |
1d19db8d |
590 | Standard_Real aU = theU0, aV = theV0; |
591 | gp_Pnt2d aPu, aPv; |
592 | gp_Vec2d aD1u, aD1v, aD2u, aD2v; |
74f5f8df |
593 | |
1d19db8d |
594 | Standard_Integer aNbIter = 0; |
74f5f8df |
595 | |
1d19db8d |
596 | Standard_Real aStepU = 0.0, aStepV = 0.0; |
74f5f8df |
597 | |
1d19db8d |
598 | Standard_Real aSQDistPrev = RealFirst(); |
74f5f8df |
599 | |
1d19db8d |
600 | Geom2dGcc_CurveToolGeo::D2(theC1, aU, aPu, aD1u, aD2u); |
601 | Geom2dGcc_CurveToolGeo::D2(theC2, aV, aPv, aD1v, aD2v); |
578ce4be |
602 | |
1d19db8d |
603 | const Standard_Real aCrProd = Abs(aD1u.Crossed(aD1v)); |
604 | if(aCrProd*aCrProd > 1.0e-6* |
605 | aD1u.SquareMagnitude()*aD1v.SquareMagnitude()) |
606 | { |
607 | //Curves are not tangent. Therefore, we consider that |
608 | //2D-intersection algorithm have found good point which |
609 | //did not need in more precision. |
610 | return; |
611 | } |
74f5f8df |
612 | |
613 | do |
614 | { |
1d19db8d |
615 | aNbIter++; |
74f5f8df |
616 | |
1d19db8d |
617 | gp_Vec2d aVuv(aPv, aPu); |
74f5f8df |
618 | |
1d19db8d |
619 | Standard_Real aSQDist = aVuv.SquareMagnitude(); |
620 | if(IsEqual(aSQDist, 0.0)) |
621 | break; |
74f5f8df |
622 | |
1d19db8d |
623 | if((aNbIter == 1) || (aSQDist < aSQDistPrev)) |
74f5f8df |
624 | { |
625 | aSQDistPrev = aSQDist; |
74f5f8df |
626 | theUfinal = aU; |
627 | theVfinal = aV; |
628 | } |
74f5f8df |
629 | |
74f5f8df |
630 | |
1d19db8d |
631 | Standard_Real aG1 = aD1u.Magnitude(); |
632 | Standard_Real aG2 = aD1v.Magnitude(); |
74f5f8df |
633 | |
1d19db8d |
634 | if(IsEqual(aG1, 0.0) || IsEqual(aG2, 0.0)) |
635 | {//Here we do not processing singular cases. |
636 | break; |
637 | } |
74f5f8df |
638 | |
1d19db8d |
639 | Standard_Real aF1 = aVuv.Dot(aD1u); |
640 | Standard_Real aF2 = aVuv.Dot(aD1v); |
74f5f8df |
641 | |
1d19db8d |
642 | Standard_Real aFIu = aVuv.Dot(aD2u); |
643 | Standard_Real aFIv = aVuv.Dot(aD2v); |
644 | Standard_Real aPSIu = aD1u.Dot(aD2u); |
645 | Standard_Real aPSIv = aD1v.Dot(aD2v); |
7fd59977 |
646 | |
1d19db8d |
647 | Standard_Real aTheta = aD1u*aD1v; |
74f5f8df |
648 | |
1d19db8d |
649 | Standard_Real aS1 = aF1/aG1; |
650 | Standard_Real aS2 = aF2/aG2; |
74f5f8df |
651 | |
1d19db8d |
652 | Standard_Real aDS1u = (aG1*aG1+aFIu)/aG1 - (aS1*aPSIu/(aG1*aG1)); |
653 | Standard_Real aDS1v = -aTheta/aG1; |
654 | Standard_Real aDS2u = aTheta/aG2; |
655 | Standard_Real aDS2v = (aFIv-aG2*aG2)/aG2 - (aS2*aPSIv/(aG2*aG2)); |
74f5f8df |
656 | |
1d19db8d |
657 | Standard_Real aDet = aDS1u*aDS2v-aDS1v*aDS2u; |
74f5f8df |
658 | |
1d19db8d |
659 | if(IsEqual(aDet, 0.0)) |
660 | { |
661 | if(!IsEqual(aStepV, 0.0) && !IsEqual(aDS1u, 0.0)) |
662 | { |
663 | aV += aStepV; |
664 | aU = aU - (aDS1v*aStepV - aS1)/aDS1u; |
665 | } |
666 | else if(!IsEqual(aStepU, 0.0) && !IsEqual(aDS1v, 0.0)) |
667 | { |
668 | aU += aStepU; |
669 | aV = aV - (aDS1u*aStepU - aS1)/aDS1v; |
670 | } |
671 | else |
672 | { |
673 | break; |
674 | } |
675 | } |
74f5f8df |
676 | else |
1d19db8d |
677 | { |
678 | aStepU = -(aS1*aDS2v-aS2*aDS1v)/aDet; |
679 | aStepV = -(aS2*aDS1u-aS1*aDS2u)/aDet; |
680 | |
681 | if(Abs(aStepU) < Epsilon(Abs(aU))) |
682 | { |
683 | if(Abs(aStepV) < Epsilon(Abs(aV))) |
684 | { |
685 | break; |
686 | } |
687 | } |
74f5f8df |
688 | |
1d19db8d |
689 | aU += aStepU; |
690 | aV += aStepV; |
691 | } |
74f5f8df |
692 | |
1d19db8d |
693 | Geom2dGcc_CurveToolGeo::D2(theC1, aU, aPu, aD1u, aD2u); |
694 | Geom2dGcc_CurveToolGeo::D2(theC2, aV, aPv, aD1v, aD2v); |
74f5f8df |
695 | } |
1d19db8d |
696 | while(aNbIter <= aNbIterMax); |
697 | } |
74f5f8df |
698 | |
74f5f8df |
699 | |
7fd59977 |
700 | |
701 | // circulaire tant a deux courbes ,de rayon donne |
702 | //================================================== |
703 | |
704 | //======================================================================== |
705 | // On initialise WellDone a false. + |
706 | // On recupere les courbes Cu1 et Cu2. + |
707 | // On sort en erreur dans les cas ou la construction est impossible. + |
708 | // On fait la parallele a Cu1 dans le bon sens. + |
709 | // On fait la parallele a Cu2 dans le bon sens. + |
710 | // On intersecte les paralleles ==> point de centre de la solution. + |
711 | // On cree la solution qu on ajoute aux solutions deja trouvees. + |
712 | // On remplit les champs. + |
713 | //======================================================================== |
578ce4be |
714 | Geom2dGcc_Circ2d2TanRadGeo:: |
715 | Geom2dGcc_Circ2d2TanRadGeo (const Geom2dGcc_QCurve& Qualified1, |
716 | const Geom2dGcc_QCurve& Qualified2, |
717 | const Standard_Real Radius , |
718 | const Standard_Real Tolerance ): |
7fd59977 |
719 | |
720 | //======================================================================== |
721 | // initialisation des champs. + |
722 | //======================================================================== |
723 | |
1d19db8d |
724 | cirsol(1,aNbSolMAX) , |
725 | qualifier1(1,aNbSolMAX), |
726 | qualifier2(1,aNbSolMAX), |
727 | TheSame1(1,aNbSolMAX) , |
728 | TheSame2(1,aNbSolMAX) , |
729 | pnttg1sol(1,aNbSolMAX), |
730 | pnttg2sol(1,aNbSolMAX), |
731 | par1sol(1,aNbSolMAX) , |
732 | par2sol(1,aNbSolMAX) , |
733 | pararg1(1,aNbSolMAX) , |
734 | pararg2(1,aNbSolMAX) |
7fd59977 |
735 | { |
736 | |
74f5f8df |
737 | //======================================================================== |
738 | // Traitement. + |
739 | //======================================================================== |
740 | |
741 | Standard_Real Tol = Abs(Tolerance); |
742 | Standard_Real thefirst = -100000.; |
743 | Standard_Real thelast = 100000.; |
744 | Standard_Real firstparam; |
745 | Standard_Real lastparam; |
746 | gp_Dir2d dirx(1.,0.); |
747 | TColStd_Array1OfReal cote1(1,2); |
748 | TColStd_Array1OfReal cote2(1,2); |
749 | Standard_Integer nbrcote1=0; |
750 | Standard_Integer nbrcote2=0; |
751 | WellDone = Standard_False; |
752 | NbrSol = 0; |
753 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || |
754 | Qualified1.IsOutside() || Qualified1.IsUnqualified()) || |
755 | !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || |
756 | Qualified2.IsOutside() || Qualified2.IsUnqualified())) { |
757 | GccEnt_BadQualifier::Raise(); |
758 | return; |
759 | } |
578ce4be |
760 | Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified(); |
761 | Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified(); |
74f5f8df |
762 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } |
763 | else { |
764 | if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { |
765 | // ======================================================= |
766 | nbrcote1 = 1; |
767 | nbrcote2 = 1; |
768 | cote1(1) = Radius; |
769 | cote2(1) = Radius; |
770 | } |
771 | else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { |
772 | // ========================================================== |
773 | nbrcote1 = 1; |
774 | nbrcote2 = 1; |
775 | cote1(1) = Radius; |
776 | cote2(1) = -Radius; |
777 | } |
778 | else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { |
779 | // =========================================================== |
780 | nbrcote1 = 1; |
781 | nbrcote2 = 1; |
782 | cote1(1) = -Radius; |
783 | cote2(1) = Radius; |
784 | } |
785 | else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { |
786 | // ========================================================= |
787 | nbrcote1 = 1; |
788 | nbrcote2 = 1; |
789 | cote1(1) = -Radius; |
790 | cote2(1) = -Radius; |
791 | } |
792 | if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { |
793 | // ========================================================= |
794 | nbrcote1 = 1; |
795 | nbrcote2 = 2; |
796 | cote1(1) = Radius; |
797 | cote2(1) = Radius; |
798 | cote2(2) = -Radius; |
799 | } |
800 | if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { |
801 | // ========================================================= |
802 | nbrcote1 = 2; |
803 | nbrcote2 = 1; |
804 | cote1(1) = Radius; |
805 | cote1(2) = -Radius; |
806 | cote2(1) = Radius; |
807 | } |
808 | else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { |
809 | // ============================================================= |
810 | nbrcote1 = 1; |
811 | nbrcote2 = 2; |
812 | cote1(1) = -Radius; |
813 | cote2(1) = Radius; |
814 | cote2(2) = -Radius; |
815 | } |
816 | if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { |
817 | // ======================================================== |
818 | nbrcote1 = 2; |
819 | nbrcote2 = 1; |
820 | cote1(1) = Radius; |
821 | cote1(2) = -Radius; |
822 | cote2(1) = -Radius; |
823 | } |
824 | else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { |
825 | // ================================================================= |
826 | nbrcote1 = 2; |
827 | nbrcote2 = 2; |
828 | cote1(1) = Radius; |
829 | cote1(2) = -Radius; |
830 | cote2(1) = Radius; |
831 | cote2(2) = -Radius; |
832 | } |
578ce4be |
833 | Geom2dInt_GInter Intp; |
74f5f8df |
834 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { |
578ce4be |
835 | Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1); |
836 | Adaptor3d_OffsetCurve C1(HCu1,cote1(jcote1)); |
837 | firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C1),thefirst); |
838 | lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C1),thelast); |
0797d9d3 |
839 | #ifdef OCCT_DEBUG |
51740958 |
840 | IntRes2d_Domain D2C1(Geom2dGcc_CurveToolGeo::Value(C1,firstparam),firstparam,Tol, |
578ce4be |
841 | Geom2dGcc_CurveToolGeo::Value(C1,lastparam),lastparam,Tol); |
7fd59977 |
842 | #else |
578ce4be |
843 | Geom2dGcc_CurveToolGeo::Value(C1,firstparam); |
844 | Geom2dGcc_CurveToolGeo::Value(C1,lastparam); |
7fd59977 |
845 | #endif |
74f5f8df |
846 | for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { |
578ce4be |
847 | Handle(Geom2dAdaptor_HCurve) HCu2 = new Geom2dAdaptor_HCurve(Cu2); |
848 | Adaptor3d_OffsetCurve C2(HCu2,cote2(jcote2)); |
849 | firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst); |
850 | lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast); |
0797d9d3 |
851 | #ifdef OCCT_DEBUG |
51740958 |
852 | IntRes2d_Domain D2C2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol, |
578ce4be |
853 | Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol); |
7fd59977 |
854 | #else |
578ce4be |
855 | Geom2dGcc_CurveToolGeo::Value(C2,firstparam); |
856 | Geom2dGcc_CurveToolGeo::Value(C2,lastparam); |
7fd59977 |
857 | #endif |
74f5f8df |
858 | Intp.Perform(C1,C2,Tol,Tol); |
859 | if (Intp.IsDone()) { |
860 | if (!Intp.IsEmpty()) { |
1d19db8d |
861 | const Standard_Real aSQApproxTol = Precision::Approximation() * |
862 | Precision::Approximation(); |
74f5f8df |
863 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) |
864 | { |
865 | Standard_Real aU0 = Intp.Point(i).ParamOnFirst(); |
866 | Standard_Real aV0 = Intp.Point(i).ParamOnSecond(); |
867 | |
868 | Standard_Real aU1 = aU0-Precision::PApproximation(); |
869 | Standard_Real aV1 = aV0-Precision::PApproximation(); |
870 | |
871 | Standard_Real aU2 = aU0+Precision::PApproximation(); |
872 | Standard_Real aV2 = aV0+Precision::PApproximation(); |
873 | |
578ce4be |
874 | gp_Pnt2d P11 = Geom2dGcc_CurveToolGeo::Value(C1,aU1); |
875 | gp_Pnt2d P12 = Geom2dGcc_CurveToolGeo::Value(C2,aV1); |
876 | gp_Pnt2d P21 = Geom2dGcc_CurveToolGeo::Value(C1,aU2); |
877 | gp_Pnt2d P22 = Geom2dGcc_CurveToolGeo::Value(C2,aV2); |
74f5f8df |
878 | |
1d19db8d |
879 | Standard_Real aDist1112 = P11.SquareDistance(P12); |
880 | Standard_Real aDist1122 = P11.SquareDistance(P22); |
74f5f8df |
881 | |
1d19db8d |
882 | Standard_Real aDist1221 = P12.SquareDistance(P21); |
883 | Standard_Real aDist2122 = P21.SquareDistance(P22); |
74f5f8df |
884 | |
1d19db8d |
885 | if( (Min(aDist1112, aDist1122) <= aSQApproxTol) && |
886 | (Min(aDist1221, aDist2122) <= aSQApproxTol)) |
74f5f8df |
887 | { |
1d19db8d |
888 | PrecRoot(C1, C2, aU0, aV0, aU0, aV0); |
74f5f8df |
889 | } |
890 | |
891 | NbrSol++; |
578ce4be |
892 | gp_Pnt2d Center(Geom2dGcc_CurveToolGeo::Value(C1, aU0)); |
74f5f8df |
893 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); |
894 | // ======================================================= |
895 | qualifier1(NbrSol) = Qualified1.Qualifier(); |
896 | qualifier1(NbrSol) = Qualified1.Qualifier(); |
897 | TheSame1(NbrSol) = 0; |
898 | TheSame2(NbrSol) = 0; |
899 | pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); |
900 | pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); |
578ce4be |
901 | pnttg1sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)); |
902 | pnttg2sol(NbrSol) = Geom2dGcc_CurveTool::Value(Cu2,pararg2(NbrSol)); |
74f5f8df |
903 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
904 | pnttg1sol(NbrSol)); |
905 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), |
906 | pnttg2sol(NbrSol)); |
907 | } |
908 | } |
909 | |
910 | WellDone = Standard_True; |
911 | } |
912 | } |
913 | } |
914 | } |
915 | } |
7fd59977 |
916 | |
917 | //========================================================================= |
918 | |
578ce4be |
919 | Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
920 | IsDone () const { return WellDone; } |
7fd59977 |
921 | |
578ce4be |
922 | Standard_Integer Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
923 | NbSolutions () const { return NbrSol; } |
7fd59977 |
924 | |
578ce4be |
925 | gp_Circ2d Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
926 | ThisSolution (const Standard_Integer Index) const |
7fd59977 |
927 | { |
928 | if (!WellDone) { StdFail_NotDone::Raise(); } |
929 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
930 | return cirsol(Index); |
931 | } |
932 | |
578ce4be |
933 | void Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
934 | WhichQualifier(const Standard_Integer Index , |
935 | GccEnt_Position& Qualif1 , |
936 | GccEnt_Position& Qualif2 ) const |
7fd59977 |
937 | { |
938 | if (!WellDone) { StdFail_NotDone::Raise(); } |
939 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
940 | else { |
941 | Qualif1 = qualifier1(Index); |
942 | Qualif2 = qualifier2(Index); |
943 | } |
944 | } |
945 | |
578ce4be |
946 | void Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
947 | Tangency1 (const Standard_Integer Index, |
948 | Standard_Real& ParSol, |
949 | Standard_Real& ParArg, |
950 | gp_Pnt2d& PntSol) const{ |
951 | if (!WellDone) { StdFail_NotDone::Raise(); } |
952 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
953 | else { |
954 | if (TheSame1(Index) == 0) { |
955 | ParSol = par1sol(Index); |
956 | ParArg = pararg1(Index); |
957 | PntSol = gp_Pnt2d(pnttg1sol(Index)); |
958 | } |
959 | else { StdFail_NotDone::Raise(); } |
960 | } |
961 | } |
7fd59977 |
962 | |
578ce4be |
963 | void Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
964 | Tangency2 (const Standard_Integer Index, |
965 | Standard_Real& ParSol, |
966 | Standard_Real& ParArg, |
967 | gp_Pnt2d& PntSol) const{ |
968 | if (!WellDone) { StdFail_NotDone::Raise(); } |
969 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
970 | else { |
971 | if (TheSame2(Index) == 0) { |
972 | ParSol = par2sol(Index); |
973 | ParArg = pararg2(Index); |
974 | PntSol = gp_Pnt2d(pnttg2sol(Index)); |
975 | } |
976 | else { StdFail_NotDone::Raise(); } |
977 | } |
978 | } |
7fd59977 |
979 | |
578ce4be |
980 | Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
981 | IsTheSame1 (const Standard_Integer Index) const |
7fd59977 |
982 | { |
983 | if (!WellDone) { StdFail_NotDone::Raise(); } |
984 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
985 | |
986 | if (TheSame1(Index) == 0) { return Standard_False; } |
987 | return Standard_True; |
988 | } |
989 | |
578ce4be |
990 | Standard_Boolean Geom2dGcc_Circ2d2TanRadGeo:: |
74f5f8df |
991 | IsTheSame2 (const Standard_Integer Index) const |
7fd59977 |
992 | { |
993 | if (!WellDone) { StdFail_NotDone::Raise(); } |
994 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
995 | |
996 | if (TheSame2(Index) == 0) { return Standard_False; } |
997 | return Standard_True; |
998 | } |
999 | |