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.
17 #include <Geom2dGcc_Circ2dTanCen.ixx>
18 #include <Geom2dAdaptor_Curve.hxx>
19 #include <GccAna_Circ2dTanCen.hxx>
20 #include <Geom2dGcc_MyCirc2dTanCen.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>
29 Geom2dGcc_Circ2dTanCen::
30 Geom2dGcc_Circ2dTanCen (const Geom2dGcc_QualifiedCurve& Qualified1 ,
31 const Handle(Geom2d_Point&) PCenter ,
32 const Standard_Real Tolerance ):
40 Geom2dAdaptor_Curve C1 = Qualified1.Qualified();
41 Handle(Geom2d_Curve) CC1 = C1.Curve();
42 GeomAbs_CurveType Type1 = C1.GetType();
44 //=============================================================================
46 //=============================================================================
48 gp_Pnt2d pcenter(PCenter->Pnt2d());
50 if ((Type1 == GeomAbs_Line || Type1 == GeomAbs_Circle)) {
51 if (Type1 == GeomAbs_Circle) {
52 Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1);
53 gp_Circ2d c1(CCC1->Circ2d());
54 GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier());
55 GccAna_Circ2dTanCen Circ(Qc1,pcenter,Tolerance);
56 WellDone = Circ.IsDone();
57 NbrSol = Circ.NbSolutions();
58 for (Standard_Integer j = 1; j <= NbrSol; j++) {
59 cirsol(j) = Circ.ThisSolution(j);
60 Circ.WhichQualifier(j,qualifier1(j));
61 if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; }
62 else {TheSame1(j) = 0; }
63 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
67 Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1);
68 gp_Lin2d l1(LL1->Lin2d());
69 GccAna_Circ2dTanCen Circ(l1,pcenter);
70 WellDone = Circ.IsDone();
71 NbrSol = Circ.NbSolutions();
72 for (Standard_Integer j = 1; j <= NbrSol; j++) {
73 cirsol(j) = Circ.ThisSolution(j);
74 Circ.WhichQualifier(j,qualifier1(j));
75 if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; }
76 else {TheSame1(j) = 0; }
77 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
82 //=============================================================================
84 //=============================================================================
87 Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier());
88 Geom2dGcc_MyCirc2dTanCen Circ(Qc1,pcenter,Tolerance);
89 WellDone = Circ.IsDone();
90 NbrSol = Circ.NbSolutions();
91 for (Standard_Integer j = 1; j <= NbrSol; j++) {
92 cirsol(j) = Circ.ThisSolution(j);
94 Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j));
95 Circ.WhichQualifier(j,qualifier1(j));
100 Standard_Boolean Geom2dGcc_Circ2dTanCen::
101 IsDone () const { return WellDone; }
103 Standard_Integer Geom2dGcc_Circ2dTanCen::
109 gp_Circ2d Geom2dGcc_Circ2dTanCen::
110 ThisSolution (const Standard_Integer Index) const
112 if (!WellDone) { StdFail_NotDone::Raise(); }
113 if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
114 return cirsol(Index);
117 void Geom2dGcc_Circ2dTanCen::
118 WhichQualifier(const Standard_Integer Index,
119 GccEnt_Position& Qualif1) const
121 if (!WellDone) { StdFail_NotDone::Raise(); }
122 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
123 else { Qualif1 = qualifier1(Index); }
126 void Geom2dGcc_Circ2dTanCen::
127 Tangency1 (const Standard_Integer Index,
128 Standard_Real& ParSol,
129 Standard_Real& ParArg,
130 gp_Pnt2d& PntSol) const
132 if (!WellDone) { StdFail_NotDone::Raise(); }
133 else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
135 if (TheSame1(Index) == 0) {
136 ParSol = par1sol(Index);
137 ParArg = pararg1(Index);
138 PntSol = pnttg1sol(Index);
140 else { StdFail_NotDone::Raise(); }
144 Standard_Boolean Geom2dGcc_Circ2dTanCen::
145 IsTheSame1 (const Standard_Integer Index) const
147 if (!WellDone) { StdFail_NotDone::Raise(); }
148 if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); }
149 if (TheSame1(Index) == 0) { return Standard_False; }
150 return Standard_True;