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 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <GccAna_Circ2dTanCen.hxx> |
7fd59977 |
19 | #include <GccEnt_BadQualifier.hxx> |
42cf5bc1 |
20 | #include <GccEnt_QualifiedCirc.hxx> |
21 | #include <GccEnt_QualifiedLin.hxx> |
7fd59977 |
22 | #include <Geom2d_Circle.hxx> |
23 | #include <Geom2d_Line.hxx> |
c04c30b3 |
24 | #include <Geom2d_Point.hxx> |
42cf5bc1 |
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> |
7fd59977 |
33 | #include <StdFail_NotDone.hxx> |
34 | |
35 | Geom2dGcc_Circ2dTanCen:: |
36 | Geom2dGcc_Circ2dTanCen (const Geom2dGcc_QualifiedCurve& Qualified1 , |
c04c30b3 |
37 | const Handle(Geom2d_Point)& PCenter , |
7fd59977 |
38 | const Standard_Real Tolerance ): |
39 | cirsol(1,2) , |
40 | qualifier1(1,2), |
41 | TheSame1(1,2) , |
42 | pnttg1sol(1,2), |
43 | par1sol(1,2) , |
44 | pararg1(1,2) |
45 | { |
46 | Geom2dAdaptor_Curve C1 = Qualified1.Qualified(); |
47 | Handle(Geom2d_Curve) CC1 = C1.Curve(); |
48 | GeomAbs_CurveType Type1 = C1.GetType(); |
49 | |
50 | //============================================================================= |
51 | // Appel a GccAna. + |
52 | //============================================================================= |
53 | |
54 | gp_Pnt2d pcenter(PCenter->Pnt2d()); |
55 | NbrSol = 0; |
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)); |
70 | } |
71 | } |
72 | else { |
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)); |
84 | } |
85 | } |
86 | } |
87 | |
88 | //============================================================================= |
89 | // Appel a GccGeo. + |
90 | //============================================================================= |
91 | |
92 | else { |
0b85f9a6 |
93 | Geom2dGcc_QCurve Qc1(C1,Qualified1.Qualifier()); |
578ce4be |
94 | Geom2dGcc_Circ2dTanCenGeo Circ(Qc1,pcenter,Tolerance); |
7fd59977 |
95 | WellDone = Circ.IsDone(); |
96 | NbrSol = Circ.NbSolutions(); |
97 | for (Standard_Integer j = 1; j <= NbrSol; j++) { |
98 | cirsol(j) = Circ.ThisSolution(j); |
99 | TheSame1(j) = 0; |
100 | Circ.Tangency1(j,par1sol(j),pararg1(j),pnttg1sol(j)); |
101 | Circ.WhichQualifier(j,qualifier1(j)); |
102 | } |
103 | } |
104 | } |
105 | |
106 | Standard_Boolean Geom2dGcc_Circ2dTanCen:: |
107 | IsDone () const { return WellDone; } |
108 | |
109 | Standard_Integer Geom2dGcc_Circ2dTanCen:: |
110 | NbSolutions () const |
111 | { |
112 | return NbrSol; |
113 | } |
114 | |
115 | gp_Circ2d Geom2dGcc_Circ2dTanCen:: |
116 | ThisSolution (const Standard_Integer Index) const |
117 | { |
9775fa61 |
118 | if (!WellDone) { throw StdFail_NotDone(); } |
119 | if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
120 | return cirsol(Index); |
121 | } |
122 | |
123 | void Geom2dGcc_Circ2dTanCen:: |
124 | WhichQualifier(const Standard_Integer Index, |
125 | GccEnt_Position& Qualif1) const |
126 | { |
9775fa61 |
127 | if (!WellDone) { throw StdFail_NotDone(); } |
128 | else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
129 | else { Qualif1 = qualifier1(Index); } |
130 | } |
131 | |
132 | void Geom2dGcc_Circ2dTanCen:: |
133 | Tangency1 (const Standard_Integer Index, |
134 | Standard_Real& ParSol, |
135 | Standard_Real& ParArg, |
136 | gp_Pnt2d& PntSol) const |
137 | { |
9775fa61 |
138 | if (!WellDone) { throw StdFail_NotDone(); } |
139 | else if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
140 | else { |
141 | if (TheSame1(Index) == 0) { |
142 | ParSol = par1sol(Index); |
143 | ParArg = pararg1(Index); |
144 | PntSol = pnttg1sol(Index); |
145 | } |
9775fa61 |
146 | else { throw StdFail_NotDone(); } |
7fd59977 |
147 | } |
148 | } |
149 | |
150 | Standard_Boolean Geom2dGcc_Circ2dTanCen:: |
151 | IsTheSame1 (const Standard_Integer Index) const |
152 | { |
9775fa61 |
153 | if (!WellDone) { throw StdFail_NotDone(); } |
154 | if (Index <= 0 ||Index > NbrSol) { throw Standard_OutOfRange(); } |
7fd59977 |
155 | if (TheSame1(Index) == 0) { return Standard_False; } |
156 | return Standard_True; |
157 | } |
158 | |