b311480e |
1 | // Created on: 1992-10-26 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <Geom2dGcc_Circ2dTanCen.ixx> |
18 | #include <Geom2dAdaptor_Curve.hxx> |
19 | #include <GccAna_Circ2dTanCen.hxx> |
578ce4be |
20 | #include <Geom2dGcc_Circ2dTanCenGeo.hxx> |
0b85f9a6 |
21 | #include <Geom2dGcc_QCurve.hxx> |
7fd59977 |
22 | #include <GccEnt_BadQualifier.hxx> |
23 | #include <Geom2d_Circle.hxx> |
24 | #include <Geom2d_Line.hxx> |
c04c30b3 |
25 | #include <Geom2d_Point.hxx> |
7fd59977 |
26 | #include <GccEnt_QualifiedCirc.hxx> |
27 | #include <GccEnt_QualifiedLin.hxx> |
28 | #include <StdFail_NotDone.hxx> |
29 | |
30 | Geom2dGcc_Circ2dTanCen:: |
31 | Geom2dGcc_Circ2dTanCen (const Geom2dGcc_QualifiedCurve& Qualified1 , |
c04c30b3 |
32 | const Handle(Geom2d_Point)& PCenter , |
7fd59977 |
33 | const Standard_Real Tolerance ): |
34 | cirsol(1,2) , |
35 | qualifier1(1,2), |
36 | TheSame1(1,2) , |
37 | pnttg1sol(1,2), |
38 | par1sol(1,2) , |
39 | pararg1(1,2) |
40 | { |
41 | Geom2dAdaptor_Curve C1 = Qualified1.Qualified(); |
42 | Handle(Geom2d_Curve) CC1 = C1.Curve(); |
43 | GeomAbs_CurveType Type1 = C1.GetType(); |
44 | |
45 | //============================================================================= |
46 | // Appel a GccAna. + |
47 | //============================================================================= |
48 | |
49 | gp_Pnt2d pcenter(PCenter->Pnt2d()); |
50 | NbrSol = 0; |
51 | if ((Type1 == GeomAbs_Line || Type1 == GeomAbs_Circle)) { |
52 | if (Type1 == GeomAbs_Circle) { |
53 | Handle(Geom2d_Circle) CCC1 = Handle(Geom2d_Circle)::DownCast(CC1); |
54 | gp_Circ2d c1(CCC1->Circ2d()); |
55 | GccEnt_QualifiedCirc Qc1(c1,Qualified1.Qualifier()); |
56 | GccAna_Circ2dTanCen Circ(Qc1,pcenter,Tolerance); |
57 | WellDone = Circ.IsDone(); |
58 | NbrSol = Circ.NbSolutions(); |
59 | for (Standard_Integer j = 1; j <= NbrSol; j++) { |
60 | cirsol(j) = Circ.ThisSolution(j); |
61 | Circ.WhichQualifier(j,qualifier1(j)); |
62 | if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; } |
63 | else {TheSame1(j) = 0; } |
64 | Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j)); |
65 | } |
66 | } |
67 | else { |
68 | Handle(Geom2d_Line) LL1 = Handle(Geom2d_Line)::DownCast(CC1); |
69 | gp_Lin2d l1(LL1->Lin2d()); |
70 | GccAna_Circ2dTanCen Circ(l1,pcenter); |
71 | WellDone = Circ.IsDone(); |
72 | NbrSol = Circ.NbSolutions(); |
73 | for (Standard_Integer j = 1; j <= NbrSol; j++) { |
74 | cirsol(j) = Circ.ThisSolution(j); |
75 | Circ.WhichQualifier(j,qualifier1(j)); |
76 | if (Circ.IsTheSame1(j)) { TheSame1(j) = 1; } |
77 | else {TheSame1(j) = 0; } |
78 | Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j)); |
79 | } |
80 | } |
81 | } |
82 | |
83 | //============================================================================= |
84 | // Appel a GccGeo. + |
85 | //============================================================================= |
86 | |
87 | else { |
0b85f9a6 |
88 | Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); |
578ce4be |
89 | Geom2dGcc_Circ2dTanCenGeo Circ(Qc1,pcenter,Tolerance); |
7fd59977 |
90 | WellDone = Circ.IsDone(); |
91 | NbrSol = Circ.NbSolutions(); |
92 | for (Standard_Integer j = 1; j <= NbrSol; j++) { |
93 | cirsol(j) = Circ.ThisSolution(j); |
94 | TheSame1(j) = 0; |
95 | Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j)); |
96 | Circ.WhichQualifier(j,qualifier1(j)); |
97 | } |
98 | } |
99 | } |
100 | |
101 | Standard_Boolean Geom2dGcc_Circ2dTanCen:: |
102 | IsDone () const { return WellDone; } |
103 | |
104 | Standard_Integer Geom2dGcc_Circ2dTanCen:: |
105 | NbSolutions () const |
106 | { |
107 | return NbrSol; |
108 | } |
109 | |
110 | gp_Circ2d Geom2dGcc_Circ2dTanCen:: |
111 | ThisSolution (const Standard_Integer Index) const |
112 | { |
113 | if (!WellDone) { StdFail_NotDone::Raise(); } |
114 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
115 | return cirsol(Index); |
116 | } |
117 | |
118 | void Geom2dGcc_Circ2dTanCen:: |
119 | WhichQualifier(const Standard_Integer Index, |
120 | GccEnt_Position& Qualif1) const |
121 | { |
122 | if (!WellDone) { StdFail_NotDone::Raise(); } |
123 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
124 | else { Qualif1 = qualifier1(Index); } |
125 | } |
126 | |
127 | void Geom2dGcc_Circ2dTanCen:: |
128 | Tangency1 (const Standard_Integer Index, |
129 | Standard_Real& ParSol, |
130 | Standard_Real& ParArg, |
131 | gp_Pnt2d& PntSol) const |
132 | { |
133 | if (!WellDone) { StdFail_NotDone::Raise(); } |
134 | else if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
135 | else { |
136 | if (TheSame1(Index) == 0) { |
137 | ParSol = par1sol(Index); |
138 | ParArg = pararg1(Index); |
139 | PntSol = pnttg1sol(Index); |
140 | } |
141 | else { StdFail_NotDone::Raise(); } |
142 | } |
143 | } |
144 | |
145 | Standard_Boolean Geom2dGcc_Circ2dTanCen:: |
146 | IsTheSame1 (const Standard_Integer Index) const |
147 | { |
148 | if (!WellDone) { StdFail_NotDone::Raise(); } |
149 | if (Index <= 0 ||Index > NbrSol) { Standard_OutOfRange::Raise(); } |
150 | if (TheSame1(Index) == 0) { return Standard_False; } |
151 | return Standard_True; |
152 | } |
153 | |