1 // Created on: 1992-01-02
2 // Created by: Remi GILET
3 // Copyright (c) 1992-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_Circ2d2TanOn.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_Dir2d.hxx>
26 #include <gp_Lin2d.hxx>
27 #include <gp_Pnt2d.hxx>
28 #include <IntAna2d_AnaIntersection.hxx>
29 #include <IntAna2d_IntPoint.hxx>
30 #include <Standard_OutOfRange.hxx>
31 #include <StdFail_NotDone.hxx>
33 //=========================================================================
34 // Creation of a circle passing by : 2 points Point1 and Point2. +
35 // Centered on : 1 straight line OnLine. +
36 // with a Tolerance of precision : Tolerance. +
38 // Create L1 straight line of points equidistant from Point1 and Point2. +
39 // Then create solutions cirsol such as : +
40 // cirsol is all circle with center at the intersections of +
41 // L1 with OnLine and the radius the distance between Point1 and the point +
42 // calculated above. +
43 //=========================================================================
45 GccAna_Circ2d2TanOn (const gp_Pnt2d& Point1 ,
46 const gp_Pnt2d& Point2 ,
47 const gp_Lin2d& OnLine ,
48 const Standard_Real Tolerance ):
65 WellDone = Standard_False;
69 Standard_Real dist = Point1.Distance(Point2);
70 if (dist < Abs(Tolerance)) { WellDone = Standard_True; }
72 gp_Lin2d L1(gp_Pnt2d((Point1.XY()+Point2.XY())/2.0),
73 gp_Dir2d(Point1.Y()-Point2.Y(),Point2.X()-Point1.X()));
74 IntAna2d_AnaIntersection Intp(L1,OnLine);
76 if (!Intp.IsEmpty()) {
77 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
79 gp_Ax2d axe(Intp.Point(i).Value(),dirx);
80 cirsol(NbrSol)=gp_Circ2d(axe,Point1.Distance(Intp.Point(i).Value()));
81 // ====================================================================
82 qualifier1(NbrSol) = GccEnt_noqualifier;
83 qualifier2(NbrSol) = GccEnt_noqualifier;
84 pnttg1sol(NbrSol) = Point1;
85 pnttg2sol(NbrSol) = Point2;
86 pntcen(NbrSol) = cirsol(NbrSol).Location();
89 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg1sol(NbrSol));
90 par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),pnttg2sol(NbrSol));
91 parcen3(NbrSol)=ElCLib::Parameter(OnLine,pntcen(NbrSol));
94 WellDone = Standard_True;