1 // Created on: 1991-12-13
2 // Created by: Remi GILET
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 //=========================================================================
18 // Creation d un cercle tangent a deux elements : Droite. +
22 // centre sur un troisieme : Droite. +
25 //=========================================================================
27 #include <Geom2dGcc_Circ2d2TanOnIter.ixx>
29 #include <gp_Dir2d.hxx>
30 #include <gp_Ax2d.hxx>
32 #include <StdFail_NotDone.hxx>
33 #include <GccEnt_BadQualifier.hxx>
34 #include <math_FunctionSetRoot.hxx>
37 #include <Geom2dGcc_CurveTool.hxx>
38 #include <Geom2dGcc_FunctionTanCuCuOnCu.hxx>
40 Geom2dGcc_Circ2d2TanOnIter::
41 Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 ,
42 const Geom2dGcc_QCurve& Qualified2 ,
43 const gp_Lin2d& OnLine ,
44 const Standard_Real Param1 ,
45 const Standard_Real Param2 ,
46 const Standard_Real Param3 ,
47 const Standard_Real Tolang ) {
49 TheSame1 = Standard_False;
50 TheSame2 = Standard_False;
57 WellDone = Standard_False;
58 Standard_Real Tol = Abs(Tolang);
59 WellDone = Standard_False;
60 if (!(Qualified1.IsEnclosed() ||
61 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
62 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
63 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
64 GccEnt_BadQualifier::Raise();
68 gp_Lin2d L1 = Qualified1.Qualified();
69 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
70 math_Vector Umin(1,4);
71 math_Vector Umax(1,4);
72 math_Vector Ufirst(1,4);
74 Umin(1) = RealFirst();
75 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
76 Umin(3) = RealFirst();
79 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
86 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Tolang);
89 gp_Pnt2d point1 = ElCLib::Value(Param1,L1);
90 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
91 gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
92 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
93 Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Ufirst(4));
94 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
95 Func.Value(Ufirst,Umin);
98 // gp_Vec2d Tan1,Tan2,Nor1,Nor2;
100 ElCLib::D1(Ufirst(1),L1,point1,Tan1);
101 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
102 gp_Vec2d Tan3(OnLine.Direction().XY());
103 gp_Pnt2d point3(OnLine.Location().XY()+Ufirst(3)*Tan3.XY());
104 Standard_Real dist1 = point3.Distance(point1);
105 Standard_Real dist2 = point3.Distance(point2);
106 if ( Abs(dist1-dist2)/2. <= Tol) {
107 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
108 Standard_Real normetan2 = Tan2.Magnitude();
109 gp_Vec2d Vec1(point1,point3);
110 gp_Vec2d Vec2(point2,point3);
111 Standard_Real normevec2 = Vec2.Magnitude();
112 Standard_Real angle2;
113 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
114 angle2 = Vec2.Angle(Tan2);
116 else { angle2 = 0.; }
117 Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(),
118 L1.Direction().X()));
119 if (Qualified1.IsUnqualified() ||
120 (Qualified1.IsOutside() && pscal <= 0.) ||
121 (Qualified1.IsEnclosed() && pscal >= 0.)) {
122 if (Qualified2.IsUnqualified() ||
123 (Qualified2.IsEnclosing()&&angle2<=0.)||
124 (Qualified2.IsOutside() && angle2 >= 0) ||
125 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
126 qualifier1 = Qualified1.Qualifier();
127 qualifier2 = Qualified2.Qualifier();
130 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
133 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
136 WellDone = Standard_True;
143 Geom2dGcc_Circ2d2TanOnIter::
144 Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
145 const Geom2dGcc_QCurve& Qualified2 ,
146 const gp_Lin2d& OnLine ,
147 const Standard_Real Param1 ,
148 const Standard_Real Param2 ,
149 const Standard_Real Param3 ,
150 const Standard_Real Tolerance ) {
151 TheSame1 = Standard_False;
152 TheSame2 = Standard_False;
159 WellDone = Standard_False;
160 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
161 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
162 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
163 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
164 GccEnt_BadQualifier::Raise();
167 Standard_Real Tol = Abs(Tolerance);
168 gp_Dir2d dirx(1.,0.);
169 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
170 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
171 math_Vector Umin(1,4);
172 math_Vector Umax(1,4);
173 math_Vector Ufirst(1,4);
174 math_Vector tol(1,4);
175 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
176 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
177 Umin(3) = RealFirst();
179 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
180 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
181 Umax(3) = RealLast();
182 Umax(4) = RealLast();
186 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
187 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
190 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
191 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
192 gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
193 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
194 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Ufirst(4));
195 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
196 Func.Value(Ufirst,Umin);
200 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
201 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
202 gp_Vec2d Tan3(OnLine.Direction().XY());
203 gp_Pnt2d point3(OnLine.Location().XY()+Ufirst(3)*Tan3.XY());
204 Standard_Real dist1 = point3.Distance(point1);
205 Standard_Real dist2 = point3.Distance(point2);
206 if ( Abs(dist1-dist2)/2. <= Tol) {
207 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
208 Standard_Real normetan1 = Tan1.Magnitude();
209 Standard_Real normetan2 = Tan2.Magnitude();
210 gp_Vec2d Vec1(point1,point3);
211 gp_Vec2d Vec2(point2,point3);
212 Standard_Real normevec1 = Vec1.Magnitude();
213 Standard_Real normevec2 = Vec2.Magnitude();
214 Standard_Real angle1,angle2;
215 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
216 angle1 = Vec1.Angle(Tan1);
218 else { angle1 = 0.; }
219 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
220 angle2 = Vec2.Angle(Tan2);
222 else { angle2 = 0.; }
223 if (Qualified1.IsUnqualified()||
224 (Qualified1.IsEnclosing()&&angle1<=0.)||
225 (Qualified1.IsOutside() && angle1 >= 0.) ||
226 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
227 if (Qualified2.IsUnqualified() ||
228 (Qualified2.IsEnclosing()&&angle2<=0.)||
229 (Qualified2.IsOutside() && angle2 >= 0) ||
230 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
231 qualifier1 = Qualified1.Qualifier();
232 qualifier2 = Qualified2.Qualifier();
235 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
238 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
241 WellDone = Standard_True;
248 Geom2dGcc_Circ2d2TanOnIter::
249 Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
250 const gp_Pnt2d& Point2 ,
251 const gp_Lin2d& OnLine ,
252 const Standard_Real Param1 ,
253 const Standard_Real Param2 ,
254 const Standard_Real Tolerance ) {
255 TheSame1 = Standard_False;
256 TheSame2 = Standard_False;
263 WellDone = Standard_False;
264 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
265 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
266 GccEnt_BadQualifier::Raise();
269 Standard_Real Tol = Abs(Tolerance);
270 gp_Dir2d dirx(1.,0.);
271 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
272 math_Vector Umin(1,3);
273 math_Vector Umax(1,3);
274 math_Vector Ufirst(1,3);
275 math_Vector tol(1,3);
276 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
277 Umin(2) = RealFirst();
279 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
280 Umax(2) = RealLast();
281 Umax(3) = RealLast();
284 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
287 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
288 gp_Pnt2d point3 = ElCLib::Value(Param2,OnLine);
289 Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
290 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Ufirst(3));
291 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
292 Func.Value(Ufirst,Umin);
295 gp_Pnt2d point1,point3;
297 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
298 ElCLib::D1(Ufirst(2),OnLine,point3,Tan3);
299 Standard_Real dist1 = point3.Distance(point1);
300 Standard_Real dist2 = point3.Distance(Point2);
301 if ( Abs(dist1-dist2)/2. <= Tol) {
302 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
303 Standard_Real normetan1 = Tan1.Magnitude();
304 gp_Vec2d Vec1(point1,point3);
305 Standard_Real normevec1 = Vec1.Magnitude();
306 Standard_Real angle1;
307 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
308 angle1 = Vec1.Angle(Tan1);
310 else { angle1 = 0.; }
311 if (Qualified1.IsUnqualified()||
312 (Qualified1.IsEnclosing()&&angle1<=0.)||
313 (Qualified1.IsOutside() && angle1 >= 0.) ||
314 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
315 qualifier1 = Qualified1.Qualifier();
316 qualifier2 = GccEnt_noqualifier;
319 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
322 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
325 WellDone = Standard_True;
331 Geom2dGcc_Circ2d2TanOnIter::
332 Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
333 const Geom2dGcc_QCurve& Qualified2 ,
334 const gp_Lin2d& OnLine ,
335 const Standard_Real Param1 ,
336 const Standard_Real Param2 ,
337 const Standard_Real Param3 ,
338 const Standard_Real Tolerance ) {
339 TheSame1 = Standard_False;
340 TheSame2 = Standard_False;
347 WellDone = Standard_False;
348 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
349 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
350 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
351 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
352 GccEnt_BadQualifier::Raise();
355 Standard_Real Tol = Abs(Tolerance);
356 gp_Dir2d dirx(1.,0.);
357 gp_Circ2d C1 = Qualified1.Qualified();
358 Standard_Real R1 = C1.Radius();
359 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
360 math_Vector Umin(1,4);
361 math_Vector Umax(1,4);
362 math_Vector Ufirst(1,4);
363 math_Vector tol(1,4);
364 Umin(1) = RealFirst();
365 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
366 Umin(3) = RealFirst();
368 Umax(1) = RealLast();
369 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
370 Umax(3) = RealLast();
371 Umax(4) = RealLast();
375 tol(1) = 2.e-15*M_PI;
376 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
379 gp_Pnt2d point1 = ElCLib::Value(Param1,C1);
380 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
381 gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
382 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
383 Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Ufirst(4));
384 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
385 Func.Value(Ufirst,Umin);
388 // gp_Vec2d Tan1,Tan2,Nor1,Nor2;
389 gp_Vec2d Tan1,Tan2,Nor2;
390 ElCLib::D2(Ufirst(1),C1,point1,Tan1,Nor2);
391 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
393 gp_Vec2d Tan3(OnLine.Direction().XY());
395 OnLine.Direction().XY();
397 point3 = ElCLib::Value(Ufirst(1),OnLine);
398 Standard_Real dist1 = point3.Distance(point1);
399 Standard_Real dist2 = point3.Distance(point2);
400 if ( Abs(dist1-dist2)/2. <= Tol) {
401 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
402 Standard_Real normetan2 = Tan2.Magnitude();
403 gp_Vec2d Vec1(point1,point3);
404 gp_Vec2d Vec2(point2,point3);
405 Standard_Real normevec2 = Vec2.Magnitude();
406 Standard_Real angle2;
407 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
408 angle2 = Vec2.Angle(Tan2);
410 else { angle2 = 0.; }
411 Standard_Real dist = C1.Location().Distance(point3);
412 Standard_Real Rsol = cirsol.Radius();
413 if (Qualified1.IsUnqualified() ||
414 (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)||
415 (Qualified1.IsOutside() && dist >= Rsol) ||
416 (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) {
417 if (Qualified2.IsUnqualified() ||
418 (Qualified2.IsEnclosing()&&angle2<=0.)||
419 (Qualified2.IsOutside() && angle2 >= 0) ||
420 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
421 qualifier1 = Qualified1.Qualifier();
422 qualifier2 = Qualified2.Qualifier();
425 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
428 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
431 WellDone = Standard_True;
438 Geom2dGcc_Circ2d2TanOnIter::
439 Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
440 const Geom2dGcc_QCurve& Qualified2 ,
441 const gp_Circ2d& OnCirc ,
442 const Standard_Real Param1 ,
443 const Standard_Real Param2 ,
444 const Standard_Real Param3 ,
445 const Standard_Real Tolerance ) {
446 TheSame1 = Standard_False;
447 TheSame2 = Standard_False;
454 WellDone = Standard_False;
455 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
456 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
457 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
458 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
459 GccEnt_BadQualifier::Raise();
462 Standard_Real Tol = Abs(Tolerance);
463 gp_Dir2d dirx(1.,0.);
464 gp_Circ2d C1 = Qualified1.Qualified();
465 Standard_Real R1 = C1.Radius();
466 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
467 math_Vector Umin(1,4);
468 math_Vector Umax(1,4);
469 math_Vector Ufirst(1,4);
470 math_Vector tol(1,4);
471 Umin(1) = RealFirst();
472 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
473 Umin(3) = RealFirst();
475 Umax(1) = RealLast();
476 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
477 Umax(3) = RealLast();
478 Umax(4) = RealLast();
482 tol(1) = 2.e-15*M_PI;
483 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
484 tol(3) = 2.e-15*M_PI;
486 gp_Pnt2d point1 = ElCLib::Value(Param1,C1);
487 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
488 gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc);
489 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
490 Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Ufirst(4));
491 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
492 Func.Value(Ufirst,Umin);
495 // gp_Vec2d Tan1,Tan2,Nor1;
497 ElCLib::D1(Ufirst(1),C1,point1,Tan1);
498 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
500 gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3)));
502 point3 = ElCLib::Value(Ufirst(3),OnCirc);
503 Standard_Real dist1 = point3.Distance(point1);
504 Standard_Real dist2 = point3.Distance(point2);
505 if ( Abs(dist1-dist2)/2. <= Tol) {
506 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
507 Standard_Real normetan2 = Tan2.Magnitude();
508 gp_Vec2d Vec1(point1,point3);
509 gp_Vec2d Vec2(point2,point3);
510 Standard_Real normevec2 = Vec2.Magnitude();
511 Standard_Real angle2;
512 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
513 angle2 = Vec2.Angle(Tan2);
515 else { angle2 = 0.; }
516 Standard_Real dist = C1.Location().Distance(point3);
517 Standard_Real Rsol = cirsol.Radius();
518 if (Qualified1.IsUnqualified() ||
519 (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)||
520 (Qualified1.IsOutside() && dist >= Rsol) ||
521 (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) {
522 if (Qualified2.IsUnqualified() ||
523 (Qualified2.IsEnclosing()&&angle2<=0.)||
524 (Qualified2.IsOutside() && angle2 >= 0) ||
525 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
526 qualifier1 = Qualified1.Qualifier();
527 qualifier2 = Qualified2.Qualifier();
530 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
533 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
536 WellDone = Standard_True;
543 Geom2dGcc_Circ2d2TanOnIter::
544 Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 ,
545 const Geom2dGcc_QCurve& Qualified2 ,
546 const gp_Circ2d& OnCirc ,
547 const Standard_Real Param1 ,
548 const Standard_Real Param2 ,
549 const Standard_Real Param3 ,
550 const Standard_Real Tolerance ) {
551 TheSame1 = Standard_False;
552 TheSame2 = Standard_False;
559 WellDone = Standard_False;
560 if (!(Qualified1.IsEnclosed() ||
561 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
562 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
563 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
564 GccEnt_BadQualifier::Raise();
567 Standard_Real Tol = Abs(Tolerance);
568 gp_Dir2d dirx(1.,0.);
569 gp_Lin2d L1 = Qualified1.Qualified();
570 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
571 math_Vector Umin(1,4);
572 math_Vector Umax(1,4);
573 math_Vector Ufirst(1,4);
574 math_Vector tol(1,4);
575 Umin(1) = RealFirst();
576 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
577 Umin(3) = RealFirst();
579 Umax(1) = RealLast();
580 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
581 Umax(3) = RealLast();
582 Umax(4) = RealLast();
587 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
588 tol(3) = 2.e-15*M_PI;
590 gp_Pnt2d point1 = ElCLib::Value(Param1,L1);
591 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
592 gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc);
593 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
594 Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Ufirst(4));
595 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
596 Func.Value(Ufirst,Umin);
599 gp_Pnt2d point1,point2;
601 ElCLib::D1(Ufirst(1),L1,point1,Tan1);
602 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
604 gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3)));
606 point3 = ElCLib::Value(Ufirst(3),OnCirc);
607 Standard_Real dist1 = point3.Distance(point1);
608 Standard_Real dist2 = point3.Distance(point2);
609 if ( Abs(dist1-dist2)/2. <= Tol) {
610 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
611 Standard_Real normetan2 = Tan2.Magnitude();
612 gp_Vec2d Vec1(point1,point3);
613 gp_Vec2d Vec2(point2,point3);
614 Standard_Real normevec2 = Vec2.Magnitude();
615 Standard_Real angle2;
616 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
617 angle2 = Vec2.Angle(Tan2);
619 else { angle2 = 0.; }
620 Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(),
621 L1.Direction().X()));
622 if (Qualified1.IsUnqualified() ||
623 (Qualified1.IsOutside() && pscal <= 0.) ||
624 (Qualified1.IsEnclosed() && pscal >= 0.)) {
625 if (Qualified2.IsUnqualified() ||
626 (Qualified2.IsEnclosing()&&angle2<=0.)||
627 (Qualified2.IsOutside() && angle2 >= 0) ||
628 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
629 qualifier1 = Qualified1.Qualifier();
630 qualifier2 = Qualified2.Qualifier();
633 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
636 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
639 WellDone = Standard_True;
646 Geom2dGcc_Circ2d2TanOnIter::
647 Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
648 const Geom2dGcc_QCurve& Qualified2 ,
649 const gp_Circ2d& OnCirc ,
650 const Standard_Real Param1 ,
651 const Standard_Real Param2 ,
652 const Standard_Real Param3 ,
653 const Standard_Real Tolerance ) {
654 TheSame1 = Standard_False;
655 TheSame2 = Standard_False;
662 WellDone = Standard_False;
663 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
664 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
665 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
666 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
667 GccEnt_BadQualifier::Raise();
670 Standard_Real Tol = Abs(Tolerance);
671 gp_Dir2d dirx(1.,0.);
672 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
673 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
674 math_Vector Umin(1,4);
675 math_Vector Umax(1,4);
676 math_Vector Ufirst(1,4);
677 math_Vector tol(1,4);
678 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
679 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
680 Umin(3) = RealFirst();
682 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
683 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
684 Umax(3) = RealLast();
685 Umax(4) = RealLast();
689 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
690 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
691 tol(3) = 2.e-15*M_PI;
693 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
694 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
695 Standard_Real R1 = OnCirc.Radius();
696 gp_Pnt2d point3(OnCirc.Location().XY()+R1*gp_XY(Cos(Param3),Sin(Param3)));
697 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
698 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Ufirst(4));
699 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
700 Func.Value(Ufirst,Umin);
703 // gp_Vec2d Tan1,Tan2,Nor1;
705 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
706 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
708 gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3)));
710 point3 = gp_Pnt2d(OnCirc.Location().XY()+
711 R1*gp_XY(Cos(Ufirst(3)),Sin(Ufirst(3))));
712 Standard_Real dist1 = point3.Distance(point1);
713 Standard_Real dist2 = point3.Distance(point2);
714 if ( Abs(dist1-dist2)/2. <= Tol) {
715 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
716 Standard_Real normetan1 = Tan1.Magnitude();
717 Standard_Real normetan2 = Tan2.Magnitude();
718 gp_Vec2d Vec1(point1,point3);
719 gp_Vec2d Vec2(point2,point3);
720 Standard_Real normevec1 = Vec1.Magnitude();
721 Standard_Real normevec2 = Vec2.Magnitude();
722 Standard_Real angle1,angle2;
723 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
724 angle1 = Vec1.Angle(Tan1);
726 else { angle1 = 0.; }
727 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
728 angle2 = Vec2.Angle(Tan2);
730 else { angle2 = 0.; }
731 if (Qualified1.IsUnqualified()||
732 (Qualified1.IsEnclosing()&&angle1<=0.)||
733 (Qualified1.IsOutside() && angle1 >= 0.) ||
734 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
735 if (Qualified2.IsUnqualified() ||
736 (Qualified2.IsEnclosing()&&angle2<=0.)||
737 (Qualified2.IsOutside() && angle2 >= 0) ||
738 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
739 qualifier1 = Qualified1.Qualifier();
740 qualifier2 = Qualified2.Qualifier();
746 par2sol = pnttg2sol.Distance(pnttg1sol);
749 WellDone = Standard_True;
756 Geom2dGcc_Circ2d2TanOnIter::
757 Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
758 const gp_Pnt2d& Point2 ,
759 const gp_Circ2d& OnCirc ,
760 const Standard_Real Param1 ,
761 const Standard_Real Param2 ,
762 const Standard_Real Tolerance ) {
763 TheSame1 = Standard_False;
764 TheSame2 = Standard_False;
771 WellDone = Standard_False;
772 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
773 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
774 GccEnt_BadQualifier::Raise();
777 Standard_Real Tol = Abs(Tolerance);
778 gp_Dir2d dirx(1.,0.);
779 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
780 math_Vector Umin(1,3);
781 math_Vector Umax(1,3);
782 math_Vector Ufirst(1,3);
783 math_Vector tol(1,3);
784 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
785 Umin(2) = RealFirst();
787 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
788 Umax(2) = RealLast();
789 Umax(3) = RealLast();
792 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
793 tol(2) = 2.e-15*M_PI;
795 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
796 gp_Pnt2d point3 = ElCLib::Value(Param2,OnCirc);
797 Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
798 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Ufirst(3));
799 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
800 Func.Value(Ufirst,Umin);
803 gp_Pnt2d point1,point3;
805 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
806 ElCLib::D1(Ufirst(2),OnCirc,point3,Tan3);
807 Standard_Real dist1 = point3.Distance(point1);
808 Standard_Real dist2 = point3.Distance(Point2);
809 if ( Abs(dist1-dist2)/2. <= Tol) {
810 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
811 Standard_Real normetan1 = Tan1.Magnitude();
812 gp_Vec2d Vec1(point1,point3);
813 Standard_Real normevec1 = Vec1.Magnitude();
814 Standard_Real angle1;
815 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
816 angle1 = Vec1.Angle(Tan1);
818 else { angle1 = 0.; }
819 if (Qualified1.IsUnqualified()||
820 (Qualified1.IsEnclosing()&&angle1<=0.)||
821 (Qualified1.IsOutside() && angle1 >= 0.) ||
822 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
823 qualifier1 = Qualified1.Qualifier();
824 qualifier2 = GccEnt_noqualifier;
827 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
830 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
833 WellDone = Standard_True;
839 Geom2dGcc_Circ2d2TanOnIter::
840 Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
841 const Geom2dGcc_QCurve& Qualified2 ,
842 const Geom2dAdaptor_Curve& OnCurv ,
843 const Standard_Real Param1 ,
844 const Standard_Real Param2 ,
845 const Standard_Real Param3 ,
846 const Standard_Real Tolerance ) {
847 TheSame1 = Standard_False;
848 TheSame2 = Standard_False;
855 WellDone = Standard_False;
856 Standard_Real Tol = Abs(Tolerance);
857 WellDone = Standard_False;
858 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
859 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
860 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
861 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
862 GccEnt_BadQualifier::Raise();
865 gp_Dir2d dirx(1.,0.);
866 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
867 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
868 math_Vector Umin(1,4);
869 math_Vector Umax(1,4);
870 math_Vector Ufirst(1,4);
871 math_Vector tol(1,4);
872 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
873 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
874 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
876 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
877 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
878 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
879 Umax(4) = RealLast();
883 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
884 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
885 tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
887 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
888 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
889 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,Param3);
890 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
891 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Ufirst(4));
892 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
893 Func.Value(Ufirst,Umin);
896 gp_Vec2d Tan1,Tan2,Tan3;
897 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
898 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
899 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
900 Standard_Real dist1 = point3.Distance(point1);
901 Standard_Real dist2 = point3.Distance(point2);
902 if ( Abs(dist1-dist2)/2. <= Tol) {
903 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
904 Standard_Real normetan1 = Tan1.Magnitude();
905 Standard_Real normetan2 = Tan2.Magnitude();
906 gp_Vec2d Vec1(point1,point3);
907 gp_Vec2d Vec2(point2,point3);
908 Standard_Real normevec1 = Vec1.Magnitude();
909 Standard_Real normevec2 = Vec2.Magnitude();
910 Standard_Real angle1,angle2;
911 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
912 angle1 = Vec1.Angle(Tan1);
914 else { angle1 = 0.; }
915 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
916 angle2 = Vec2.Angle(Tan2);
918 else { angle2 = 0.; }
919 if (Qualified1.IsUnqualified()||
920 (Qualified1.IsEnclosing()&&angle1<=0.)||
921 (Qualified1.IsOutside() && angle1 >= 0.) ||
922 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
923 if (Qualified2.IsUnqualified() ||
924 (Qualified2.IsEnclosing()&&angle2<=0.)||
925 (Qualified2.IsOutside() && angle2 >= 0) ||
926 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
927 qualifier1 = Qualified1.Qualifier();
928 qualifier2 = Qualified2.Qualifier();
934 par2sol = pnttg2sol.Distance(pnttg1sol);
937 WellDone = Standard_True;
944 Geom2dGcc_Circ2d2TanOnIter::
945 Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
946 const Geom2dGcc_QCurve& Qualified2 ,
947 const Geom2dAdaptor_Curve& OnCurv ,
948 const Standard_Real Param1 ,
949 const Standard_Real Param2 ,
950 const Standard_Real ParamOn ,
951 const Standard_Real Tolerance ) {
953 TheSame1 = Standard_False;
954 TheSame2 = Standard_False;
961 WellDone = Standard_False;
962 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
963 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
964 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
965 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
966 GccEnt_BadQualifier::Raise();
969 Standard_Real Tol = Abs(Tolerance);
970 gp_Circ2d C1 = Qualified1.Qualified();
971 Standard_Real R1 = C1.Radius();
972 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
973 math_Vector Umin(1,4);
974 math_Vector Umax(1,4);
975 math_Vector Ufirst(1,4);
976 math_Vector tol(1,4);
977 Umin(1) = RealFirst();
978 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
979 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
981 Umax(1) = RealLast();
982 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
983 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
984 Umax(4) = RealLast();
988 tol(1) = 2.e-15*M_PI;
989 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
990 tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
992 gp_Pnt2d point1 = ElCLib::Value(Param1,C1);
993 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
994 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
995 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
996 Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Ufirst(4));
997 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
998 Func.Value(Ufirst,Umin);
1001 gp_Vec2d Tan1,Tan2,Tan3;
1002 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
1003 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
1004 ElCLib::D1(Ufirst(1),C1,point1,Tan1);
1005 Standard_Real dist1 = point3.Distance(point1);
1006 Standard_Real dist2 = point3.Distance(point2);
1007 if ( Abs(dist1-dist2)/2. <= Tol) {
1008 gp_Dir2d dirx(1.,0.);
1009 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
1010 Standard_Real normetan2 = Tan2.Magnitude();
1011 gp_Vec2d Vec1(point1.XY(),point3.XY());
1012 gp_Vec2d Vec2(point2.XY(),point3.XY());
1013 Standard_Real normevec2 = Vec2.Magnitude();
1014 Standard_Real angle2;
1015 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
1016 angle2 = Vec2.Angle(Tan2);
1018 else { angle2 = 0.; }
1019 Standard_Real dist = C1.Location().Distance(point3);
1020 Standard_Real Rsol = cirsol.Radius();
1021 if (Qualified1.IsUnqualified() ||
1022 (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)||
1023 (Qualified1.IsOutside() && dist >= Rsol) ||
1024 (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) {
1025 if (Qualified2.IsUnqualified() ||
1026 (Qualified2.IsEnclosing()&&angle2<=0.)||
1027 (Qualified2.IsOutside() && angle2 >= 0) ||
1028 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
1029 qualifier1 = Qualified1.Qualifier();
1030 qualifier2 = Qualified2.Qualifier();
1032 pararg1 = Ufirst(1);
1033 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
1035 pararg2 = Ufirst(2);
1036 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
1038 parcen3 = Ufirst(3);
1039 WellDone = Standard_True;
1046 Geom2dGcc_Circ2d2TanOnIter::
1047 Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 ,
1048 const Geom2dGcc_QCurve& Qualified2 ,
1049 const Geom2dAdaptor_Curve& OnCurv ,
1050 const Standard_Real Param1 ,
1051 const Standard_Real Param2 ,
1052 const Standard_Real ParamOn ,
1053 const Standard_Real Tolerance ) {
1054 TheSame1 = Standard_False;
1055 TheSame2 = Standard_False;
1062 WellDone = Standard_False;
1063 if (!(Qualified1.IsEnclosed() ||
1064 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
1065 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
1066 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
1067 GccEnt_BadQualifier::Raise();
1070 Standard_Real Tol = Abs(Tolerance);
1071 gp_Dir2d dirx(1.,0.);
1072 gp_Lin2d L1 = Qualified1.Qualified();
1073 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
1074 math_Vector Umin(1,4);
1075 math_Vector Umax(1,4);
1076 math_Vector Ufirst(1,4);
1077 math_Vector tol(1,4);
1078 Umin(1) = RealFirst();
1079 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
1080 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
1082 Umax(1) = RealLast();
1083 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
1084 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
1085 Umax(4) = RealLast();
1088 Ufirst(3) = ParamOn;
1090 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
1091 tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
1093 gp_Pnt2d point1 = ElCLib::Value(Param1,L1);
1094 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
1095 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
1096 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
1097 Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Ufirst(4));
1098 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
1099 Func.Value(Ufirst,Umin);
1100 if (Root.IsDone()) {
1102 gp_Vec2d Tan1,Tan2,Tan3;
1103 ElCLib::D1(Ufirst(1),L1,point1,Tan1);
1104 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
1105 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
1106 Standard_Real dist1 = point3.Distance(point1);
1107 Standard_Real dist2 = point3.Distance(point2);
1108 if ( Abs(dist1-dist2)/2. <= Tol) {
1109 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
1110 Standard_Real normetan2 = Tan2.Magnitude();
1111 gp_Vec2d Vec1(point1,point3);
1112 gp_Vec2d Vec2(point2,point3);
1113 Standard_Real normevec2 = Vec2.Magnitude();
1114 Standard_Real angle2;
1115 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
1116 angle2 = Vec2.Angle(Tan2);
1118 else { angle2 = 0.; }
1119 Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(),
1120 L1.Direction().X()));
1121 if (Qualified1.IsUnqualified() ||
1122 (Qualified1.IsOutside() && pscal <= 0.) ||
1123 (Qualified1.IsEnclosed() && pscal >= 0.)) {
1124 if (Qualified2.IsUnqualified() ||
1125 (Qualified2.IsEnclosing()&&angle2<=0.)||
1126 (Qualified2.IsOutside() && angle2 >= 0) ||
1127 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
1128 qualifier1 = Qualified1.Qualifier();
1129 qualifier2 = Qualified2.Qualifier();
1131 pararg1 = Ufirst(1);
1132 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
1134 pararg2 = Ufirst(2);
1135 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
1137 parcen3 = Ufirst(3);
1138 WellDone = Standard_True;
1145 Geom2dGcc_Circ2d2TanOnIter::
1146 Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
1147 const gp_Pnt2d& Point2 ,
1148 const Geom2dAdaptor_Curve& OnCurv ,
1149 const Standard_Real Param1 ,
1150 const Standard_Real ParamOn ,
1151 const Standard_Real Tolerance )
1153 TheSame1 = Standard_False;
1154 TheSame2 = Standard_False;
1161 WellDone = Standard_False;
1162 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
1163 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
1164 GccEnt_BadQualifier::Raise();
1167 Standard_Real Tol = Abs(Tolerance);
1168 gp_Dir2d dirx(1.,0.);
1169 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
1170 math_Vector Umin(1,3);
1171 math_Vector Umax(1,3);
1172 math_Vector Ufirst(1,3);
1173 math_Vector tol(1,3);
1174 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
1175 Umin(2) = RealFirst();
1176 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
1177 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
1178 Umax(2) = RealLast();
1179 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
1181 Ufirst(2) = ParamOn;
1182 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
1183 tol(2) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
1185 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
1186 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
1187 Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
1188 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Ufirst(3));
1189 math_FunctionSetRoot Root(Func,Ufirst,tol,Umin,Umax);
1190 Func.Value(Ufirst,Umin);
1191 if (Root.IsDone()) {
1193 // gp_Vec2d Tan1,Tan2,Tan3;
1195 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
1196 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
1197 Standard_Real dist1 = point3.Distance(point1);
1198 Standard_Real dist2 = point3.Distance(Point2);
1199 if ( Abs(dist1-dist2)/2. <= Tol) {
1200 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
1201 Standard_Real normetan1 = Tan1.Magnitude();
1202 gp_Vec2d Vec1(point1,point3);
1203 Standard_Real normevec1 = Vec1.Magnitude();
1204 Standard_Real angle1;
1205 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
1206 angle1 = Vec1.Angle(Tan1);
1208 else { angle1 = 0.; }
1209 if (Qualified1.IsUnqualified()||
1210 (Qualified1.IsEnclosing()&&angle1<=0.)||
1211 (Qualified1.IsOutside() && angle1 >= 0.) ||
1212 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
1213 qualifier1 = Qualified1.Qualifier();
1214 qualifier2 = GccEnt_noqualifier;
1216 pararg1 = Ufirst(1);
1217 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
1220 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
1222 parcen3 = Ufirst(3);
1223 WellDone = Standard_True;
1229 Standard_Boolean Geom2dGcc_Circ2d2TanOnIter::
1230 IsDone () const{ return WellDone; }
1232 gp_Circ2d Geom2dGcc_Circ2d2TanOnIter::
1233 ThisSolution () const{ return cirsol; }
1235 void Geom2dGcc_Circ2d2TanOnIter::
1236 WhichQualifier (GccEnt_Position& Qualif1 ,
1237 GccEnt_Position& Qualif2 ) const
1239 if (!WellDone) { StdFail_NotDone::Raise(); }
1241 Qualif1 = qualifier1;
1242 Qualif2 = qualifier2;
1246 void Geom2dGcc_Circ2d2TanOnIter::
1247 Tangency1 (Standard_Real& ParSol ,
1248 Standard_Real& ParArg ,
1249 gp_Pnt2d& PntSol ) const
1251 if (!WellDone) { StdFail_NotDone::Raise(); }
1253 if (TheSame1 == 0) {
1258 else { StdFail_NotDone::Raise(); }
1262 void Geom2dGcc_Circ2d2TanOnIter::
1263 Tangency2 (Standard_Real& ParSol ,
1264 Standard_Real& ParArg ,
1265 gp_Pnt2d& PntSol ) const
1267 if (!WellDone) { StdFail_NotDone::Raise(); }
1275 void Geom2dGcc_Circ2d2TanOnIter::
1276 CenterOn3 (Standard_Real& ParArg ,
1277 gp_Pnt2d& PntSol ) const
1279 if (!WellDone) { StdFail_NotDone::Raise(); }
1286 Standard_Boolean Geom2dGcc_Circ2d2TanOnIter::
1289 if (!WellDone) StdFail_NotDone::Raise();
1292 return Standard_False;
1293 return Standard_True;
1297 Standard_Boolean Geom2dGcc_Circ2d2TanOnIter::
1300 if (!WellDone) StdFail_NotDone::Raise();
1301 return Standard_False;