1 // Created on: 1992-10-26
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.
18 #include <GccAna_Circ2dTanCen.hxx>
19 #include <GccEnt_BadQualifier.hxx>
20 #include <GccEnt_QualifiedCirc.hxx>
21 #include <GccEnt_QualifiedLin.hxx>
22 #include <Geom2d_Circle.hxx>
23 #include <Geom2d_Line.hxx>
24 #include <Geom2d_Point.hxx>
25 #include <Geom2dAdaptor_Curve.hxx>
26 #include <Geom2dGcc_Circ2dTanCen.hxx>
27 #include <Geom2dGcc_Circ2dTanCenGeo.hxx>
28 #include <Geom2dGcc_QCurve.hxx>
29 #include <Geom2dGcc_QualifiedCurve.hxx>
30 #include <gp_Circ2d.hxx>
31 #include <gp_Pnt2d.hxx>
32 #include <Standard_OutOfRange.hxx>
33 #include <StdFail_NotDone.hxx>
35 Geom2dGcc_Circ2dTanCen::
36 Geom2dGcc_Circ2dTanCen (const Geom2dGcc_QualifiedCurve& Qualified1 ,
37 const Handle(Geom2d_Point)& PCenter ,
38 const Standard_Real Tolerance ):
46 Geom2dAdaptor_Curve C1 = Qualified1.Qualified();
47 Handle(Geom2d_Curve) CC1 = C1.Curve();
48 GeomAbs_CurveType Type1 = C1.GetType();
50 //=============================================================================
52 //=============================================================================
54 gp_Pnt2d pcenter(PCenter->Pnt2d());
56 if ((Type1 == GeomAbs_Line || Type1 == GeomAbs_Circle)) {
57 if (Type1 == GeomAbs_Circle) {
58 Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1);
59 gp_Circ2d c1(CCC1->Circ2d());
60 GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier());
61 GccAna_Circ2dTanCen Circ(Qc1,pcenter,Tolerance);
62 WellDone = Circ.IsDone();
63 NbrSol = Circ.NbSolutions();
64 for (Standard_Integer j = 1; j <= NbrSol; j++) {
65 cirsol(j) = Circ.ThisSolution(j);
66 Circ.WhichQualifier(j,qualifier1(j));
67 if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; }
68 else {TheSame1(j) = 0; }
69 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
73 Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1);
74 gp_Lin2d l1(LL1->Lin2d());
75 GccAna_Circ2dTanCen Circ(l1,pcenter);
76 WellDone = Circ.IsDone();
77 NbrSol = Circ.NbSolutions();
78 for (Standard_Integer j = 1; j <= NbrSol; j++) {
79 cirsol(j) = Circ.ThisSolution(j);
80 Circ.WhichQualifier(j,qualifier1(j));
81 if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; }
82 else {TheSame1(j) = 0; }
83 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
88 //=============================================================================
90 //=============================================================================
93 Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier());
94 Geom2dGcc_Circ2dTanCenGeo Circ(Qc1,pcenter,Tolerance);
95 WellDone = Circ.IsDone();
96 NbrSol = Circ.NbSolutions();
97 for (Standard_Integer j = 1; j <= NbrSol; j++) {
98 cirsol(j) = Circ.ThisSolution(j);
100 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
101 Circ.WhichQualifier(j,qualifier1(j));
106 Standard_Boolean Geom2dGcc_Circ2dTanCen::
107 IsDone () const { return WellDone; }
109 Standard_Integer Geom2dGcc_Circ2dTanCen::
115 gp_Circ2d Geom2dGcc_Circ2dTanCen::
116 ThisSolution (const Standard_Integer Index) const
118 if (!WellDone) { throw StdFail_NotDone(); }
119 if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); }
120 return cirsol(Index);
123 void Geom2dGcc_Circ2dTanCen::
124 WhichQualifier(const Standard_Integer Index,
125 GccEnt_Position& Qualif1) const
127 if (!WellDone) { throw StdFail_NotDone(); }
128 else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); }
129 else { Qualif1 = qualifier1(Index); }
132 void Geom2dGcc_Circ2dTanCen::
133 Tangency1 (const Standard_Integer Index,
134 Standard_Real& ParSol,
135 Standard_Real& ParArg,
136 gp_Pnt2d& PntSol) const
138 if (!WellDone) { throw StdFail_NotDone(); }
139 else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); }
141 if (TheSame1(Index) == 0) {
142 ParSol = par1sol(Index);
143 ParArg = pararg1(Index);
144 PntSol = pnttg1sol(Index);
146 else { throw StdFail_NotDone(); }
150 Standard_Boolean Geom2dGcc_Circ2dTanCen::
151 IsTheSame1 (const Standard_Integer Index) const
153 if (!WellDone) { throw StdFail_NotDone(); }
154 if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); }
155 if (TheSame1(Index) == 0) { return Standard_False; }
156 return Standard_True;