1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 //========================================================================
16 // circulaire tangent a un element de type : - Cercle. +
19 // centre sur un deuxieme element de type : - Cercle. +
21 // de rayon donne : Radius. +
22 //========================================================================
24 #include <Adaptor3d_OffsetCurve.hxx>
26 #include <GccEnt_BadQualifier.hxx>
27 #include <GccEnt_QualifiedCirc.hxx>
28 #include <GccEnt_QualifiedLin.hxx>
29 #include <Geom2dAdaptor_Curve.hxx>
30 #include <Geom2dAdaptor_HCurve.hxx>
31 #include <Geom2dGcc_Circ2dTanOnRadGeo.hxx>
32 #include <Geom2dGcc_CurveTool.hxx>
33 #include <Geom2dGcc_CurveToolGeo.hxx>
34 #include <Geom2dGcc_QCurve.hxx>
35 #include <Geom2dInt_GInter.hxx>
36 #include <gp_Circ2d.hxx>
37 #include <gp_Dir2d.hxx>
38 #include <gp_Lin2d.hxx>
39 #include <gp_Pnt2d.hxx>
40 #include <IntRes2d_Domain.hxx>
41 #include <IntRes2d_IntersectionPoint.hxx>
42 #include <math_DirectPolynomialRoots.hxx>
43 #include <Standard_NegativeValue.hxx>
44 #include <Standard_OutOfRange.hxx>
45 #include <StdFail_NotDone.hxx>
46 #include <TColStd_Array1OfReal.hxx>
48 //=========================================================================
49 // Cercle tangent : a un cercle Qualified1 (C1). +
50 // centre : sur une droite OnLine. +
51 // de rayon : Radius. +
53 // On initialise le tableau de solutions cirsol ainsi que tous les +
55 // On elimine en fonction du qualifieur les cas ne presentant pas de +
57 // On resoud l equation du second degre indiquant que le point de centre +
58 // recherche (xc,yc) est a une distance Radius du cercle C1 et +
59 // sur la droite OnLine. +
60 // Les solutions sont representees par les cercles : +
61 // - de centre Pntcen(xc,yc) +
62 // - de rayon Radius. +
63 //=========================================================================
64 Geom2dGcc_Circ2dTanOnRadGeo::
65 Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1,
66 const gp_Lin2d& OnLine ,
67 const Standard_Real Radius ,
68 const Standard_Real Tolerance ):
70 //=========================================================================
71 // Initialisation des champs. +
72 //=========================================================================
84 //=========================================================================
86 //=========================================================================
88 gp_Dir2d dirx(1.0,0.0);
89 Standard_Real Tol = Abs(Tolerance);
90 Standard_Real thefirst = -100000.;
91 Standard_Real thelast = 100000.;
92 Standard_Real firstparam;
93 Standard_Real lastparam;
94 WellDone = Standard_False;
96 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
97 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
98 GccEnt_BadQualifier::Raise();
101 Standard_Integer nbrcote1 = 0;
102 TColStd_Array1OfReal Coef(1,2);
103 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
105 if (Radius < 0.0) { Standard_NegativeValue::Raise(); }
107 if (Qualified1.IsEnclosed()) {
108 // ===========================
112 else if(Qualified1.IsOutside()) {
113 // ===============================
117 else if(Qualified1.IsUnqualified()) {
118 // ===================================
124 Geom2dInt_TheIntConicCurveOfGInter Intp;
125 for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
126 Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
127 Adaptor3d_OffsetCurve C2(HCu1,Coef(jcote1));
128 firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst);
129 lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast);
130 IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol,
131 Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol);
132 Intp.Perform(OnLine,D1,C2,D2,Tol,Tol);
134 if (!Intp.IsEmpty()) {
135 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
137 gp_Pnt2d Center(Intp.Point(i).Value());
138 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
139 // =======================================================
140 qualifier1(NbrSol) = Qualified1.Qualifier();
141 TheSame1(NbrSol) = 0;
142 pararg1(NbrSol) = Intp.Point(i).ParamOnSecond();
143 parcen3(NbrSol) = Intp.Point(i).ParamOnFirst();
144 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
146 pnttg1sol(NbrSol) = gp_Pnt2d(Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)));
147 pntcen3(NbrSol) = Center;
150 WellDone = Standard_True;
156 //=========================================================================
157 // Cercle tangent : a un cercle Qualified1 (C1). +
158 // centre : sur une droite OnLine. +
159 // de rayon : Radius. +
161 // On initialise le tableau de solutions cirsol ainsi que tous les +
163 // On elimine en fonction du qualifieur les cas ne presentant pas de +
165 // On resoud l equation du second degre indiquant que le point de centre +
166 // recherche (xc,yc) est a une distance Radius du cercle C1 et +
167 // sur la droite OnLine. +
168 // Les solutions sont representees par les cercles : +
169 // - de centre Pntcen(xc,yc) +
170 // - de rayon Radius. +
171 //=========================================================================
173 Geom2dGcc_Circ2dTanOnRadGeo::
174 Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1,
175 const gp_Circ2d& OnCirc ,
176 const Standard_Real Radius ,
177 const Standard_Real Tolerance ):
179 //=========================================================================
180 // Initialisation des champs. +
181 //=========================================================================
193 //=========================================================================
195 //=========================================================================
197 gp_Dir2d dirx(1.0,0.0);
198 Standard_Real thefirst = -100000.;
199 Standard_Real thelast = 100000.;
200 Standard_Real firstparam;
201 Standard_Real lastparam;
202 Standard_Real Tol = Abs(Tolerance);
203 Standard_Integer nbrcote1=0;
204 WellDone = Standard_False;
206 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
207 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
208 GccEnt_BadQualifier::Raise();
211 TColStd_Array1OfReal cote1(1,2);
212 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
215 Standard_NegativeValue::Raise();
218 if (Qualified1.IsEnclosed()) {
219 // ===========================
223 else if(Qualified1.IsOutside()) {
224 // ===============================
228 else if(Qualified1.IsUnqualified()) {
229 // ===================================
234 IntRes2d_Domain D1(ElCLib::Value(0.,OnCirc), 0.,Tol,
235 ElCLib::Value(2.*M_PI,OnCirc),2.*M_PI,Tol);
236 D1.SetEquivalentParameters(0.,2.*M_PI);
237 Geom2dInt_TheIntConicCurveOfGInter Intp;
238 for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
239 Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
240 Adaptor3d_OffsetCurve C2(HCu1,cote1(jcote1));
241 firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst);
242 lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast);
243 IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol,
244 Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol);
245 Intp.Perform(OnCirc,D1,C2,D2,Tol,Tol);
247 if (!Intp.IsEmpty()) {
248 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
250 gp_Pnt2d Center(Intp.Point(i).Value());
251 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
252 // =======================================================
253 qualifier1(NbrSol) = Qualified1.Qualifier();
254 TheSame1(NbrSol) = 0;
255 pararg1(NbrSol) = Intp.Point(i).ParamOnSecond();
256 parcen3(NbrSol) = Intp.Point(i).ParamOnFirst();
257 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
259 pnttg1sol(NbrSol) = gp_Pnt2d(Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)));
260 pntcen3(NbrSol) = Center;
263 WellDone = Standard_True;
269 //=========================================================================
270 // Cercle tangent : a un cercle Qualified1 (C1). +
271 // centre : sur une droite OnLine. +
272 // de rayon : Radius. +
274 // On initialise le tableau de solutions cirsol ainsi que tous les +
276 // On elimine en fonction du qualifieur les cas ne presentant pas de +
278 // On resoud l equation du second degre indiquant que le point de centre +
279 // recherche (xc,yc) est a une distance Radius du cercle C1 et +
280 // sur la droite OnLine. +
281 // Les solutions sont representees par les cercles : +
282 // - de centre Pntcen(xc,yc) +
283 // - de rayon Radius. +
284 //=========================================================================
286 Geom2dGcc_Circ2dTanOnRadGeo::
287 Geom2dGcc_Circ2dTanOnRadGeo (const GccEnt_QualifiedCirc& Qualified1,
288 const Geom2dAdaptor_Curve& OnCurv ,
289 const Standard_Real Radius ,
290 const Standard_Real Tolerance ):
292 //=========================================================================
293 // Initialisation des champs. +
294 //=========================================================================
306 //=========================================================================
308 //=========================================================================
310 gp_Dir2d dirx(1.0,0.0);
311 Standard_Real thefirst = -100000.;
312 Standard_Real thelast = 100000.;
313 Standard_Real firstparam;
314 Standard_Real lastparam;
315 Standard_Real Tol = Abs(Tolerance);
316 Standard_Integer nbrcote1=0;
317 WellDone = Standard_False;
319 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
320 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
321 GccEnt_BadQualifier::Raise();
324 TColStd_Array1OfReal cote1(1,2);
325 gp_Circ2d C1 = Qualified1.Qualified();
326 gp_Pnt2d center1(C1.Location());
327 Standard_Real R1 = C1.Radius();
330 Standard_NegativeValue::Raise();
333 if (Qualified1.IsEnclosed()) {
334 // ===========================
338 else if(Qualified1.IsOutside()) {
339 // ===============================
343 else if(Qualified1.IsUnqualified()) {
344 // ===================================
349 Geom2dInt_TheIntConicCurveOfGInter Intp;
350 for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
351 gp_Circ2d Circ(C1.XAxis(),R1 + cote1(jcote1));
352 IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol,
353 ElCLib::Value(2.*M_PI,Circ),2.*M_PI,Tol);
354 D1.SetEquivalentParameters(0.,2.*M_PI);
355 firstparam = Max(Geom2dGcc_CurveTool::FirstParameter(OnCurv),thefirst);
356 lastparam = Min(Geom2dGcc_CurveTool::LastParameter(OnCurv),thelast);
357 IntRes2d_Domain D2(Geom2dGcc_CurveTool::Value(OnCurv,firstparam),firstparam,Tol,
358 Geom2dGcc_CurveTool::Value(OnCurv,lastparam),lastparam,Tol);
359 Intp.Perform(Circ,D1,OnCurv,D2,Tol,Tol);
361 if (!Intp.IsEmpty()) {
362 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
364 gp_Pnt2d Center(Intp.Point(i).Value());
365 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
366 // =======================================================
367 Standard_Real distcc1 = Center.Distance(center1);
368 if (!Qualified1.IsUnqualified()) {
369 qualifier1(NbrSol) = Qualified1.Qualifier();
371 else if (Abs(distcc1+Radius-R1) < Tol) {
372 qualifier1(NbrSol) = GccEnt_enclosed;
374 else if (Abs(distcc1-R1-Radius) < Tol) {
375 qualifier1(NbrSol) = GccEnt_outside;
377 else { qualifier1(NbrSol) = GccEnt_enclosing; }
378 TheSame1(NbrSol) = 0;
379 pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
380 parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
381 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
383 pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),C1);
384 pntcen3(NbrSol) = Center;
387 WellDone = Standard_True;
393 //=========================================================================
394 // Cercle tangent : a un cercle Qualified1 (C1). +
395 // centre : sur une droite OnLine. +
396 // de rayon : Radius. +
398 // On initialise le tableau de solutions cirsol ainsi que tous les +
400 // On elimine en fonction du qualifieur les cas ne presentant pas de +
402 // On resoud l equation du second degre indiquant que le point de centre +
403 // recherche (xc,yc) est a une distance Radius du cercle C1 et +
404 // sur la droite OnLine. +
405 // Les solutions sont representees par les cercles : +
406 // - de centre Pntcen(xc,yc) +
407 // - de rayon Radius. +
408 //=========================================================================
410 Geom2dGcc_Circ2dTanOnRadGeo::
411 Geom2dGcc_Circ2dTanOnRadGeo (const GccEnt_QualifiedLin& Qualified1,
412 const Geom2dAdaptor_Curve& OnCurv ,
413 const Standard_Real Radius ,
414 const Standard_Real Tolerance ):
416 //=========================================================================
417 // Initialisation des champs. +
418 //=========================================================================
430 //=========================================================================
432 //=========================================================================
434 gp_Dir2d dirx(1.0,0.0);
435 Standard_Real thefirst = -100000.;
436 Standard_Real thelast = 100000.;
437 Standard_Real firstparam;
438 Standard_Real lastparam;
439 Standard_Real Tol = Abs(Tolerance);
440 WellDone = Standard_False;
442 if (!(Qualified1.IsEnclosed() ||
443 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
444 GccEnt_BadQualifier::Raise();
447 Standard_Integer nbrcote1=0;
448 TColStd_Array1OfReal cote1(1,2);
449 gp_Lin2d L1 = Qualified1.Qualified();
450 gp_Pnt2d origin1(L1.Location());
451 gp_Dir2d dir1(L1.Direction());
452 gp_Dir2d norm1(-dir1.Y(),dir1.X());
455 Standard_NegativeValue::Raise();
458 if (Qualified1.IsEnclosed()) {
459 // ===========================
463 else if(Qualified1.IsOutside()) {
464 // ===============================
468 else if(Qualified1.IsUnqualified()) {
469 // ===================================
474 Geom2dInt_TheIntConicCurveOfGInter Intp;
475 for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
476 gp_Pnt2d Point(dir1.XY()+cote1(jcote1)*norm1.XY());
477 gp_Lin2d Line(Point,dir1); // ligne avec deport.
479 firstparam = Max(Geom2dGcc_CurveTool::FirstParameter(OnCurv),thefirst);
480 lastparam = Min(Geom2dGcc_CurveTool::LastParameter(OnCurv),thelast);
481 IntRes2d_Domain D2(Geom2dGcc_CurveTool::Value(OnCurv,firstparam),firstparam,Tol,
482 Geom2dGcc_CurveTool::Value(OnCurv,lastparam),lastparam,Tol);
483 Intp.Perform(Line,D1,OnCurv,D2,Tol,Tol);
485 if (!Intp.IsEmpty()) {
486 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
488 gp_Pnt2d Center(Intp.Point(i).Value());
489 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
490 // =======================================================
491 gp_Dir2d dc1(origin1.XY()-Center.XY());
492 if (!Qualified1.IsUnqualified()) {
493 qualifier1(NbrSol) = Qualified1.Qualifier();
495 else if (dc1.Dot(norm1) > 0.0) {
496 qualifier1(NbrSol) = GccEnt_outside;
498 else { qualifier1(NbrSol) = GccEnt_enclosed; }
499 TheSame1(NbrSol) = 0;
500 pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
501 parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
502 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
504 pnttg1sol(NbrSol) = ElCLib::Value(pararg1(NbrSol),L1);
505 pntcen3(NbrSol) = Center;
508 WellDone = Standard_True;
514 //=========================================================================
515 // Cercle tangent : a un cercle Qualified1 (C1). +
516 // centre : sur une droite OnLine. +
517 // de rayon : Radius. +
519 // On initialise le tableau de solutions cirsol ainsi que tous les +
521 // On elimine en fonction du qualifieur les cas ne presentant pas de +
523 // On resoud l equation du second degre indiquant que le point de centre +
524 // recherche (xc,yc) est a une distance Radius du cercle C1 et +
525 // sur la droite OnLine. +
526 // Les solutions sont representees par les cercles : +
527 // - de centre Pntcen(xc,yc) +
528 // - de rayon Radius. +
529 //=========================================================================
531 Geom2dGcc_Circ2dTanOnRadGeo::
532 Geom2dGcc_Circ2dTanOnRadGeo (const Geom2dGcc_QCurve& Qualified1,
533 const Geom2dAdaptor_Curve& OnCurv ,
534 const Standard_Real Radius ,
535 const Standard_Real Tolerance ):
537 //=========================================================================
538 // Initialisation des champs. +
539 //=========================================================================
551 //=========================================================================
553 //=========================================================================
555 gp_Dir2d dirx(1.0,0.0);
556 Standard_Real thefirst = -100000.;
557 Standard_Real thelast = 100000.;
558 Standard_Real firstparam;
559 Standard_Real lastparam;
560 Standard_Real Tol = Abs(Tolerance);
561 Standard_Integer nbrcote1=0;
562 WellDone = Standard_False;
564 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
565 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
566 GccEnt_BadQualifier::Raise();
569 TColStd_Array1OfReal cote1(1,2);
570 Geom2dAdaptor_Curve Cu1 = Qualified1.Qualified();
573 Standard_NegativeValue::Raise();
576 if (Qualified1.IsEnclosed()) {
577 // ===========================
581 else if(Qualified1.IsOutside()) {
582 // ===============================
586 else if(Qualified1.IsUnqualified()) {
587 // ===================================
592 Geom2dInt_GInter Intp;
593 for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
594 Handle(Geom2dAdaptor_HCurve) HCu1 = new Geom2dAdaptor_HCurve(Cu1);
595 Adaptor3d_OffsetCurve C1(HCu1,cote1(jcote1));
596 firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C1),thefirst);
597 lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C1),thelast);
598 IntRes2d_Domain D1(Geom2dGcc_CurveToolGeo::Value(C1,firstparam),firstparam,Tol,
599 Geom2dGcc_CurveToolGeo::Value(C1,lastparam),lastparam,Tol);
600 Handle(Geom2dAdaptor_HCurve) HOnCurv = new Geom2dAdaptor_HCurve(OnCurv);
601 Adaptor3d_OffsetCurve C2(HOnCurv);
602 firstparam = Max(Geom2dGcc_CurveToolGeo::FirstParameter(C2),thefirst);
603 lastparam = Min(Geom2dGcc_CurveToolGeo::LastParameter(C2),thelast);
604 IntRes2d_Domain D2(Geom2dGcc_CurveToolGeo::Value(C2,firstparam),firstparam,Tol,
605 Geom2dGcc_CurveToolGeo::Value(C2,lastparam),lastparam,Tol);
606 Intp.Perform(C1,D1,C2,D2,Tol,Tol);
608 if (!Intp.IsEmpty()) {
609 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
611 gp_Pnt2d Center(Intp.Point(i).Value());
612 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
613 // =======================================================
614 qualifier1(NbrSol) = Qualified1.Qualifier();
615 TheSame1(NbrSol) = 0;
616 pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
617 parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
618 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
620 pnttg1sol(NbrSol) = gp_Pnt2d(Geom2dGcc_CurveTool::Value(Cu1,pararg1(NbrSol)));
621 pntcen3(NbrSol) = Center;
624 WellDone = Standard_True;
630 //=========================================================================
631 // Cercle tangent : a un cercle Qualified1 (C1). +
632 // centre : sur une droite OnLine. +
633 // de rayon : Radius. +
635 // On initialise le tableau de solutions cirsol ainsi que tous les +
637 // On elimine en fonction du qualifieur les cas ne presentant pas de +
639 // On resoud l equation du second degre indiquant que le point de centre +
640 // recherche (xc,yc) est a une distance Radius du cercle C1 et +
641 // sur la droite OnLine. +
642 // Les solutions sont representees par les cercles : +
643 // - de centre Pntcen(xc,yc) +
644 // - de rayon Radius. +
645 //=========================================================================
647 Geom2dGcc_Circ2dTanOnRadGeo::
648 Geom2dGcc_Circ2dTanOnRadGeo (const gp_Pnt2d& Point1 ,
649 const Geom2dAdaptor_Curve& OnCurv ,
650 const Standard_Real Radius ,
651 const Standard_Real Tolerance ):
653 //=========================================================================
654 // Initialisation des champs. +
655 //=========================================================================
667 //=========================================================================
669 //=========================================================================
671 gp_Dir2d dirx(1.0,0.0);
672 Standard_Real thefirst = -100000.;
673 Standard_Real thelast = 100000.;
674 Standard_Real firstparam;
675 Standard_Real lastparam;
676 Standard_Real Tol = Abs(Tolerance);
677 WellDone = Standard_False;
681 Standard_NegativeValue::Raise();
684 // gp_Dir2d Dir(-y1dir,x1dir);
685 gp_Circ2d Circ(gp_Ax2d(Point1,gp_Dir2d(1.,0.)),Radius);
686 IntRes2d_Domain D1(ElCLib::Value(0.,Circ), 0.,Tol,
687 ElCLib::Value(2.*M_PI,Circ),2*M_PI,Tol);
688 D1.SetEquivalentParameters(0.,2.*M_PI);
689 firstparam = Max(Geom2dGcc_CurveTool::FirstParameter(OnCurv),thefirst);
690 lastparam = Min(Geom2dGcc_CurveTool::LastParameter(OnCurv),thelast);
691 IntRes2d_Domain D2(Geom2dGcc_CurveTool::Value(OnCurv,firstparam),firstparam,Tol,
692 Geom2dGcc_CurveTool::Value(OnCurv,lastparam),lastparam,Tol);
693 Geom2dInt_TheIntConicCurveOfGInter Intp(Circ,D1,OnCurv,D2,Tol,Tol);
695 if (!Intp.IsEmpty()) {
696 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
698 gp_Pnt2d Center(Intp.Point(i).Value());
699 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
700 // =======================================================
701 qualifier1(NbrSol) = GccEnt_noqualifier;
702 TheSame1(NbrSol) = 0;
703 pararg1(NbrSol) = Intp.Point(i).ParamOnFirst();
704 parcen3(NbrSol) = Intp.Point(i).ParamOnSecond();
705 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
707 pnttg1sol(NbrSol) = Point1;
708 pntcen3(NbrSol) = Center;
710 WellDone = Standard_True;
716 //=========================================================================
718 Standard_Boolean Geom2dGcc_Circ2dTanOnRadGeo::
719 IsDone () const { return WellDone; }
721 Standard_Integer Geom2dGcc_Circ2dTanOnRadGeo::
722 NbSolutions () const { return NbrSol; }
724 gp_Circ2d Geom2dGcc_Circ2dTanOnRadGeo::
725 ThisSolution (const Standard_Integer Index) const
728 if (Index > NbrSol || Index <= 0)
729 Standard_OutOfRange::Raise();
731 return cirsol(Index);
734 void Geom2dGcc_Circ2dTanOnRadGeo::
735 WhichQualifier(const Standard_Integer Index ,
736 GccEnt_Position& Qualif1 ) const
738 if (!WellDone) { StdFail_NotDone::Raise(); }
739 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
741 Qualif1 = qualifier1(Index);
745 void Geom2dGcc_Circ2dTanOnRadGeo::
746 Tangency1 (const Standard_Integer Index,
747 Standard_Real& ParSol,
748 Standard_Real& ParArg,
749 gp_Pnt2d& PntSol) const{
751 StdFail_NotDone::Raise();
753 else if (Index <= 0 ||Index > NbrSol) {
754 Standard_OutOfRange::Raise();
757 ParSol = par1sol(Index);
758 ParArg = pararg1(Index);
759 PntSol = gp_Pnt2d(pnttg1sol(Index));
763 void Geom2dGcc_Circ2dTanOnRadGeo::
764 CenterOn3 (const Standard_Integer Index,
765 Standard_Real& ParArg,
766 gp_Pnt2d& PntSol) const {
768 StdFail_NotDone::Raise();
770 else if (Index <= 0 ||Index > NbrSol) {
771 Standard_OutOfRange::Raise();
774 ParArg = parcen3(Index);
775 PntSol = pnttg1sol(Index);
779 Standard_Boolean Geom2dGcc_Circ2dTanOnRadGeo::
780 IsTheSame1 (const Standard_Integer Index) const
782 if (!WellDone) StdFail_NotDone::Raise();
783 if (Index <= 0 ||Index > NbrSol) Standard_OutOfRange::Raise();
785 if (TheSame1(Index) == 0)
786 return Standard_False;
788 return Standard_True;