0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / Geom2dGcc / Geom2dGcc_Circ2d2TanOnIter.cxx
CommitLineData
54e37688 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17//=========================================================================
18// Creation d un cercle tangent a deux elements : Droite. +
19// Cercle. +
20// Point. +
21// Courbes. +
22// centre sur un troisieme : Droite. +
23// Cercle. +
24// Courbes. +
25//=========================================================================
26
54e37688 27#include <ElCLib.hxx>
42cf5bc1 28#include <GccEnt_BadQualifier.hxx>
29#include <GccEnt_QualifiedCirc.hxx>
30#include <GccEnt_QualifiedLin.hxx>
31#include <Geom2dAdaptor_Curve.hxx>
32#include <Geom2dGcc_Circ2d2TanOnIter.hxx>
54e37688 33#include <Geom2dGcc_CurveTool.hxx>
34#include <Geom2dGcc_FunctionTanCuCuOnCu.hxx>
42cf5bc1 35#include <Geom2dGcc_QCurve.hxx>
36#include <gp.hxx>
37#include <gp_Ax2d.hxx>
38#include <gp_Circ2d.hxx>
39#include <gp_Dir2d.hxx>
40#include <gp_Lin2d.hxx>
41#include <gp_Pnt2d.hxx>
42#include <math_FunctionSetRoot.hxx>
43#include <StdFail_NotDone.hxx>
54e37688 44
45Geom2dGcc_Circ2d2TanOnIter::
46Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 ,
47 const Geom2dGcc_QCurve& Qualified2 ,
48 const gp_Lin2d& OnLine ,
49 const Standard_Real Param1 ,
50 const Standard_Real Param2 ,
51 const Standard_Real Param3 ,
52 const Standard_Real Tolang ) {
53
54 TheSame1 = Standard_False;
55 TheSame2 = Standard_False;
56 par1sol = 0.;
57 par2sol = 0.;
58 pararg1 = 0.;
59 pararg2 = 0.;
60 parcen3 = 0.;
61
62 WellDone = Standard_False;
63 Standard_Real Tol = Abs(Tolang);
d533dafb 64 qualifier1 = GccEnt_noqualifier;
65 qualifier2 = GccEnt_noqualifier;
54e37688 66 if (!(Qualified1.IsEnclosed() ||
67 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
68 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
69 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 70 throw GccEnt_BadQualifier();
54e37688 71 return;
72 }
73 gp_Dir2d dirx(1.,0.);
74 gp_Lin2d L1 = Qualified1.Qualified();
75 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
76 math_Vector Umin(1,4);
77 math_Vector Umax(1,4);
78 math_Vector Ufirst(1,4);
79 math_Vector tol(1,4);
80 Umin(1) = RealFirst();
81 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
82 Umin(3) = RealFirst();
83 Umin(4) = 0.;
84 Umax(1) = RealLast();
85 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
86 Umax(3) = RealLast();
87 Umax(4) = RealLast();
88 Ufirst(1) = Param1;
89 Ufirst(2) = Param2;
90 Ufirst(3) = Param3;
91 tol(1) = 1.e-15;
92 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Tolang);
93 tol(3) = tol(1);
94 tol(4) = tol(1);
95 gp_Pnt2d point1 = ElCLib::Value(Param1,L1);
96 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
97 gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
98 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 99 Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Max(Ufirst(4), Tol));
859a47c3 100 math_FunctionSetRoot Root(Func, tol);
101 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 102 Func.Value(Ufirst,Umin);
103 if (Root.IsDone()) {
104 Root.Root(Ufirst);
105 // gp_Vec2d Tan1,Tan2,Nor1,Nor2;
106 gp_Vec2d Tan1,Tan2;
107 ElCLib::D1(Ufirst(1),L1,point1,Tan1);
108 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
109 gp_Vec2d Tan3(OnLine.Direction().XY());
51740958 110 gp_Pnt2d point3new(OnLine.Location().XY()+Ufirst(3)*Tan3.XY());
111 Standard_Real dist1 = point3new.Distance(point1);
112 Standard_Real dist2 = point3new.Distance(point2);
54e37688 113 if ( Abs(dist1-dist2)/2. <= Tol) {
51740958 114 cirsol = gp_Circ2d(gp_Ax2d(point3new,dirx),(dist1+dist2)/2.);
54e37688 115 Standard_Real normetan2 = Tan2.Magnitude();
51740958 116 gp_Vec2d Vec1(point1,point3new);
117 gp_Vec2d Vec2(point2,point3new);
54e37688 118 Standard_Real normevec2 = Vec2.Magnitude();
119 Standard_Real angle2;
120 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
121 angle2 = Vec2.Angle(Tan2);
122 }
123 else { angle2 = 0.; }
51740958 124 Standard_Real pscal=point3new.XY().Dot(gp_XY(-L1.Direction().Y(),
54e37688 125 L1.Direction().X()));
126 if (Qualified1.IsUnqualified() ||
127 (Qualified1.IsOutside() && pscal <= 0.) ||
128 (Qualified1.IsEnclosed() && pscal >= 0.)) {
129 if (Qualified2.IsUnqualified() ||
130 (Qualified2.IsEnclosing()&&angle2<=0.)||
131 (Qualified2.IsOutside() && angle2 >= 0) ||
132 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
133 qualifier1 = Qualified1.Qualifier();
134 qualifier2 = Qualified2.Qualifier();
135 pnttg1sol = point1;
136 pararg1 = Ufirst(1);
137 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
138 pnttg2sol = point2;
139 pararg2 = Ufirst(2);
140 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
51740958 141 pntcen = point3new;
54e37688 142 parcen3 = Ufirst(3);
143 WellDone = Standard_True;
144 }
145 }
146 }
147 }
148}
149
150Geom2dGcc_Circ2d2TanOnIter::
151Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
152 const Geom2dGcc_QCurve& Qualified2 ,
153 const gp_Lin2d& OnLine ,
154 const Standard_Real Param1 ,
155 const Standard_Real Param2 ,
156 const Standard_Real Param3 ,
157 const Standard_Real Tolerance ) {
158 TheSame1 = Standard_False;
159 TheSame2 = Standard_False;
160 par1sol = 0.;
161 par2sol = 0.;
162 pararg1 = 0.;
163 pararg2 = 0.;
164 parcen3 = 0.;
165
166 WellDone = Standard_False;
d533dafb 167 qualifier1 = GccEnt_noqualifier;
168 qualifier2 = GccEnt_noqualifier;
54e37688 169 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
170 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
171 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
172 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 173 throw GccEnt_BadQualifier();
54e37688 174 return;
175 }
176 Standard_Real Tol = Abs(Tolerance);
177 gp_Dir2d dirx(1.,0.);
178 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
179 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
180 math_Vector Umin(1,4);
181 math_Vector Umax(1,4);
182 math_Vector Ufirst(1,4);
183 math_Vector tol(1,4);
184 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
185 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
f4dee9bb 186 Umin(3) = RealFirst();
54e37688 187 Umin(4) = 0.;
188 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
189 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
190 Umax(3) = RealLast();
191 Umax(4) = RealLast();
192 Ufirst(1) = Param1;
193 Ufirst(2) = Param2;
194 Ufirst(3) = Param3;
195 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
196 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
197 tol(3) = 1.e-15;
198 tol(4) = Tol/10.;
199 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
200 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
201 gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
202 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 203 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Max(Ufirst(4), Tol));
859a47c3 204 math_FunctionSetRoot Root(Func, tol);
205 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 206 Func.Value(Ufirst,Umin);
207 if (Root.IsDone()) {
208 Root.Root(Ufirst);
209 gp_Vec2d Tan1,Tan2;
210 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
211 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
212 gp_Vec2d Tan3(OnLine.Direction().XY());
51740958 213 gp_Pnt2d point3new(OnLine.Location().XY()+Ufirst(3)*Tan3.XY());
214 Standard_Real dist1 = point3new.Distance(point1);
215 Standard_Real dist2 = point3new.Distance(point2);
f4dee9bb 216 if((dist1+dist2)/2. < Tol)
217 {
218 return;
219 }
54e37688 220 if ( Abs(dist1-dist2)/2. <= Tol) {
51740958 221 cirsol = gp_Circ2d(gp_Ax2d(point3new,dirx),(dist1+dist2)/2.);
54e37688 222 Standard_Real normetan1 = Tan1.Magnitude();
223 Standard_Real normetan2 = Tan2.Magnitude();
51740958 224 gp_Vec2d Vec1(point1,point3new);
225 gp_Vec2d Vec2(point2,point3new);
54e37688 226 Standard_Real normevec1 = Vec1.Magnitude();
227 Standard_Real normevec2 = Vec2.Magnitude();
228 Standard_Real angle1,angle2;
229 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
230 angle1 = Vec1.Angle(Tan1);
231 }
232 else { angle1 = 0.; }
233 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
234 angle2 = Vec2.Angle(Tan2);
235 }
236 else { angle2 = 0.; }
237 if (Qualified1.IsUnqualified()||
238 (Qualified1.IsEnclosing()&&angle1<=0.)||
239 (Qualified1.IsOutside() && angle1 >= 0.) ||
240 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
241 if (Qualified2.IsUnqualified() ||
242 (Qualified2.IsEnclosing()&&angle2<=0.)||
243 (Qualified2.IsOutside() && angle2 >= 0) ||
244 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
245 qualifier1 = Qualified1.Qualifier();
246 qualifier2 = Qualified2.Qualifier();
247 pnttg1sol = point1;
248 pararg1 = Ufirst(1);
249 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
250 pnttg2sol = point2;
251 pararg2 = Ufirst(2);
252 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
51740958 253 pntcen = point3new;
54e37688 254 parcen3 = Ufirst(3);
255 WellDone = Standard_True;
256 }
257 }
258 }
259 }
260}
261
262Geom2dGcc_Circ2d2TanOnIter::
263Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
264 const gp_Pnt2d& Point2 ,
265 const gp_Lin2d& OnLine ,
266 const Standard_Real Param1 ,
267 const Standard_Real Param2 ,
268 const Standard_Real Tolerance ) {
269 TheSame1 = Standard_False;
270 TheSame2 = Standard_False;
271 par1sol = 0.;
272 par2sol = 0.;
273 pararg1 = 0.;
274 pararg2 = 0.;
275 parcen3 = 0.;
276
277 WellDone = Standard_False;
d533dafb 278 qualifier1 = GccEnt_noqualifier;
279 qualifier2 = GccEnt_noqualifier;
54e37688 280 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
281 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
9775fa61 282 throw GccEnt_BadQualifier();
54e37688 283 return;
284 }
285 Standard_Real Tol = Abs(Tolerance);
286 gp_Dir2d dirx(1.,0.);
287 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
288 math_Vector Umin(1,3);
289 math_Vector Umax(1,3);
290 math_Vector Ufirst(1,3);
291 math_Vector tol(1,3);
292 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
293 Umin(2) = RealFirst();
294 Umin(3) = 0.;
295 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
296 Umax(2) = RealLast();
297 Umax(3) = RealLast();
298 Ufirst(1) = Param1;
299 Ufirst(2) = Param2;
300 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
301 tol(2) = 1.e-15;
302 tol(3) = Tol/10.;
303 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
304 gp_Pnt2d point3 = ElCLib::Value(Param2,OnLine);
305 Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
f4dee9bb 306 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Max(Ufirst(3), Tol));
859a47c3 307 math_FunctionSetRoot Root(Func, tol);
308 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 309 Func.Value(Ufirst,Umin);
310 if (Root.IsDone()) {
311 Root.Root(Ufirst);
51740958 312 gp_Pnt2d point1new,point3new;
54e37688 313 gp_Vec2d Tan1,Tan3;
51740958 314 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1new,Tan1);
315 ElCLib::D1(Ufirst(2),OnLine,point3new,Tan3);
316 Standard_Real dist1 = point3new.Distance(point1new);
317 Standard_Real dist2 = point3new.Distance(Point2);
54e37688 318 if ( Abs(dist1-dist2)/2. <= Tol) {
51740958 319 cirsol = gp_Circ2d(gp_Ax2d(point3new,dirx),(dist1+dist2)/2.);
54e37688 320 Standard_Real normetan1 = Tan1.Magnitude();
51740958 321 gp_Vec2d Vec1(point1new,point3new);
54e37688 322 Standard_Real normevec1 = Vec1.Magnitude();
323 Standard_Real angle1;
324 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
325 angle1 = Vec1.Angle(Tan1);
326 }
327 else { angle1 = 0.; }
328 if (Qualified1.IsUnqualified()||
329 (Qualified1.IsEnclosing()&&angle1<=0.)||
330 (Qualified1.IsOutside() && angle1 >= 0.) ||
331 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
332 qualifier1 = Qualified1.Qualifier();
333 qualifier2 = GccEnt_noqualifier;
51740958 334 pnttg1sol = point1new;
54e37688 335 pararg1 = Ufirst(1);
336 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
337 pnttg2sol = Point2;
338 pararg2 = Ufirst(2);
339 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
51740958 340 pntcen = point3new;
54e37688 341 parcen3 = Ufirst(3);
342 WellDone = Standard_True;
343 }
344 }
345 }
346}
347
348Geom2dGcc_Circ2d2TanOnIter::
349Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
350 const Geom2dGcc_QCurve& Qualified2 ,
351 const gp_Lin2d& OnLine ,
352 const Standard_Real Param1 ,
353 const Standard_Real Param2 ,
354 const Standard_Real Param3 ,
355 const Standard_Real Tolerance ) {
356 TheSame1 = Standard_False;
357 TheSame2 = Standard_False;
358 par1sol = 0.;
359 par2sol = 0.;
360 pararg1 = 0.;
361 pararg2 = 0.;
362 parcen3 = 0.;
363
364 WellDone = Standard_False;
d533dafb 365 qualifier1 = GccEnt_noqualifier;
366 qualifier2 = GccEnt_noqualifier;
54e37688 367 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
368 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
369 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
370 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 371 throw GccEnt_BadQualifier();
54e37688 372 return;
373 }
374 Standard_Real Tol = Abs(Tolerance);
375 gp_Dir2d dirx(1.,0.);
376 gp_Circ2d C1 = Qualified1.Qualified();
377 Standard_Real R1 = C1.Radius();
378 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
379 math_Vector Umin(1,4);
380 math_Vector Umax(1,4);
381 math_Vector Ufirst(1,4);
382 math_Vector tol(1,4);
383 Umin(1) = RealFirst();
384 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
385 Umin(3) = RealFirst();
386 Umin(4) = 0.;
387 Umax(1) = RealLast();
388 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
389 Umax(3) = RealLast();
390 Umax(4) = RealLast();
391 Ufirst(1) = Param1;
392 Ufirst(2) = Param2;
393 Ufirst(3) = Param3;
394 tol(1) = 2.e-15*M_PI;
395 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
396 tol(3) = 1.e-15;
397 tol(4) = Tol/10.;
398 gp_Pnt2d point1 = ElCLib::Value(Param1,C1);
399 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
400 gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
401 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 402 Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Max(Ufirst(4), Tol));
859a47c3 403 math_FunctionSetRoot Root(Func, tol);
404 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 405 Func.Value(Ufirst,Umin);
406 if (Root.IsDone()) {
407 Root.Root(Ufirst);
408 // gp_Vec2d Tan1,Tan2,Nor1,Nor2;
409 gp_Vec2d Tan1,Tan2,Nor2;
410 ElCLib::D2(Ufirst(1),C1,point1,Tan1,Nor2);
411 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
0797d9d3 412#ifdef OCCT_DEBUG
54e37688 413 gp_Vec2d Tan3(OnLine.Direction().XY());
414#else
415 OnLine.Direction().XY();
416#endif
417 point3 = ElCLib::Value(Ufirst(1),OnLine);
418 Standard_Real dist1 = point3.Distance(point1);
419 Standard_Real dist2 = point3.Distance(point2);
420 if ( Abs(dist1-dist2)/2. <= Tol) {
421 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
422 Standard_Real normetan2 = Tan2.Magnitude();
423 gp_Vec2d Vec1(point1,point3);
424 gp_Vec2d Vec2(point2,point3);
425 Standard_Real normevec2 = Vec2.Magnitude();
426 Standard_Real angle2;
427 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
428 angle2 = Vec2.Angle(Tan2);
429 }
430 else { angle2 = 0.; }
431 Standard_Real dist = C1.Location().Distance(point3);
432 Standard_Real Rsol = cirsol.Radius();
433 if (Qualified1.IsUnqualified() ||
434 (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)||
435 (Qualified1.IsOutside() && dist >= Rsol) ||
436 (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) {
437 if (Qualified2.IsUnqualified() ||
438 (Qualified2.IsEnclosing()&&angle2<=0.)||
439 (Qualified2.IsOutside() && angle2 >= 0) ||
440 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
441 qualifier1 = Qualified1.Qualifier();
442 qualifier2 = Qualified2.Qualifier();
443 pnttg1sol = point1;
444 pararg1 = Ufirst(1);
445 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
446 pnttg2sol = point2;
447 pararg2 = Ufirst(2);
448 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
449 pntcen = point3;
450 parcen3 = Ufirst(3);
451 WellDone = Standard_True;
452 }
453 }
454 }
455 }
456}
457
458Geom2dGcc_Circ2d2TanOnIter::
459Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
460 const Geom2dGcc_QCurve& Qualified2 ,
461 const gp_Circ2d& OnCirc ,
462 const Standard_Real Param1 ,
463 const Standard_Real Param2 ,
464 const Standard_Real Param3 ,
465 const Standard_Real Tolerance ) {
466 TheSame1 = Standard_False;
467 TheSame2 = Standard_False;
468 par1sol = 0.;
469 par2sol = 0.;
470 pararg1 = 0.;
471 pararg2 = 0.;
472 parcen3 = 0.;
473
474 WellDone = Standard_False;
d533dafb 475 qualifier1 = GccEnt_noqualifier;
476 qualifier2 = GccEnt_noqualifier;
54e37688 477 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
478 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
479 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
480 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 481 throw GccEnt_BadQualifier();
54e37688 482 return;
483 }
484 Standard_Real Tol = Abs(Tolerance);
485 gp_Dir2d dirx(1.,0.);
486 gp_Circ2d C1 = Qualified1.Qualified();
487 Standard_Real R1 = C1.Radius();
488 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
489 math_Vector Umin(1,4);
490 math_Vector Umax(1,4);
491 math_Vector Ufirst(1,4);
492 math_Vector tol(1,4);
493 Umin(1) = RealFirst();
494 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
495 Umin(3) = RealFirst();
496 Umin(4) = 0.;
497 Umax(1) = RealLast();
498 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
499 Umax(3) = RealLast();
500 Umax(4) = RealLast();
501 Ufirst(1) = Param1;
502 Ufirst(2) = Param2;
503 Ufirst(3) = Param3;
504 tol(1) = 2.e-15*M_PI;
505 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
506 tol(3) = 2.e-15*M_PI;
507 tol(4) = Tol/10.;
508 gp_Pnt2d point1 = ElCLib::Value(Param1,C1);
509 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
510 gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc);
511 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 512 Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Max(Ufirst(4), Tol));
859a47c3 513 math_FunctionSetRoot Root(Func, tol);
514 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 515 Func.Value(Ufirst,Umin);
516 if (Root.IsDone()) {
517 Root.Root(Ufirst);
518 // gp_Vec2d Tan1,Tan2,Nor1;
519 gp_Vec2d Tan1,Tan2;
520 ElCLib::D1(Ufirst(1),C1,point1,Tan1);
521 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
0797d9d3 522#ifdef OCCT_DEBUG
54e37688 523 gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3)));
524#endif
525 point3 = ElCLib::Value(Ufirst(3),OnCirc);
526 Standard_Real dist1 = point3.Distance(point1);
527 Standard_Real dist2 = point3.Distance(point2);
528 if ( Abs(dist1-dist2)/2. <= Tol) {
529 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
530 Standard_Real normetan2 = Tan2.Magnitude();
531 gp_Vec2d Vec1(point1,point3);
532 gp_Vec2d Vec2(point2,point3);
533 Standard_Real normevec2 = Vec2.Magnitude();
534 Standard_Real angle2;
535 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
536 angle2 = Vec2.Angle(Tan2);
537 }
538 else { angle2 = 0.; }
539 Standard_Real dist = C1.Location().Distance(point3);
540 Standard_Real Rsol = cirsol.Radius();
541 if (Qualified1.IsUnqualified() ||
542 (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)||
543 (Qualified1.IsOutside() && dist >= Rsol) ||
544 (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) {
545 if (Qualified2.IsUnqualified() ||
546 (Qualified2.IsEnclosing()&&angle2<=0.)||
547 (Qualified2.IsOutside() && angle2 >= 0) ||
548 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
549 qualifier1 = Qualified1.Qualifier();
550 qualifier2 = Qualified2.Qualifier();
551 pnttg1sol = point1;
552 pararg1 = Ufirst(1);
553 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
554 pnttg2sol = point2;
555 pararg2 = Ufirst(2);
556 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
557 pntcen = point3;
558 parcen3 = Ufirst(3);
559 WellDone = Standard_True;
560 }
561 }
562 }
563 }
564}
565
566Geom2dGcc_Circ2d2TanOnIter::
567Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 ,
568 const Geom2dGcc_QCurve& Qualified2 ,
569 const gp_Circ2d& OnCirc ,
570 const Standard_Real Param1 ,
571 const Standard_Real Param2 ,
572 const Standard_Real Param3 ,
573 const Standard_Real Tolerance ) {
574 TheSame1 = Standard_False;
575 TheSame2 = Standard_False;
576 par1sol = 0.;
577 par2sol = 0.;
578 pararg1 = 0.;
579 pararg2 = 0.;
580 parcen3 = 0.;
581
582 WellDone = Standard_False;
d533dafb 583 qualifier1 = GccEnt_noqualifier;
584 qualifier2 = GccEnt_noqualifier;
54e37688 585 if (!(Qualified1.IsEnclosed() ||
586 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
587 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
588 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 589 throw GccEnt_BadQualifier();
54e37688 590 return;
591 }
592 Standard_Real Tol = Abs(Tolerance);
593 gp_Dir2d dirx(1.,0.);
594 gp_Lin2d L1 = Qualified1.Qualified();
595 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
596 math_Vector Umin(1,4);
597 math_Vector Umax(1,4);
598 math_Vector Ufirst(1,4);
599 math_Vector tol(1,4);
600 Umin(1) = RealFirst();
601 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
602 Umin(3) = RealFirst();
603 Umin(4) = 0.;
604 Umax(1) = RealLast();
605 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
606 Umax(3) = RealLast();
607 Umax(4) = RealLast();
608 Ufirst(1) = Param1;
609 Ufirst(2) = Param2;
610 Ufirst(3) = Param3;
611 tol(1) = 1.e-15;
612 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
613 tol(3) = 2.e-15*M_PI;
614 tol(4) = Tol/10.;
615 gp_Pnt2d point1 = ElCLib::Value(Param1,L1);
616 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
617 gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc);
618 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 619 Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Max(Ufirst(4), Tol));
859a47c3 620 math_FunctionSetRoot Root(Func, tol);
621 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 622 Func.Value(Ufirst,Umin);
623 if (Root.IsDone()) {
624 Root.Root(Ufirst);
51740958 625 gp_Pnt2d point1new,point2new;
54e37688 626 gp_Vec2d Tan1,Tan2;
51740958 627 ElCLib::D1(Ufirst(1),L1,point1new,Tan1);
628 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2new,Tan2);
0797d9d3 629#ifdef OCCT_DEBUG
54e37688 630 gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3)));
631#endif
632 point3 = ElCLib::Value(Ufirst(3),OnCirc);
51740958 633 Standard_Real dist1 = point3.Distance(point1new);
634 Standard_Real dist2 = point3.Distance(point2new);
54e37688 635 if ( Abs(dist1-dist2)/2. <= Tol) {
636 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
637 Standard_Real normetan2 = Tan2.Magnitude();
51740958 638 gp_Vec2d Vec1(point1new,point3);
639 gp_Vec2d Vec2(point2new,point3);
54e37688 640 Standard_Real normevec2 = Vec2.Magnitude();
641 Standard_Real angle2;
642 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
643 angle2 = Vec2.Angle(Tan2);
644 }
645 else { angle2 = 0.; }
646 Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(),
647 L1.Direction().X()));
648 if (Qualified1.IsUnqualified() ||
649 (Qualified1.IsOutside() && pscal <= 0.) ||
650 (Qualified1.IsEnclosed() && pscal >= 0.)) {
651 if (Qualified2.IsUnqualified() ||
652 (Qualified2.IsEnclosing()&&angle2<=0.)||
653 (Qualified2.IsOutside() && angle2 >= 0) ||
654 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
655 qualifier1 = Qualified1.Qualifier();
656 qualifier2 = Qualified2.Qualifier();
51740958 657 pnttg1sol = point1new;
54e37688 658 pararg1 = Ufirst(1);
659 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
51740958 660 pnttg2sol = point2new;
54e37688 661 pararg2 = Ufirst(2);
662 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
663 pntcen = point3;
664 parcen3 = Ufirst(3);
665 WellDone = Standard_True;
666 }
667 }
668 }
669 }
670}
671
672Geom2dGcc_Circ2d2TanOnIter::
673Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
674 const Geom2dGcc_QCurve& Qualified2 ,
675 const gp_Circ2d& OnCirc ,
676 const Standard_Real Param1 ,
677 const Standard_Real Param2 ,
678 const Standard_Real Param3 ,
679 const Standard_Real Tolerance ) {
680 TheSame1 = Standard_False;
681 TheSame2 = Standard_False;
682 par1sol = 0.;
683 par2sol = 0.;
684 pararg1 = 0.;
685 pararg2 = 0.;
686 parcen3 = 0.;
687
688 WellDone = Standard_False;
d533dafb 689 qualifier1 = GccEnt_noqualifier;
690 qualifier2 = GccEnt_noqualifier;
54e37688 691 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
692 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
693 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
694 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 695 throw GccEnt_BadQualifier();
54e37688 696 return;
697 }
698 Standard_Real Tol = Abs(Tolerance);
699 gp_Dir2d dirx(1.,0.);
700 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
701 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
702 math_Vector Umin(1,4);
703 math_Vector Umax(1,4);
704 math_Vector Ufirst(1,4);
705 math_Vector tol(1,4);
706 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
707 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
708 Umin(3) = RealFirst();
709 Umin(4) = 0.;
710 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
711 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
712 Umax(3) = RealLast();
713 Umax(4) = RealLast();
714 Ufirst(1) = Param1;
715 Ufirst(2) = Param2;
716 Ufirst(3) = Param3;
717 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
718 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
719 tol(3) = 2.e-15*M_PI;
720 tol(4) = Tol/10.;
721 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
722 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
723 Standard_Real R1 = OnCirc.Radius();
724 gp_Pnt2d point3(OnCirc.Location().XY()+R1*gp_XY(Cos(Param3),Sin(Param3)));
725 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 726 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Max(Ufirst(4), Tol));
859a47c3 727 math_FunctionSetRoot Root(Func, tol);
728 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 729 Func.Value(Ufirst,Umin);
730 if (Root.IsDone()) {
731 Root.Root(Ufirst);
732 // gp_Vec2d Tan1,Tan2,Nor1;
733 gp_Vec2d Tan1,Tan2;
734 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
735 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
0797d9d3 736#ifdef OCCT_DEBUG
54e37688 737 gp_Vec2d Tan3(-Sin(Ufirst(3)),Cos(Ufirst(3)));
738#endif
739 point3 = gp_Pnt2d(OnCirc.Location().XY()+
740 R1*gp_XY(Cos(Ufirst(3)),Sin(Ufirst(3))));
741 Standard_Real dist1 = point3.Distance(point1);
742 Standard_Real dist2 = point3.Distance(point2);
743 if ( Abs(dist1-dist2)/2. <= Tol) {
744 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
745 Standard_Real normetan1 = Tan1.Magnitude();
746 Standard_Real normetan2 = Tan2.Magnitude();
747 gp_Vec2d Vec1(point1,point3);
748 gp_Vec2d Vec2(point2,point3);
749 Standard_Real normevec1 = Vec1.Magnitude();
750 Standard_Real normevec2 = Vec2.Magnitude();
751 Standard_Real angle1,angle2;
752 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
753 angle1 = Vec1.Angle(Tan1);
754 }
755 else { angle1 = 0.; }
756 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
757 angle2 = Vec2.Angle(Tan2);
758 }
759 else { angle2 = 0.; }
760 if (Qualified1.IsUnqualified()||
761 (Qualified1.IsEnclosing()&&angle1<=0.)||
762 (Qualified1.IsOutside() && angle1 >= 0.) ||
763 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
764 if (Qualified2.IsUnqualified() ||
765 (Qualified2.IsEnclosing()&&angle2<=0.)||
766 (Qualified2.IsOutside() && angle2 >= 0) ||
767 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
768 qualifier1 = Qualified1.Qualifier();
769 qualifier2 = Qualified2.Qualifier();
770 pararg1 = Ufirst(1);
771 par1sol = 0.;
772 pnttg1sol = point1;
773 pararg2 = Ufirst(2);
774 pnttg2sol = point2;
775 par2sol = pnttg2sol.Distance(pnttg1sol);
776 pntcen = point3;
777 parcen3 = Ufirst(3);
778 WellDone = Standard_True;
779 }
780 }
781 }
782 }
783}
784
785Geom2dGcc_Circ2d2TanOnIter::
786Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
787 const gp_Pnt2d& Point2 ,
788 const gp_Circ2d& OnCirc ,
789 const Standard_Real Param1 ,
790 const Standard_Real Param2 ,
791 const Standard_Real Tolerance ) {
792 TheSame1 = Standard_False;
793 TheSame2 = Standard_False;
794 par1sol = 0.;
795 par2sol = 0.;
796 pararg1 = 0.;
797 pararg2 = 0.;
798 parcen3 = 0.;
799
800 WellDone = Standard_False;
d533dafb 801 qualifier1 = GccEnt_noqualifier;
802 qualifier2 = GccEnt_noqualifier;
54e37688 803 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
804 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
9775fa61 805 throw GccEnt_BadQualifier();
54e37688 806 return;
807 }
808 Standard_Real Tol = Abs(Tolerance);
809 gp_Dir2d dirx(1.,0.);
810 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
811 math_Vector Umin(1,3);
812 math_Vector Umax(1,3);
813 math_Vector Ufirst(1,3);
814 math_Vector tol(1,3);
815 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
816 Umin(2) = RealFirst();
817 Umin(3) = 0.;
818 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
819 Umax(2) = RealLast();
820 Umax(3) = RealLast();
821 Ufirst(1) = Param1;
822 Ufirst(2) = Param2;
823 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
824 tol(2) = 2.e-15*M_PI;
825 tol(3) = Tol/10.;
826 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
827 gp_Pnt2d point3 = ElCLib::Value(Param2,OnCirc);
828 Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
f4dee9bb 829 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Max(Ufirst(3), Tol));
859a47c3 830 math_FunctionSetRoot Root(Func, tol);
831 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 832 Func.Value(Ufirst,Umin);
833 if (Root.IsDone()) {
834 Root.Root(Ufirst);
51740958 835 gp_Pnt2d point1new,point3new;
54e37688 836 gp_Vec2d Tan1,Tan3;
51740958 837 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1new,Tan1);
838 ElCLib::D1(Ufirst(2),OnCirc,point3new,Tan3);
839 Standard_Real dist1 = point3new.Distance(point1new);
840 Standard_Real dist2 = point3new.Distance(Point2);
54e37688 841 if ( Abs(dist1-dist2)/2. <= Tol) {
51740958 842 cirsol = gp_Circ2d(gp_Ax2d(point3new,dirx),(dist1+dist2)/2.);
54e37688 843 Standard_Real normetan1 = Tan1.Magnitude();
51740958 844 gp_Vec2d Vec1(point1new,point3new);
54e37688 845 Standard_Real normevec1 = Vec1.Magnitude();
846 Standard_Real angle1;
847 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
848 angle1 = Vec1.Angle(Tan1);
849 }
850 else { angle1 = 0.; }
851 if (Qualified1.IsUnqualified()||
852 (Qualified1.IsEnclosing()&&angle1<=0.)||
853 (Qualified1.IsOutside() && angle1 >= 0.) ||
854 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
855 qualifier1 = Qualified1.Qualifier();
856 qualifier2 = GccEnt_noqualifier;
51740958 857 pnttg1sol = point1new;
54e37688 858 pararg1 = Ufirst(1);
859 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
860 pnttg2sol = Point2;
861 pararg2 = 0.;
862 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
51740958 863 pntcen = point3new;
54e37688 864 parcen3 = Ufirst(3);
865 WellDone = Standard_True;
866 }
867 }
868 }
869}
870
871Geom2dGcc_Circ2d2TanOnIter::
872Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
873 const Geom2dGcc_QCurve& Qualified2 ,
874 const Geom2dAdaptor_Curve& OnCurv ,
875 const Standard_Real Param1 ,
876 const Standard_Real Param2 ,
877 const Standard_Real Param3 ,
878 const Standard_Real Tolerance ) {
879 TheSame1 = Standard_False;
880 TheSame2 = Standard_False;
881 par1sol = 0.;
882 par2sol = 0.;
883 pararg1 = 0.;
884 pararg2 = 0.;
885 parcen3 = 0.;
886
887 WellDone = Standard_False;
888 Standard_Real Tol = Abs(Tolerance);
d533dafb 889 qualifier1 = GccEnt_noqualifier;
890 qualifier2 = GccEnt_noqualifier;
54e37688 891 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
892 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
893 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
894 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 895 throw GccEnt_BadQualifier();
54e37688 896 return;
897 }
898 gp_Dir2d dirx(1.,0.);
899 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
900 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
901 math_Vector Umin(1,4);
902 math_Vector Umax(1,4);
903 math_Vector Ufirst(1,4);
904 math_Vector tol(1,4);
905 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
906 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
907 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
908 Umin(4) = 0.;
909 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
910 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
911 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
912 Umax(4) = RealLast();
913 Ufirst(1) = Param1;
914 Ufirst(2) = Param2;
915 Ufirst(3) = Param3;
916 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
917 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
918 tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
919 tol(4) = Tol/10.;
920 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
921 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
922 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,Param3);
923 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 924 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Max(Ufirst(4), Tol));
859a47c3 925 math_FunctionSetRoot Root(Func, tol);
926 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 927 Func.Value(Ufirst,Umin);
928 if (Root.IsDone()) {
929 Root.Root(Ufirst);
930 gp_Vec2d Tan1,Tan2,Tan3;
931 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
932 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
933 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
934 Standard_Real dist1 = point3.Distance(point1);
935 Standard_Real dist2 = point3.Distance(point2);
936 if ( Abs(dist1-dist2)/2. <= Tol) {
937 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
938 Standard_Real normetan1 = Tan1.Magnitude();
939 Standard_Real normetan2 = Tan2.Magnitude();
940 gp_Vec2d Vec1(point1,point3);
941 gp_Vec2d Vec2(point2,point3);
942 Standard_Real normevec1 = Vec1.Magnitude();
943 Standard_Real normevec2 = Vec2.Magnitude();
944 Standard_Real angle1,angle2;
945 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
946 angle1 = Vec1.Angle(Tan1);
947 }
948 else { angle1 = 0.; }
949 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
950 angle2 = Vec2.Angle(Tan2);
951 }
952 else { angle2 = 0.; }
953 if (Qualified1.IsUnqualified()||
954 (Qualified1.IsEnclosing()&&angle1<=0.)||
955 (Qualified1.IsOutside() && angle1 >= 0.) ||
956 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
957 if (Qualified2.IsUnqualified() ||
958 (Qualified2.IsEnclosing()&&angle2<=0.)||
959 (Qualified2.IsOutside() && angle2 >= 0) ||
960 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
961 qualifier1 = Qualified1.Qualifier();
962 qualifier2 = Qualified2.Qualifier();
963 pararg1 = Ufirst(1);
964 par1sol = 0.;
965 pnttg1sol = point1;
966 pararg2 = Ufirst(2);
967 pnttg2sol = point2;
968 par2sol = pnttg2sol.Distance(pnttg1sol);
969 pntcen = point3;
970 parcen3 = Ufirst(3);
971 WellDone = Standard_True;
972 }
973 }
974 }
975 }
976}
977
978Geom2dGcc_Circ2d2TanOnIter::
979Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
980 const Geom2dGcc_QCurve& Qualified2 ,
981 const Geom2dAdaptor_Curve& OnCurv ,
982 const Standard_Real Param1 ,
983 const Standard_Real Param2 ,
984 const Standard_Real ParamOn ,
985 const Standard_Real Tolerance ) {
986
987 TheSame1 = Standard_False;
988 TheSame2 = Standard_False;
989 par1sol = 0.;
990 par2sol = 0.;
991 pararg1 = 0.;
992 pararg2 = 0.;
993 parcen3 = 0.;
994
995 WellDone = Standard_False;
d533dafb 996 qualifier1 = GccEnt_noqualifier;
997 qualifier2 = GccEnt_noqualifier;
54e37688 998 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
999 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
1000 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
1001 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 1002 throw GccEnt_BadQualifier();
54e37688 1003 return;
1004 }
1005 Standard_Real Tol = Abs(Tolerance);
1006 gp_Circ2d C1 = Qualified1.Qualified();
1007 Standard_Real R1 = C1.Radius();
1008 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
1009 math_Vector Umin(1,4);
1010 math_Vector Umax(1,4);
1011 math_Vector Ufirst(1,4);
1012 math_Vector tol(1,4);
1013 Umin(1) = RealFirst();
1014 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
1015 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
1016 Umin(4) = 0.;
1017 Umax(1) = RealLast();
1018 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
1019 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
1020 Umax(4) = RealLast();
1021 Ufirst(1) = Param1;
1022 Ufirst(2) = Param2;
1023 Ufirst(3) = ParamOn;
1024 tol(1) = 2.e-15*M_PI;
1025 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
1026 tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
8c2d3314 1027 tol(4) = Tol/10.;
54e37688 1028 gp_Pnt2d point1 = ElCLib::Value(Param1,C1);
1029 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
1030 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
1031 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 1032 Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Max(Ufirst(4), Tol));
859a47c3 1033 math_FunctionSetRoot Root(Func, tol);
1034 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 1035 Func.Value(Ufirst,Umin);
1036 if (Root.IsDone()) {
1037 Root.Root(Ufirst);
1038 gp_Vec2d Tan1,Tan2,Tan3;
1039 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
1040 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
1041 ElCLib::D1(Ufirst(1),C1,point1,Tan1);
1042 Standard_Real dist1 = point3.Distance(point1);
1043 Standard_Real dist2 = point3.Distance(point2);
1044 if ( Abs(dist1-dist2)/2. <= Tol) {
1045 gp_Dir2d dirx(1.,0.);
1046 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
1047 Standard_Real normetan2 = Tan2.Magnitude();
1048 gp_Vec2d Vec1(point1.XY(),point3.XY());
1049 gp_Vec2d Vec2(point2.XY(),point3.XY());
1050 Standard_Real normevec2 = Vec2.Magnitude();
1051 Standard_Real angle2;
1052 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
1053 angle2 = Vec2.Angle(Tan2);
1054 }
1055 else { angle2 = 0.; }
1056 Standard_Real dist = C1.Location().Distance(point3);
1057 Standard_Real Rsol = cirsol.Radius();
1058 if (Qualified1.IsUnqualified() ||
1059 (Qualified1.IsEnclosing() && Rsol >= R1 && dist <= Rsol)||
1060 (Qualified1.IsOutside() && dist >= Rsol) ||
1061 (Qualified1.IsEnclosed() && Rsol <= R1 && dist <= Rsol)) {
1062 if (Qualified2.IsUnqualified() ||
1063 (Qualified2.IsEnclosing()&&angle2<=0.)||
1064 (Qualified2.IsOutside() && angle2 >= 0) ||
1065 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
1066 qualifier1 = Qualified1.Qualifier();
1067 qualifier2 = Qualified2.Qualifier();
1068 pnttg1sol = point1;
1069 pararg1 = Ufirst(1);
1070 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
1071 pnttg2sol = point2;
1072 pararg2 = Ufirst(2);
1073 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
1074 pntcen = point3;
1075 parcen3 = Ufirst(3);
1076 WellDone = Standard_True;
1077 }
1078 }
1079 }
1080 }
1081}
1082
1083Geom2dGcc_Circ2d2TanOnIter::
1084Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 ,
1085 const Geom2dGcc_QCurve& Qualified2 ,
1086 const Geom2dAdaptor_Curve& OnCurv ,
1087 const Standard_Real Param1 ,
1088 const Standard_Real Param2 ,
1089 const Standard_Real ParamOn ,
1090 const Standard_Real Tolerance ) {
1091 TheSame1 = Standard_False;
1092 TheSame2 = Standard_False;
1093 par1sol = 0.;
1094 par2sol = 0.;
1095 pararg1 = 0.;
1096 pararg2 = 0.;
1097 parcen3 = 0.;
1098
1099 WellDone = Standard_False;
d533dafb 1100 qualifier1 = GccEnt_noqualifier;
1101 qualifier2 = GccEnt_noqualifier;
54e37688 1102 if (!(Qualified1.IsEnclosed() ||
1103 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
1104 !(Qualified2.IsEnclosed() || Qualified2.IsEnclosing() ||
1105 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
9775fa61 1106 throw GccEnt_BadQualifier();
54e37688 1107 return;
1108 }
1109 Standard_Real Tol = Abs(Tolerance);
1110 gp_Dir2d dirx(1.,0.);
1111 gp_Lin2d L1 = Qualified1.Qualified();
1112 Geom2dAdaptor_Curve Cu2 = Qualified2.Qualified();
1113 math_Vector Umin(1,4);
1114 math_Vector Umax(1,4);
1115 math_Vector Ufirst(1,4);
1116 math_Vector tol(1,4);
1117 Umin(1) = RealFirst();
1118 Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
1119 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
1120 Umin(4) = 0.;
1121 Umax(1) = RealLast();
1122 Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
1123 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
1124 Umax(4) = RealLast();
1125 Ufirst(1) = Param1;
1126 Ufirst(2) = Param2;
1127 Ufirst(3) = ParamOn;
1128 tol(1) = 1.e-15;
1129 tol(2) = Geom2dGcc_CurveTool::EpsX(Cu2,Abs(Tolerance));
1130 tol(3) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
1131 tol(4) = Tol/10.;
1132 gp_Pnt2d point1 = ElCLib::Value(Param1,L1);
1133 gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
1134 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
1135 Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
f4dee9bb 1136 Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Max(Ufirst(4), Tol));
859a47c3 1137 math_FunctionSetRoot Root(Func, tol);
1138 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 1139 Func.Value(Ufirst,Umin);
1140 if (Root.IsDone()) {
1141 Root.Root(Ufirst);
1142 gp_Vec2d Tan1,Tan2,Tan3;
1143 ElCLib::D1(Ufirst(1),L1,point1,Tan1);
1144 Geom2dGcc_CurveTool::D1(Cu2,Ufirst(2),point2,Tan2);
1145 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
1146 Standard_Real dist1 = point3.Distance(point1);
1147 Standard_Real dist2 = point3.Distance(point2);
1148 if ( Abs(dist1-dist2)/2. <= Tol) {
1149 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
1150 Standard_Real normetan2 = Tan2.Magnitude();
1151 gp_Vec2d Vec1(point1,point3);
1152 gp_Vec2d Vec2(point2,point3);
1153 Standard_Real normevec2 = Vec2.Magnitude();
1154 Standard_Real angle2;
1155 if (normevec2 >= gp::Resolution() && normetan2 >= gp::Resolution()) {
1156 angle2 = Vec2.Angle(Tan2);
1157 }
1158 else { angle2 = 0.; }
1159 Standard_Real pscal=point3.XY().Dot(gp_XY(-L1.Direction().Y(),
1160 L1.Direction().X()));
1161 if (Qualified1.IsUnqualified() ||
1162 (Qualified1.IsOutside() && pscal <= 0.) ||
1163 (Qualified1.IsEnclosed() && pscal >= 0.)) {
1164 if (Qualified2.IsUnqualified() ||
1165 (Qualified2.IsEnclosing()&&angle2<=0.)||
1166 (Qualified2.IsOutside() && angle2 >= 0) ||
1167 (Qualified2.IsEnclosed() && angle2 <= 0.)) {
1168 qualifier1 = Qualified1.Qualifier();
1169 qualifier2 = Qualified2.Qualifier();
1170 pnttg1sol = point1;
1171 pararg1 = Ufirst(1);
1172 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
1173 pnttg2sol = point2;
1174 pararg2 = Ufirst(2);
1175 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
1176 pntcen = point3;
1177 parcen3 = Ufirst(3);
1178 WellDone = Standard_True;
1179 }
1180 }
1181 }
1182 }
1183}
1184
1185Geom2dGcc_Circ2d2TanOnIter::
1186Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
1187 const gp_Pnt2d& Point2 ,
1188 const Geom2dAdaptor_Curve& OnCurv ,
1189 const Standard_Real Param1 ,
1190 const Standard_Real ParamOn ,
1191 const Standard_Real Tolerance )
1192{
1193 TheSame1 = Standard_False;
1194 TheSame2 = Standard_False;
1195 par1sol = 0.;
1196 par2sol = 0.;
1197 pararg1 = 0.;
1198 pararg2 = 0.;
1199 parcen3 = 0.;
1200
1201 WellDone = Standard_False;
d533dafb 1202 qualifier1 = GccEnt_noqualifier;
1203 qualifier2 = GccEnt_noqualifier;
54e37688 1204 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
1205 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
9775fa61 1206 throw GccEnt_BadQualifier();
54e37688 1207 return;
1208 }
1209 Standard_Real Tol = Abs(Tolerance);
1210 gp_Dir2d dirx(1.,0.);
1211 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
1212 math_Vector Umin(1,3);
1213 math_Vector Umax(1,3);
1214 math_Vector Ufirst(1,3);
1215 math_Vector tol(1,3);
1216 Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
1217 Umin(2) = RealFirst();
1218 Umin(3) = Geom2dGcc_CurveTool::FirstParameter(OnCurv);
1219 Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
1220 Umax(2) = RealLast();
1221 Umax(3) = Geom2dGcc_CurveTool::LastParameter(OnCurv);
1222 Ufirst(1) = Param1;
1223 Ufirst(2) = ParamOn;
1224 tol(1) = Geom2dGcc_CurveTool::EpsX(Cu1,Abs(Tolerance));
1225 tol(2) = Geom2dGcc_CurveTool::EpsX(OnCurv,Abs(Tolerance));
1226 tol(3) = Tol/10.;
1227 gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
1228 gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
1229 Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
f4dee9bb 1230 Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Max(Ufirst(3), Tol));
859a47c3 1231 math_FunctionSetRoot Root(Func, tol);
1232 Root.Perform(Func, Ufirst, Umin, Umax);
54e37688 1233 Func.Value(Ufirst,Umin);
1234 if (Root.IsDone()) {
1235 Root.Root(Ufirst);
1236 // gp_Vec2d Tan1,Tan2,Tan3;
1237 gp_Vec2d Tan1,Tan3;
1238 Geom2dGcc_CurveTool::D1(Cu1,Ufirst(1),point1,Tan1);
1239 Geom2dGcc_CurveTool::D1(OnCurv,Ufirst(3),point3,Tan3);
1240 Standard_Real dist1 = point3.Distance(point1);
1241 Standard_Real dist2 = point3.Distance(Point2);
1242 if ( Abs(dist1-dist2)/2. <= Tol) {
1243 cirsol = gp_Circ2d(gp_Ax2d(point3,dirx),(dist1+dist2)/2.);
1244 Standard_Real normetan1 = Tan1.Magnitude();
1245 gp_Vec2d Vec1(point1,point3);
1246 Standard_Real normevec1 = Vec1.Magnitude();
1247 Standard_Real angle1;
1248 if (normevec1 >= gp::Resolution() && normetan1 >= gp::Resolution()) {
1249 angle1 = Vec1.Angle(Tan1);
1250 }
1251 else { angle1 = 0.; }
1252 if (Qualified1.IsUnqualified()||
1253 (Qualified1.IsEnclosing()&&angle1<=0.)||
1254 (Qualified1.IsOutside() && angle1 >= 0.) ||
1255 (Qualified1.IsEnclosed() && angle1 <= 0.)) {
1256 qualifier1 = Qualified1.Qualifier();
1257 qualifier2 = GccEnt_noqualifier;
1258 pnttg1sol = point1;
1259 pararg1 = Ufirst(1);
1260 par1sol = ElCLib::Parameter(cirsol,pnttg1sol);
1261 pnttg2sol = Point2;
1262 pararg2 = 0.;
1263 par2sol = ElCLib::Parameter(cirsol,pnttg2sol);
1264 pntcen = point3;
1265 parcen3 = Ufirst(3);
1266 WellDone = Standard_True;
1267 }
1268 }
1269 }
1270}
1271
1272Standard_Boolean Geom2dGcc_Circ2d2TanOnIter::
1273IsDone () const{ return WellDone; }
1274
1275gp_Circ2d Geom2dGcc_Circ2d2TanOnIter::
1276ThisSolution () const{ return cirsol; }
1277
1278void Geom2dGcc_Circ2d2TanOnIter::
1279WhichQualifier (GccEnt_Position& Qualif1 ,
1280 GccEnt_Position& Qualif2 ) const
1281{
9775fa61 1282 if (!WellDone) { throw StdFail_NotDone(); }
54e37688 1283 else {
1284 Qualif1 = qualifier1;
1285 Qualif2 = qualifier2;
1286 }
1287}
1288
1289void Geom2dGcc_Circ2d2TanOnIter::
1290Tangency1 (Standard_Real& ParSol ,
1291 Standard_Real& ParArg ,
1292 gp_Pnt2d& PntSol ) const
1293{
9775fa61 1294 if (!WellDone) { throw StdFail_NotDone(); }
54e37688 1295 else {
1296 if (TheSame1 == 0) {
1297 ParSol = 0;
1298 ParArg = 0;
1299 PntSol = pnttg1sol;
1300 }
9775fa61 1301 else { throw StdFail_NotDone(); }
54e37688 1302 }
1303}
1304
1305void Geom2dGcc_Circ2d2TanOnIter::
1306Tangency2 (Standard_Real& ParSol ,
1307 Standard_Real& ParArg ,
1308 gp_Pnt2d& PntSol ) const
1309{
9775fa61 1310 if (!WellDone) { throw StdFail_NotDone(); }
54e37688 1311 else {
1312 ParSol = 0;
1313 ParArg = 0;
1314 PntSol = pnttg2sol;
1315 }
1316}
1317
1318void Geom2dGcc_Circ2d2TanOnIter::
1319CenterOn3 (Standard_Real& ParArg ,
1320 gp_Pnt2d& PntSol ) const
1321{
9775fa61 1322 if (!WellDone) { throw StdFail_NotDone(); }
54e37688 1323 else {
1324 ParArg = 0;
1325 PntSol = pntcen;
1326 }
1327}
1328
1329Standard_Boolean Geom2dGcc_Circ2d2TanOnIter::
1330IsTheSame1 () const
1331{
9775fa61 1332 if (!WellDone) throw StdFail_NotDone();
54e37688 1333
1334 if (TheSame1 == 0)
1335 return Standard_False;
1336 return Standard_True;
1337}
1338
1339
1340Standard_Boolean Geom2dGcc_Circ2d2TanOnIter::
1341IsTheSame2 () const
1342{
9775fa61 1343 if (!WellDone) throw StdFail_NotDone();
54e37688 1344 return Standard_False;
1345}