Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File GccGeo_Circ2d2TanRad.gxx, REG 19/07/91 |
2 | ||
3 | #include <ElCLib.hxx> | |
4 | #include <gp_Ax2d.hxx> | |
5 | #include <gp_Circ2d.hxx> | |
6 | #include <gp_Lin2d.hxx> | |
7 | #include <Standard_NegativeValue.hxx> | |
8 | #include <Standard_OutOfRange.hxx> | |
9 | #include <StdFail_NotDone.hxx> | |
10 | #include <TColStd_Array1OfReal.hxx> | |
11 | #include <GccEnt_BadQualifier.hxx> | |
12 | #include <IntRes2d_Domain.hxx> | |
13 | #include <IntRes2d_IntersectionPoint.hxx> | |
14 | ||
15 | // circulaire tant a une courbe et une droite ,de rayon donne | |
16 | //============================================================== | |
17 | ||
18 | //======================================================================== | |
19 | // On initialise WellDone a false. + | |
20 | // On recupere la courbe Cu2 et la droite L1. + | |
21 | // On sort en erreur dans les cas ou la construction est impossible. + | |
22 | // On fait la parallele a Cu2 dans le bon sens. + | |
23 | // On fait la parallele a L1 dans le bon sens. + | |
24 | // On intersecte les paralleles ==> point de centre de la solution. + | |
25 | // On cree la solution qu on ajoute aux solutions deja trouvees. + | |
26 | // On remplit les champs. + | |
27 | //======================================================================== | |
28 | ||
29 | GccGeo_Circ2d2TanRad:: | |
30 | GccGeo_Circ2d2TanRad (const GccEnt_QualifiedLin& Qualified1, | |
31 | const TheQCurve& Qualified2, | |
32 | const Standard_Real Radius , | |
33 | const Standard_Real Tolerance ): | |
34 | ||
35 | //======================================================================== | |
36 | // initialisation des champs. + | |
37 | //======================================================================== | |
38 | ||
39 | cirsol(1,16) , | |
40 | qualifier1(1,16), | |
41 | qualifier2(1,16), | |
42 | TheSame1(1,16) , | |
43 | TheSame2(1,16) , | |
44 | pnttg1sol(1,16), | |
45 | pnttg2sol(1,16), | |
46 | par1sol(1,16) , | |
47 | par2sol(1,16) , | |
48 | pararg1(1,16) , | |
49 | pararg2(1,16) | |
50 | { | |
51 | ||
52 | //======================================================================== | |
53 | // Traitement. + | |
54 | //======================================================================== | |
55 | ||
56 | Standard_Real Tol = Abs(Tolerance); | |
57 | Standard_Real thefirst = -100000.; | |
58 | Standard_Real thelast = 100000.; | |
59 | Standard_Real firstparam; | |
60 | Standard_Real lastparam; | |
61 | gp_Dir2d dirx(1.,0.); | |
62 | TColStd_Array1OfReal cote1(1,2); | |
63 | TColStd_Array1OfReal cote2(1,2); | |
64 | Standard_Integer nbrcote1=0; | |
65 | Standard_Integer nbrcote2=0; | |
66 | WellDone = Standard_False; | |
67 | NbrSol = 0; | |
68 | if (!(Qualified1.IsEnclosed() || | |
69 | Qualified1.IsOutside() || Qualified1.IsUnqualified()) || | |
70 | !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || | |
71 | Qualified2.IsOutside() || Qualified2.IsUnqualified())) { | |
72 | ||
73 | GccEnt_BadQualifier::Raise(); | |
74 | return; | |
75 | } | |
76 | gp_Lin2d L1 = Qualified1.Qualified(); | |
77 | Standard_Real x1dir = (L1.Direction()).X(); | |
78 | Standard_Real y1dir = (L1.Direction()).Y(); | |
79 | Standard_Real lxloc = (L1.Location()).X(); | |
80 | Standard_Real lyloc = (L1.Location()).Y(); | |
81 | gp_Pnt2d origin1(lxloc,lyloc); | |
82 | gp_Dir2d normL1(-y1dir,x1dir); | |
83 | TheCurve Cu2= Qualified2.Qualified(); | |
84 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } | |
85 | else { | |
86 | if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { | |
87 | // ======================================================= | |
88 | nbrcote1 = 1; | |
89 | nbrcote2 = 1; | |
90 | cote1(1) = Radius; | |
91 | cote2(1) = Radius; | |
92 | } | |
93 | else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { | |
94 | // ========================================================== | |
95 | nbrcote1 = 1; | |
96 | nbrcote2 = 1; | |
97 | cote1(1) = Radius; | |
98 | cote2(1) = -Radius; | |
99 | } | |
100 | else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { | |
101 | // =========================================================== | |
102 | nbrcote1 = 1; | |
103 | nbrcote2 = 1; | |
104 | cote1(1) = -Radius; | |
105 | cote2(1) = Radius; | |
106 | } | |
107 | else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { | |
108 | // ========================================================= | |
109 | nbrcote1 = 1; | |
110 | nbrcote2 = 1; | |
111 | cote1(1) = -Radius; | |
112 | cote2(1) = -Radius; | |
113 | } | |
114 | if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { | |
115 | // ========================================================= | |
116 | nbrcote1 = 1; | |
117 | nbrcote2 = 2; | |
118 | cote1(1) = Radius; | |
119 | cote2(1) = Radius; | |
120 | cote2(2) = -Radius; | |
121 | } | |
122 | if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { | |
123 | // ========================================================= | |
124 | nbrcote1 = 2; | |
125 | nbrcote2 = 1; | |
126 | cote1(1) = Radius; | |
127 | cote1(2) = -Radius; | |
128 | cote2(1) = Radius; | |
129 | } | |
130 | else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { | |
131 | // ============================================================= | |
132 | nbrcote1 = 1; | |
133 | nbrcote2 = 2; | |
134 | cote1(1) = -Radius; | |
135 | cote2(1) = Radius; | |
136 | cote2(2) = -Radius; | |
137 | } | |
138 | if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { | |
139 | // ======================================================== | |
140 | nbrcote1 = 2; | |
141 | nbrcote2 = 1; | |
142 | cote1(1) = Radius; | |
143 | cote1(2) = -Radius; | |
144 | cote2(1) = -Radius; | |
145 | } | |
146 | else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { | |
147 | // ================================================================= | |
148 | nbrcote1 = 2; | |
149 | nbrcote2 = 2; | |
150 | cote1(1) = Radius; | |
151 | cote1(2) = -Radius; | |
152 | cote2(1) = Radius; | |
153 | cote2(2) = -Radius; | |
154 | } | |
155 | gp_Dir2d Dir(-y1dir,x1dir); | |
156 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { | |
157 | gp_Pnt2d Point(L1.Location().XY()+cote1(jcote1)*Dir.XY()); | |
158 | gp_Lin2d Line(Point,L1.Direction()); // ligne avec deport. | |
159 | IntRes2d_Domain D1; | |
160 | for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { | |
161 | Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(Cu2); | |
162 | TheParGenCurve C2(HCu2,cote2(jcote2)); | |
163 | firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); | |
164 | lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); | |
165 | IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, | |
166 | TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); | |
167 | TheIntConicCurve Intp(Line,D1,C2,D2,Tol,Tol); | |
168 | if (Intp.IsDone()) { | |
169 | if (!Intp.IsEmpty()) { | |
170 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { | |
171 | NbrSol++; | |
172 | gp_Pnt2d Center(Intp.Point(i).Value()); | |
173 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); | |
174 | // ======================================================= | |
175 | gp_Dir2d dc1(origin1.XY()-Center.XY()); | |
176 | qualifier2(NbrSol) = Qualified2.Qualifier(); | |
177 | if (!Qualified1.IsUnqualified()) { | |
178 | qualifier1(NbrSol) = Qualified1.Qualifier(); | |
179 | } | |
180 | else if (dc1.Dot(normL1) > 0.0) { | |
181 | qualifier1(NbrSol) = GccEnt_outside; | |
182 | } | |
183 | else { qualifier1(NbrSol) = GccEnt_enclosed; } | |
184 | TheSame1(NbrSol) = 0; | |
185 | TheSame2(NbrSol) = 0; | |
186 | pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); | |
187 | pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); | |
188 | pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1); | |
189 | pnttg2sol(NbrSol) = TheTool::Value(Cu2,pararg2(NbrSol)); | |
190 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
191 | pnttg1sol(NbrSol)); | |
192 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
193 | pnttg2sol(NbrSol)); | |
194 | } | |
195 | } | |
196 | WellDone = Standard_True; | |
197 | } | |
198 | } | |
199 | } | |
200 | } | |
201 | } | |
202 | ||
203 | // circulaire tant a une courbe et un cercle ,de rayon donne | |
204 | //============================================================= | |
205 | ||
206 | //======================================================================== | |
207 | // On initialise WellDone a false. + | |
208 | // On recupere la courbe Cu2 et le cercle C1. + | |
209 | // On sort en erreur dans les cas ou la construction est impossible. + | |
210 | // On fait la parallele a Cu2 dans le bon sens. + | |
211 | // On fait la parallele a C1 dans le bon sens. + | |
212 | // On intersecte les paralleles ==> point de centre de la solution. + | |
213 | // On cree la solution qu on ajoute aux solutions deja trouvees. + | |
214 | // On remplit les champs. + | |
215 | //======================================================================== | |
216 | ||
217 | GccGeo_Circ2d2TanRad:: | |
218 | GccGeo_Circ2d2TanRad (const GccEnt_QualifiedCirc& Qualified1, | |
219 | const TheQCurve& Qualified2, | |
220 | const Standard_Real Radius , | |
221 | const Standard_Real Tolerance ): | |
222 | ||
223 | //======================================================================== | |
224 | // initialisation des champs. + | |
225 | //======================================================================== | |
226 | ||
227 | cirsol(1,16) , | |
228 | qualifier1(1,16), | |
229 | qualifier2(1,16), | |
230 | TheSame1(1,16) , | |
231 | TheSame2(1,16) , | |
232 | pnttg1sol(1,16), | |
233 | pnttg2sol(1,16), | |
234 | par1sol(1,16) , | |
235 | par2sol(1,16) , | |
236 | pararg1(1,16) , | |
237 | pararg2(1,16) | |
238 | { | |
239 | ||
240 | //======================================================================== | |
241 | // Traitement. + | |
242 | //======================================================================== | |
243 | ||
244 | Standard_Real Tol = Abs(Tolerance); | |
245 | Standard_Real thefirst = -100000.; | |
246 | Standard_Real thelast = 100000.; | |
247 | Standard_Real firstparam; | |
248 | Standard_Real lastparam; | |
249 | gp_Dir2d dirx(1.,0.); | |
250 | TColStd_Array1OfReal cote1(1,2); | |
251 | TColStd_Array1OfReal cote2(1,2); | |
252 | Standard_Integer nbrcote1=0; | |
253 | Standard_Integer nbrcote2=0; | |
254 | WellDone = Standard_False; | |
255 | NbrSol = 0; | |
256 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || | |
257 | Qualified1.IsOutside() || Qualified1.IsUnqualified()) || | |
258 | !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || | |
259 | Qualified2.IsOutside() || Qualified2.IsUnqualified())) { | |
260 | GccEnt_BadQualifier::Raise(); | |
261 | return; | |
262 | } | |
263 | gp_Circ2d C1 = Qualified1.Qualified(); | |
264 | gp_Pnt2d center1(C1.Location()); | |
265 | TheCurve Cu2 = Qualified2.Qualified(); | |
266 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } | |
267 | else { | |
268 | if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { | |
269 | // ======================================================= | |
270 | nbrcote1 = 1; | |
271 | nbrcote2 = 1; | |
272 | cote1(1) = Radius; | |
273 | cote2(1) = Radius; | |
274 | } | |
275 | else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { | |
276 | // ========================================================== | |
277 | nbrcote1 = 1; | |
278 | nbrcote2 = 1; | |
279 | cote1(1) = Radius; | |
280 | cote2(1) = -Radius; | |
281 | } | |
282 | else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { | |
283 | // =========================================================== | |
284 | nbrcote1 = 1; | |
285 | nbrcote2 = 1; | |
286 | cote1(1) = -Radius; | |
287 | cote2(1) = Radius; | |
288 | } | |
289 | else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { | |
290 | // ========================================================= | |
291 | nbrcote1 = 1; | |
292 | nbrcote2 = 1; | |
293 | cote1(1) = -Radius; | |
294 | cote2(1) = -Radius; | |
295 | } | |
296 | if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { | |
297 | // ========================================================= | |
298 | nbrcote1 = 1; | |
299 | nbrcote2 = 2; | |
300 | cote1(1) = Radius; | |
301 | cote2(1) = Radius; | |
302 | cote2(2) = -Radius; | |
303 | } | |
304 | if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { | |
305 | // ========================================================= | |
306 | nbrcote1 = 2; | |
307 | nbrcote2 = 1; | |
308 | cote1(1) = Radius; | |
309 | cote1(2) = -Radius; | |
310 | cote2(1) = Radius; | |
311 | } | |
312 | else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { | |
313 | // ============================================================= | |
314 | nbrcote1 = 1; | |
315 | nbrcote2 = 2; | |
316 | cote1(1) = -Radius; | |
317 | cote2(1) = Radius; | |
318 | cote2(2) = -Radius; | |
319 | } | |
320 | if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { | |
321 | // ======================================================== | |
322 | nbrcote1 = 2; | |
323 | nbrcote2 = 1; | |
324 | cote1(1) = Radius; | |
325 | cote1(2) = -Radius; | |
326 | cote2(1) = -Radius; | |
327 | } | |
328 | else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { | |
329 | // ================================================================= | |
330 | nbrcote1 = 2; | |
331 | nbrcote2 = 2; | |
332 | cote1(1) = Radius; | |
333 | cote1(2) = -Radius; | |
334 | cote2(1) = Radius; | |
335 | cote2(2) = -Radius; | |
336 | } | |
337 | Standard_Real R1 = C1.Radius(); | |
338 | TheIntConicCurve Intp; | |
339 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { | |
340 | gp_Circ2d Circ(C1.XAxis(),R1+cote1(jcote1)); | |
341 | IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, | |
c6541a0c D |
342 | ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol); |
343 | D1.SetEquivalentParameters(0.,2.*M_PI); | |
7fd59977 | 344 | for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { |
345 | Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(Cu2); | |
346 | TheParGenCurve C2(HCu2,cote2(jcote2)); | |
347 | firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); | |
348 | lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); | |
349 | IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, | |
350 | TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); | |
351 | Intp.Perform(Circ,D1,C2,D2,Tol,Tol); | |
352 | if (Intp.IsDone()) { | |
353 | if (!Intp.IsEmpty()) { | |
354 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { | |
355 | NbrSol++; | |
356 | gp_Pnt2d Center(Intp.Point(i).Value()); | |
357 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); | |
358 | // ======================================================= | |
359 | #ifdef DEB | |
360 | gp_Dir2d dir1(Center.XY()-center1.XY()); | |
361 | #else | |
362 | Center.XY() ; | |
363 | center1.XY() ; | |
364 | #endif | |
365 | Standard_Real distcc1 = Center.Distance(center1); | |
366 | if (!Qualified1.IsUnqualified()) { | |
367 | qualifier1(NbrSol) = Qualified1.Qualifier(); | |
368 | } | |
369 | else if (Abs(distcc1+Radius-R1) < Tol) { | |
370 | qualifier1(NbrSol) = GccEnt_enclosed; | |
371 | } | |
372 | else if (Abs(distcc1-R1-Radius) < Tol) { | |
373 | qualifier1(NbrSol) = GccEnt_outside; | |
374 | } | |
375 | else { qualifier1(NbrSol) = GccEnt_enclosing; } | |
376 | qualifier2(NbrSol) = Qualified2.Qualifier(); | |
377 | TheSame1(NbrSol) = 0; | |
378 | TheSame2(NbrSol) = 0; | |
379 | pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); | |
380 | pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); | |
381 | pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1); | |
382 | pnttg2sol(NbrSol) = TheTool::Value(Cu2,pararg2(NbrSol)); | |
383 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
384 | pnttg1sol(NbrSol)); | |
385 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
386 | pnttg2sol(NbrSol)); | |
387 | } | |
388 | } | |
389 | WellDone = Standard_True; | |
390 | } | |
391 | } | |
392 | } | |
393 | } | |
394 | } | |
395 | ||
396 | // circulaire tant a une courbe et un point ,de rayon donne | |
397 | //============================================================ | |
398 | ||
399 | //======================================================================== | |
400 | // On initialise WellDone a false. + | |
401 | // On recupere la courbe Cu1 et le point P2. + | |
402 | // On sort en erreur dans les cas ou la construction est impossible. + | |
403 | // On fait la parallele a Cu1 dans le bon sens. + | |
404 | // On fait la parallele a P2 dans le bon sens. + | |
405 | // On intersecte les paralleles ==> point de centre de la solution. + | |
406 | // On cree la solution qu on ajoute aux solutions deja trouvees. + | |
407 | // On remplit les champs. + | |
408 | //======================================================================== | |
409 | ||
410 | GccGeo_Circ2d2TanRad:: | |
411 | GccGeo_Circ2d2TanRad (const TheQCurve& Qualified1, | |
412 | const gp_Pnt2d& Point2 , | |
413 | const Standard_Real Radius , | |
414 | const Standard_Real Tolerance ): | |
415 | ||
416 | //======================================================================== | |
417 | // initialisation des champs. + | |
418 | //======================================================================== | |
419 | ||
420 | cirsol(1,16) , | |
421 | qualifier1(1,16), | |
422 | qualifier2(1,16), | |
423 | TheSame1(1,16) , | |
424 | TheSame2(1,16) , | |
425 | pnttg1sol(1,16), | |
426 | pnttg2sol(1,16), | |
427 | par1sol(1,16) , | |
428 | par2sol(1,16) , | |
429 | pararg1(1,16) , | |
430 | pararg2(1,16) | |
431 | { | |
432 | ||
433 | //======================================================================== | |
434 | // Traitement. + | |
435 | //======================================================================== | |
436 | ||
437 | Standard_Real Tol = Abs(Tolerance); | |
438 | Standard_Real thefirst = -100000.; | |
439 | Standard_Real thelast = 100000.; | |
440 | Standard_Real firstparam; | |
441 | Standard_Real lastparam; | |
442 | gp_Dir2d dirx(1.,0.); | |
443 | TColStd_Array1OfReal cote1(1,2); | |
444 | Standard_Integer nbrcote1=0; | |
445 | WellDone = Standard_False; | |
446 | NbrSol = 0; | |
447 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || | |
448 | Qualified1.IsOutside() || Qualified1.IsUnqualified())) { | |
449 | GccEnt_BadQualifier::Raise(); | |
450 | return; | |
451 | } | |
452 | TheCurve Cu1 = Qualified1.Qualified(); | |
453 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } | |
454 | else { | |
455 | if (Qualified1.IsEnclosed()) { | |
456 | // =========================== | |
457 | nbrcote1 = 1; | |
458 | cote1(1) = Radius; | |
459 | } | |
460 | else if(Qualified1.IsOutside()) { | |
461 | // =============================== | |
462 | nbrcote1 = 1; | |
463 | cote1(1) = -Radius; | |
464 | } | |
465 | else if(Qualified1.IsUnqualified()) { | |
466 | // =================================== | |
467 | nbrcote1 = 2; | |
468 | cote1(1) = Radius; | |
469 | cote1(2) = -Radius; | |
470 | } | |
471 | gp_Circ2d Circ(gp_Ax2d(Point2,gp_Dir2d(1.,0.)),Radius); | |
472 | IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol, | |
c6541a0c D |
473 | ElCLib::Value(M_PI+M_PI,Circ),M_PI+M_PI,Tol); |
474 | D1.SetEquivalentParameters(0.,M_PI+M_PI); | |
7fd59977 | 475 | TheIntConicCurve Intp; |
476 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { | |
477 | Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); | |
478 | TheParGenCurve Cu2(HCu1,cote1(jcote1)); | |
479 | firstparam = Max(TheCurvePGTool::FirstParameter(Cu2),thefirst); | |
480 | lastparam = Min(TheCurvePGTool::LastParameter(Cu2),thelast); | |
481 | IntRes2d_Domain D2(TheCurvePGTool::Value(Cu2,firstparam),firstparam,Tol, | |
482 | TheCurvePGTool::Value(Cu2,lastparam),lastparam,Tol); | |
483 | Intp.Perform(Circ,D1,Cu2,D2,Tol,Tol); | |
484 | if (Intp.IsDone()) { | |
485 | if (!Intp.IsEmpty()) { | |
486 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { | |
487 | NbrSol++; | |
488 | gp_Pnt2d Center(Intp.Point(i).Value()); | |
489 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); | |
490 | // ======================================================= | |
491 | qualifier1(NbrSol) = Qualified1.Qualifier(); | |
492 | qualifier2(NbrSol) = GccEnt_noqualifier; | |
493 | TheSame1(NbrSol) = 0; | |
494 | TheSame2(NbrSol) = 0; | |
495 | pararg1(NbrSol) = Intp.Point(i).ParamOnSecond(); | |
496 | pararg2(NbrSol) = 0.; | |
497 | pnttg1sol(NbrSol) = TheTool::Value(Cu1,pararg1(NbrSol)); | |
498 | pnttg2sol(NbrSol) = Point2; | |
499 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
500 | pnttg1sol(NbrSol)); | |
501 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
502 | pnttg2sol(NbrSol)); | |
503 | } | |
504 | } | |
505 | WellDone = Standard_True; | |
506 | } | |
507 | } | |
508 | } | |
509 | } | |
510 | ||
511 | // circulaire tant a deux courbes ,de rayon donne | |
512 | //================================================== | |
513 | ||
514 | //======================================================================== | |
515 | // On initialise WellDone a false. + | |
516 | // On recupere les courbes Cu1 et Cu2. + | |
517 | // On sort en erreur dans les cas ou la construction est impossible. + | |
518 | // On fait la parallele a Cu1 dans le bon sens. + | |
519 | // On fait la parallele a Cu2 dans le bon sens. + | |
520 | // On intersecte les paralleles ==> point de centre de la solution. + | |
521 | // On cree la solution qu on ajoute aux solutions deja trouvees. + | |
522 | // On remplit les champs. + | |
523 | //======================================================================== | |
524 | ||
525 | GccGeo_Circ2d2TanRad:: | |
526 | GccGeo_Circ2d2TanRad (const TheQCurve& Qualified1, | |
527 | const TheQCurve& Qualified2, | |
528 | const Standard_Real Radius , | |
529 | const Standard_Real Tolerance ): | |
530 | ||
531 | //======================================================================== | |
532 | // initialisation des champs. + | |
533 | //======================================================================== | |
534 | ||
535 | cirsol(1,16) , | |
536 | qualifier1(1,16), | |
537 | qualifier2(1,16), | |
538 | TheSame1(1,16) , | |
539 | TheSame2(1,16) , | |
540 | pnttg1sol(1,16), | |
541 | pnttg2sol(1,16), | |
542 | par1sol(1,16) , | |
543 | par2sol(1,16) , | |
544 | pararg1(1,16) , | |
545 | pararg2(1,16) | |
546 | { | |
547 | ||
548 | //======================================================================== | |
549 | // Traitement. + | |
550 | //======================================================================== | |
551 | ||
552 | Standard_Real Tol = Abs(Tolerance); | |
553 | Standard_Real thefirst = -100000.; | |
554 | Standard_Real thelast = 100000.; | |
555 | Standard_Real firstparam; | |
556 | Standard_Real lastparam; | |
557 | gp_Dir2d dirx(1.,0.); | |
558 | TColStd_Array1OfReal cote1(1,2); | |
559 | TColStd_Array1OfReal cote2(1,2); | |
560 | Standard_Integer nbrcote1=0; | |
561 | Standard_Integer nbrcote2=0; | |
562 | WellDone = Standard_False; | |
563 | NbrSol = 0; | |
564 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || | |
565 | Qualified1.IsOutside() || Qualified1.IsUnqualified()) || | |
566 | !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() || | |
567 | Qualified2.IsOutside() || Qualified2.IsUnqualified())) { | |
568 | GccEnt_BadQualifier::Raise(); | |
569 | return; | |
570 | } | |
571 | TheCurve Cu1 = Qualified1.Qualified(); | |
572 | TheCurve Cu2 = Qualified2.Qualified(); | |
573 | if (Radius < 0.0) { Standard_NegativeValue::Raise(); } | |
574 | else { | |
575 | if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) { | |
576 | // ======================================================= | |
577 | nbrcote1 = 1; | |
578 | nbrcote2 = 1; | |
579 | cote1(1) = Radius; | |
580 | cote2(1) = Radius; | |
581 | } | |
582 | else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) { | |
583 | // ========================================================== | |
584 | nbrcote1 = 1; | |
585 | nbrcote2 = 1; | |
586 | cote1(1) = Radius; | |
587 | cote2(1) = -Radius; | |
588 | } | |
589 | else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) { | |
590 | // =========================================================== | |
591 | nbrcote1 = 1; | |
592 | nbrcote2 = 1; | |
593 | cote1(1) = -Radius; | |
594 | cote2(1) = Radius; | |
595 | } | |
596 | else if(Qualified1.IsOutside() && Qualified2.IsOutside()) { | |
597 | // ========================================================= | |
598 | nbrcote1 = 1; | |
599 | nbrcote2 = 1; | |
600 | cote1(1) = -Radius; | |
601 | cote2(1) = -Radius; | |
602 | } | |
603 | if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) { | |
604 | // ========================================================= | |
605 | nbrcote1 = 1; | |
606 | nbrcote2 = 2; | |
607 | cote1(1) = Radius; | |
608 | cote2(1) = Radius; | |
609 | cote2(2) = -Radius; | |
610 | } | |
611 | if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) { | |
612 | // ========================================================= | |
613 | nbrcote1 = 2; | |
614 | nbrcote2 = 1; | |
615 | cote1(1) = Radius; | |
616 | cote1(2) = -Radius; | |
617 | cote2(1) = Radius; | |
618 | } | |
619 | else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) { | |
620 | // ============================================================= | |
621 | nbrcote1 = 1; | |
622 | nbrcote2 = 2; | |
623 | cote1(1) = -Radius; | |
624 | cote2(1) = Radius; | |
625 | cote2(2) = -Radius; | |
626 | } | |
627 | if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) { | |
628 | // ======================================================== | |
629 | nbrcote1 = 2; | |
630 | nbrcote2 = 1; | |
631 | cote1(1) = Radius; | |
632 | cote1(2) = -Radius; | |
633 | cote2(1) = -Radius; | |
634 | } | |
635 | else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) { | |
636 | // ================================================================= | |
637 | nbrcote1 = 2; | |
638 | nbrcote2 = 2; | |
639 | cote1(1) = Radius; | |
640 | cote1(2) = -Radius; | |
641 | cote2(1) = Radius; | |
642 | cote2(2) = -Radius; | |
643 | } | |
644 | TheIntCurveCurve Intp; | |
645 | for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) { | |
646 | Handle(TheHParGenCurve) HCu1 = new TheHParGenCurve(Cu1); | |
647 | TheParGenCurve C1(HCu1,cote1(jcote1)); | |
648 | firstparam = Max(TheCurvePGTool::FirstParameter(C1),thefirst); | |
649 | lastparam = Min(TheCurvePGTool::LastParameter(C1),thelast); | |
650 | #ifdef DEB | |
651 | IntRes2d_Domain D2(TheCurvePGTool::Value(C1,firstparam),firstparam,Tol, | |
652 | TheCurvePGTool::Value(C1,lastparam),lastparam,Tol); | |
653 | #else | |
654 | TheCurvePGTool::Value(C1,firstparam); | |
655 | TheCurvePGTool::Value(C1,lastparam); | |
656 | #endif | |
657 | for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) { | |
658 | Handle(TheHParGenCurve) HCu2 = new TheHParGenCurve(Cu2); | |
659 | TheParGenCurve C2(HCu2,cote2(jcote2)); | |
660 | firstparam = Max(TheCurvePGTool::FirstParameter(C2),thefirst); | |
661 | lastparam = Min(TheCurvePGTool::LastParameter(C2),thelast); | |
662 | #ifdef DEB | |
663 | IntRes2d_Domain D2(TheCurvePGTool::Value(C2,firstparam),firstparam,Tol, | |
664 | TheCurvePGTool::Value(C2,lastparam),lastparam,Tol); | |
665 | #else | |
666 | TheCurvePGTool::Value(C2,firstparam); | |
667 | TheCurvePGTool::Value(C2,lastparam); | |
668 | #endif | |
669 | Intp.Perform(C1,C2,Tol,Tol); | |
670 | if (Intp.IsDone()) { | |
671 | if (!Intp.IsEmpty()) { | |
672 | for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) { | |
673 | NbrSol++; | |
674 | gp_Pnt2d Center(Intp.Point(i).Value()); | |
675 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius); | |
676 | // ======================================================= | |
677 | qualifier1(NbrSol) = Qualified1.Qualifier(); | |
678 | qualifier1(NbrSol) = Qualified1.Qualifier(); | |
679 | TheSame1(NbrSol) = 0; | |
680 | TheSame2(NbrSol) = 0; | |
681 | pararg1(NbrSol) = Intp.Point(i).ParamOnFirst(); | |
682 | pararg2(NbrSol) = Intp.Point(i).ParamOnSecond(); | |
683 | pnttg1sol(NbrSol) = TheTool::Value(Cu1,pararg1(NbrSol)); | |
684 | pnttg2sol(NbrSol) = TheTool::Value(Cu2,pararg2(NbrSol)); | |
685 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
686 | pnttg1sol(NbrSol)); | |
687 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
688 | pnttg2sol(NbrSol)); | |
689 | } | |
690 | } | |
691 | WellDone = Standard_True; | |
692 | } | |
693 | } | |
694 | } | |
695 | } | |
696 | } | |
697 | ||
698 | //========================================================================= | |
699 | ||
700 | Standard_Boolean GccGeo_Circ2d2TanRad:: | |
701 | IsDone () const { return WellDone; } | |
702 | ||
703 | Standard_Integer GccGeo_Circ2d2TanRad:: | |
704 | NbSolutions () const { return NbrSol; } | |
705 | ||
706 | gp_Circ2d GccGeo_Circ2d2TanRad:: | |
707 | ThisSolution (const Standard_Integer Index) const | |
708 | { | |
709 | if (!WellDone) { StdFail_NotDone::Raise(); } | |
710 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } | |
711 | return cirsol(Index); | |
712 | } | |
713 | ||
714 | void GccGeo_Circ2d2TanRad:: | |
715 | WhichQualifier(const Standard_Integer Index , | |
716 | GccEnt_Position& Qualif1 , | |
717 | GccEnt_Position& Qualif2 ) const | |
718 | { | |
719 | if (!WellDone) { StdFail_NotDone::Raise(); } | |
720 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } | |
721 | else { | |
722 | Qualif1 = qualifier1(Index); | |
723 | Qualif2 = qualifier2(Index); | |
724 | } | |
725 | } | |
726 | ||
727 | void GccGeo_Circ2d2TanRad:: | |
728 | Tangency1 (const Standard_Integer Index, | |
729 | Standard_Real& ParSol, | |
730 | Standard_Real& ParArg, | |
731 | gp_Pnt2d& PntSol) const{ | |
732 | if (!WellDone) { StdFail_NotDone::Raise(); } | |
733 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } | |
734 | else { | |
735 | if (TheSame1(Index) == 0) { | |
736 | ParSol = par1sol(Index); | |
737 | ParArg = pararg1(Index); | |
738 | PntSol = gp_Pnt2d(pnttg1sol(Index)); | |
739 | } | |
740 | else { StdFail_NotDone::Raise(); } | |
741 | } | |
742 | } | |
743 | ||
744 | void GccGeo_Circ2d2TanRad:: | |
745 | Tangency2 (const Standard_Integer Index, | |
746 | Standard_Real& ParSol, | |
747 | Standard_Real& ParArg, | |
748 | gp_Pnt2d& PntSol) const{ | |
749 | if (!WellDone) { StdFail_NotDone::Raise(); } | |
750 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } | |
751 | else { | |
752 | if (TheSame2(Index) == 0) { | |
753 | ParSol = par2sol(Index); | |
754 | ParArg = pararg2(Index); | |
755 | PntSol = gp_Pnt2d(pnttg2sol(Index)); | |
756 | } | |
757 | else { StdFail_NotDone::Raise(); } | |
758 | } | |
759 | } | |
760 | ||
761 | Standard_Boolean GccGeo_Circ2d2TanRad:: | |
762 | IsTheSame1 (const Standard_Integer Index) const | |
763 | { | |
764 | if (!WellDone) { StdFail_NotDone::Raise(); } | |
765 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } | |
766 | ||
767 | if (TheSame1(Index) == 0) { return Standard_False; } | |
768 | return Standard_True; | |
769 | } | |
770 | ||
771 | Standard_Boolean GccGeo_Circ2d2TanRad:: | |
772 | IsTheSame2 (const Standard_Integer Index) const | |
773 | { | |
774 | if (!WellDone) { StdFail_NotDone::Raise(); } | |
775 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } | |
776 | ||
777 | if (TheSame2(Index) == 0) { return Standard_False; } | |
778 | return Standard_True; | |
779 | } | |
780 |