1 // Created on: 1992-10-21
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.
17 #include <Geom2dGcc_Circ2dTanOnRad.ixx>
18 #include <Geom2dAdaptor_Curve.hxx>
19 #include <GccAna_Circ2dTanOnRad.hxx>
20 #include <Geom2dGcc_MyCirc2dTanOnRad.hxx>
21 #include <Geom2dGcc_QCurve.hxx>
22 #include <GccEnt_BadQualifier.hxx>
23 #include <Geom2d_Circle.hxx>
24 #include <Geom2d_Line.hxx>
25 #include <GccEnt_QualifiedCirc.hxx>
26 #include <GccEnt_QualifiedLin.hxx>
27 #include <StdFail_NotDone.hxx>
28 #include <Standard_NegativeValue.hxx>
29 #include <Standard_OutOfRange.hxx>
31 Geom2dGcc_Circ2dTanOnRad::
32 Geom2dGcc_Circ2dTanOnRad (const Geom2dGcc_QualifiedCurve& Qualified1 ,
33 const Geom2dAdaptor_Curve& OnCurve ,
34 const Standard_Real Radius ,
35 const Standard_Real Tolerance ):
46 Standard_NegativeValue::Raise();
49 Geom2dAdaptor_Curve C1 = Qualified1.Qualified();
50 GeomAbs_CurveType Type1 = C1.GetType();
51 GeomAbs_CurveType Type2 = OnCurve.GetType();
52 Handle(Geom2d_Curve) CC1 = C1.Curve();
53 Handle(Geom2d_Curve) Con = OnCurve.Curve();
55 //=============================================================================
57 //=============================================================================
60 if ((Type1 == GeomAbs_Line || Type1 == GeomAbs_Circle) &&
61 (Type2 == GeomAbs_Line || Type2 == GeomAbs_Circle)) {
62 if (Type1 == GeomAbs_Circle) {
63 Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1);
64 gp_Circ2d c1(CCC1->Circ2d());
65 GccEnt_QualifiedCirc Qc1=GccEnt_QualifiedCirc(c1,
66 Qualified1.Qualifier());
67 if (Type2 == GeomAbs_Circle) {
68 Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con);
69 gp_Circ2d con(CCon->Circ2d());
70 GccAna_Circ2dTanOnRad Circ(Qc1,con,Radius,Tolerance);
71 WellDone = Circ.IsDone();
72 NbrSol = Circ.NbSolutions();
76 Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
77 gp_Lin2d lon(LLon->Lin2d());
78 GccAna_Circ2dTanOnRad Circ(Qc1,lon,Radius,Tolerance);
79 WellDone = Circ.IsDone();
80 NbrSol = Circ.NbSolutions();
85 Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1);
86 gp_Lin2d l1(LL1->Lin2d());
87 GccEnt_QualifiedLin Ql1=GccEnt_QualifiedLin(l1,Qualified1.Qualifier());
88 if (Type2 == GeomAbs_Circle) {
89 Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con);
90 gp_Circ2d con(CCon->Circ2d());
91 GccAna_Circ2dTanOnRad Circ(Ql1,con,Radius,Tolerance);
92 WellDone = Circ.IsDone();
93 NbrSol = Circ.NbSolutions();
97 Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
98 gp_Lin2d lon(LLon->Lin2d());
99 GccAna_Circ2dTanOnRad Circ(Ql1,lon,Radius,Tolerance);
100 WellDone = Circ.IsDone();
101 NbrSol = Circ.NbSolutions();
107 //=============================================================================
109 //=============================================================================
112 if (Type1 == GeomAbs_Circle) {
113 Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1);
114 gp_Circ2d c1(CCC1->Circ2d());
115 GccEnt_QualifiedCirc Qc1=GccEnt_QualifiedCirc(c1,
116 Qualified1.Qualifier());
117 Geom2dGcc_MyCirc2dTanOnRad CircGeo(Qc1,OnCurve,Radius,Tolerance);
118 WellDone = CircGeo.IsDone();
119 NbrSol = CircGeo.NbSolutions();
122 else if (Type1 == GeomAbs_Line) {
123 Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1);
124 gp_Lin2d l1(LL1->Lin2d());
125 GccEnt_QualifiedLin Ql1=GccEnt_QualifiedLin(l1,Qualified1.Qualifier());
126 Geom2dGcc_MyCirc2dTanOnRad CircGeo(Ql1,OnCurve,Radius,Tolerance);
127 WellDone = CircGeo.IsDone();
128 NbrSol = CircGeo.NbSolutions();
132 Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier());
133 Geom2dGcc_MyCirc2dTanOnRad CircGeo(Qc1,OnCurve,Radius,Tolerance);
134 WellDone = CircGeo.IsDone();
135 NbrSol = CircGeo.NbSolutions();
142 Geom2dGcc_Circ2dTanOnRad::
143 Geom2dGcc_Circ2dTanOnRad (const Handle(Geom2d_Point&) Point1 ,
144 const Geom2dAdaptor_Curve& OnCurve ,
145 const Standard_Real Radius ,
146 const Standard_Real Tolerance ):
157 Standard_NegativeValue::Raise();
160 gp_Pnt2d point1(Point1->Pnt2d());
161 GeomAbs_CurveType Type2 = OnCurve.GetType();
162 Handle(Geom2d_Curve) Con = OnCurve.Curve();
164 //=============================================================================
166 //=============================================================================
169 if (Type2 == GeomAbs_Line || Type2 == GeomAbs_Circle) {
170 if (Type2 == GeomAbs_Circle) {
171 Handle(Geom2d_Circle) CCon = Handle(Geom2d_Circle)::DownCast(Con);
172 gp_Circ2d con(CCon->Circ2d());
173 GccAna_Circ2dTanOnRad Circ(point1,con,Radius,Tolerance);
174 WellDone = Circ.IsDone();
175 NbrSol = Circ.NbSolutions();
179 Handle(Geom2d_Line) LLon = Handle(Geom2d_Line)::DownCast(Con);
180 gp_Lin2d lon(LLon->Lin2d());
181 GccAna_Circ2dTanOnRad Circ(point1,lon,Radius,Tolerance);
182 WellDone = Circ.IsDone();
183 NbrSol = Circ.NbSolutions();
188 //=============================================================================
190 //=============================================================================
193 Geom2dGcc_MyCirc2dTanOnRad CircGeo(point1,OnCurve,Radius,Tolerance);
194 WellDone = CircGeo.IsDone();
195 NbrSol = CircGeo.NbSolutions();
201 void Geom2dGcc_Circ2dTanOnRad::Results(const GccAna_Circ2dTanOnRad& Circ)
203 for (Standard_Integer j = 1; j <= NbrSol; j++) {
204 cirsol(j) = Circ.ThisSolution(j);
205 if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; }
206 else {TheSame1(j) = 0; }
207 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
208 Circ.CenterOn3(j,parcen3(j),pntcen3(j));
209 Circ.WhichQualifier(j,qualifier1(j));
213 void Geom2dGcc_Circ2dTanOnRad::Results(const Geom2dGcc_MyCirc2dTanOnRad& Circ)
215 for (Standard_Integer j = 1; j <= NbrSol; j++) {
216 cirsol(j) = Circ.ThisSolution(j);
217 if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; }
218 else {TheSame1(j) = 0; }
219 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
220 Circ.CenterOn3(j,parcen3(j),pntcen3(j));
221 Circ.WhichQualifier(j,qualifier1(j));
225 Standard_Boolean Geom2dGcc_Circ2dTanOnRad::
226 IsDone () const { return WellDone; }
228 Standard_Integer Geom2dGcc_Circ2dTanOnRad::
234 gp_Circ2d Geom2dGcc_Circ2dTanOnRad::
235 ThisSolution (const Standard_Integer Index) const
237 if (!WellDone) { StdFail_NotDone::Raise(); }
238 if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
239 return cirsol(Index);
242 void Geom2dGcc_Circ2dTanOnRad::
243 WhichQualifier (const Standard_Integer Index,
244 GccEnt_Position& Qualif1) const
246 if (!WellDone) { StdFail_NotDone::Raise(); }
247 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
248 else { Qualif1 = qualifier1(Index); }
251 void Geom2dGcc_Circ2dTanOnRad::
252 Tangency1 (const Standard_Integer Index,
253 Standard_Real& ParSol,
254 Standard_Real& ParArg,
255 gp_Pnt2d& PntSol) const
257 if (!WellDone) { StdFail_NotDone::Raise(); }
258 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
260 if (TheSame1(Index) == 0) {
261 ParSol = par1sol(Index);
262 ParArg = pararg1(Index);
263 PntSol = pnttg1sol(Index);
265 else { StdFail_NotDone::Raise(); }
269 void Geom2dGcc_Circ2dTanOnRad::
270 CenterOn3 (const Standard_Integer Index,
271 Standard_Real& ParArg,
272 gp_Pnt2d& PntSol) const
274 if (!WellDone) { StdFail_NotDone::Raise(); }
275 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
277 ParArg = parcen3(Index);
278 PntSol = pntcen3(Index);
282 Standard_Boolean Geom2dGcc_Circ2dTanOnRad::
283 IsTheSame1 (const Standard_Integer Index) const
285 if (!WellDone) { StdFail_NotDone::Raise(); }
286 if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
287 if (TheSame1(Index) == 0) { return Standard_False; }
288 return Standard_True;