1 // Created on: 1991-09-24
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.
19 #include <GccAna_Circ2d2TanRad.hxx>
20 #include <GccEnt_BadQualifier.hxx>
21 #include <GccEnt_QualifiedCirc.hxx>
22 #include <GccEnt_QualifiedLin.hxx>
23 #include <gp_Ax2d.hxx>
24 #include <gp_Circ2d.hxx>
25 #include <gp_Lin2d.hxx>
26 #include <gp_Pnt2d.hxx>
27 #include <IntAna2d_AnaIntersection.hxx>
28 #include <IntAna2d_IntPoint.hxx>
29 #include <Standard_NegativeValue.hxx>
30 #include <Standard_OutOfRange.hxx>
31 #include <StdFail_NotDone.hxx>
33 // Circle passing by two points of given radius.
34 // ==============================================
35 //==============================================================================
36 // Solution of the equation of second degree showing that the center of the +
37 // circle is equidistant from two points. +
38 //==============================================================================
39 GccAna_Circ2d2TanRad::
40 GccAna_Circ2d2TanRad (const gp_Pnt2d& Point1 ,
41 const gp_Pnt2d& Point2 ,
42 const Standard_Real Radius ,
43 const Standard_Real Tolerance ):
57 gp_Dir2d dirx(1.0,0.0);
58 Standard_Real Tol = Abs(Tolerance);
60 WellDone = Standard_False;
61 if (Radius < 0.0) { throw Standard_NegativeValue(); }
63 if (Point1.Distance(Point2)-Radius*2.0 > Tol) { WellDone = Standard_True; }
65 if (Point1.Distance(Point2)-Radius*2.0 >0.0) {
66 WellDone = Standard_True;
68 gp_Ax2d axe(gp_Pnt2d(0.5*(Point1.XY()+Point2.XY())),dirx);
69 cirsol(1) = gp_Circ2d(axe,Radius);
70 // =================================
71 qualifier1(1) = GccEnt_noqualifier;
72 qualifier2(1) = GccEnt_noqualifier;
75 pnttg1sol(1) = Point1;
76 pnttg2sol(1) = Point2;
79 gp_Circ2d C1(gp_Ax2d(Point1,dirx),Radius);
80 gp_Circ2d C2(gp_Ax2d(Point2,dirx),Radius);
81 IntAna2d_AnaIntersection Intp(C1,C2);
83 if (!Intp.IsEmpty()) {
84 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
86 gp_Pnt2d Center(Intp.Point(i).Value());
87 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
88 // =======================================================
89 qualifier1(NbrSol) = GccEnt_noqualifier;
90 qualifier2(NbrSol) = GccEnt_noqualifier;
93 pnttg1sol(NbrSol) = Point1;
94 pnttg2sol(NbrSol) = Point2;
97 WellDone = Standard_True;
102 for (Standard_Integer i = 1 ; i <= NbrSol ; i++) {
105 par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
106 par2sol(i)=ElCLib::Parameter(cirsol(i),pnttg2sol(i));