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 <gp_Ax2d.hxx>
22 #include <gp_Circ2d.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <IntAna2d_AnaIntersection.hxx>
25 #include <IntAna2d_IntPoint.hxx>
26 #include <Standard_NegativeValue.hxx>
28 // Circle passing by two points of given radius.
29 // ==============================================
30 //==============================================================================
31 // Solution of the equation of second degree showing that the center of the +
32 // circle is equidistant from two points. +
33 //==============================================================================
34 GccAna_Circ2d2TanRad::
35 GccAna_Circ2d2TanRad (const gp_Pnt2d& Point1 ,
36 const gp_Pnt2d& Point2 ,
37 const Standard_Real Radius ,
38 const Standard_Real Tolerance ):
52 gp_Dir2d dirx(1.0,0.0);
53 Standard_Real Tol = Abs(Tolerance);
55 WellDone = Standard_False;
56 if (Radius < 0.0) { throw Standard_NegativeValue(); }
58 if (Point1.Distance(Point2)-Radius*2.0 > Tol) { WellDone = Standard_True; }
60 if (Point1.Distance(Point2)-Radius*2.0 >0.0) {
61 WellDone = Standard_True;
63 gp_Ax2d axe(gp_Pnt2d(0.5*(Point1.XY()+Point2.XY())),dirx);
64 cirsol(1) = gp_Circ2d(axe,Radius);
65 // =================================
66 qualifier1(1) = GccEnt_noqualifier;
67 qualifier2(1) = GccEnt_noqualifier;
70 pnttg1sol(1) = Point1;
71 pnttg2sol(1) = Point2;
74 gp_Circ2d C1(gp_Ax2d(Point1,dirx),Radius);
75 gp_Circ2d C2(gp_Ax2d(Point2,dirx),Radius);
76 IntAna2d_AnaIntersection Intp(C1,C2);
78 if (!Intp.IsEmpty()) {
79 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
81 gp_Pnt2d Center(Intp.Point(i).Value());
82 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
83 // =======================================================
84 qualifier1(NbrSol) = GccEnt_noqualifier;
85 qualifier2(NbrSol) = GccEnt_noqualifier;
88 pnttg1sol(NbrSol) = Point1;
89 pnttg2sol(NbrSol) = Point2;
92 WellDone = Standard_True;
97 for (Standard_Integer i = 1 ; i <= NbrSol ; i++) {
100 par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
101 par2sol(i)=ElCLib::Parameter(cirsol(i),pnttg2sol(i));