Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File GccAna_Circ2d3Tan.cxx_7, REG 08/07/91 |
2 | ||
3 | #include <GccAna_Circ2d3Tan.jxx> | |
4 | ||
5 | #include <ElCLib.hxx> | |
6 | #include <IntAna2d_AnaIntersection.hxx> | |
7 | #include <IntAna2d_IntPoint.hxx> | |
8 | #include <gp_Lin2d.hxx> | |
9 | #include <gp_Circ2d.hxx> | |
10 | #include <gp_Dir2d.hxx> | |
11 | #include <TColStd_Array1OfReal.hxx> | |
12 | #include <GccAna_CircPnt2dBisec.hxx> | |
13 | #include <GccAna_Pnt2dBisec.hxx> | |
14 | #include <GccInt_IType.hxx> | |
15 | #include <GccInt_BCirc.hxx> | |
16 | #include <GccInt_BLine.hxx> | |
17 | #include <GccInt_BElips.hxx> | |
18 | #include <GccInt_BHyper.hxx> | |
19 | #include <IntAna2d_Conic.hxx> | |
20 | #include <GccEnt_BadQualifier.hxx> | |
21 | #include <Precision.hxx> | |
22 | ||
0d969553 Y |
23 | //======================================================================= |
24 | // Creation of a circle tangent to a circle and two points. + | |
25 | //======================================================================= | |
7fd59977 | 26 | |
27 | GccAna_Circ2d3Tan:: | |
28 | GccAna_Circ2d3Tan (const GccEnt_QualifiedCirc& Qualified1 , | |
29 | const gp_Pnt2d& Point2 , | |
30 | const gp_Pnt2d& Point3 , | |
31 | const Standard_Real Tolerance ): | |
32 | ||
33 | cirsol(1,2) , | |
34 | qualifier1(1,2) , | |
35 | qualifier2(1,2) , | |
36 | qualifier3(1,2) , | |
37 | TheSame1(1,2) , | |
38 | TheSame2(1,2) , | |
39 | TheSame3(1,2) , | |
40 | pnttg1sol(1,2) , | |
41 | pnttg2sol(1,2) , | |
42 | pnttg3sol(1,2) , | |
43 | par1sol(1,2) , | |
44 | par2sol(1,2) , | |
45 | par3sol(1,2) , | |
46 | pararg1(1,2) , | |
47 | pararg2(1,2) , | |
48 | pararg3(1,2) | |
49 | { | |
50 | ||
51 | gp_Dir2d dirx(1.0,0.0); | |
52 | Standard_Real Tol = Abs(Tolerance); | |
53 | WellDone = Standard_False; | |
54 | NbrSol = 0; | |
55 | if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() || | |
56 | Qualified1.IsOutside() || Qualified1.IsUnqualified())) { | |
57 | GccEnt_BadQualifier::Raise(); | |
58 | return; | |
59 | } | |
60 | ||
61 | //========================================================================= | |
0d969553 | 62 | // Processing. + |
7fd59977 | 63 | //========================================================================= |
64 | ||
65 | gp_Circ2d C1 = Qualified1.Qualified(); | |
66 | Standard_Real R1 = C1.Radius(); | |
67 | gp_Pnt2d center1(C1.Location()); | |
68 | TColStd_Array1OfReal Radius(1,2); | |
69 | ||
70 | if (Point2.IsEqual(Point3,Precision::Confusion())) { | |
71 | WellDone = Standard_False; | |
72 | return ; | |
73 | } | |
74 | ||
75 | GccAna_Pnt2dBisec Bis1(Point2,Point3); | |
76 | GccAna_CircPnt2dBisec Bis2(C1,Point2); | |
77 | ||
78 | if (Bis1.IsDone() && Bis2.IsDone()) { | |
79 | Standard_Integer nbsolution2 = Bis2.NbSolutions(); | |
80 | for (Standard_Integer i = 1 ; i <= nbsolution2; i++) { | |
81 | Handle(GccInt_Bisec) Sol2 = Bis2.ThisSolution(i); | |
82 | GccInt_IType typ2 = Sol2->ArcType(); | |
83 | gp_Lin2d Sol1(Bis1.ThisSolution()); | |
84 | IntAna2d_AnaIntersection Intp; | |
85 | if (typ2 == GccInt_Cir) { | |
86 | Intp.Perform(Sol1,Sol2->Circle()); | |
87 | } | |
88 | else if (typ2 == GccInt_Lin) { | |
89 | Intp.Perform(Sol1,Sol2->Line()); | |
90 | } | |
91 | else if (typ2 == GccInt_Hpr) { | |
92 | Intp.Perform(Sol1,IntAna2d_Conic(Sol2->Hyperbola())); | |
93 | } | |
94 | else if (typ2 == GccInt_Ell) { | |
95 | Intp.Perform(Sol1,IntAna2d_Conic(Sol2->Ellipse())); | |
96 | } | |
97 | ||
98 | if (Intp.IsDone()) { | |
99 | if (!Intp.IsEmpty()) { | |
100 | for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) { | |
101 | gp_Pnt2d Center(Intp.Point(j).Value()); | |
102 | Standard_Real dist1 = Center.Distance(center1); | |
103 | Standard_Real dist2 = Center.Distance(Point2); | |
104 | Standard_Real dist3 = Center.Distance(Point3); | |
105 | Standard_Integer nbsol1 = 0; | |
106 | // Standard_Integer nbsol2 = 0; | |
107 | Standard_Integer nbsol3 = 0; | |
108 | Standard_Boolean ok = Standard_False; | |
109 | if (Qualified1.IsEnclosed()) { | |
110 | if (dist1-R1 < Tolerance) { | |
111 | Radius(1) = Abs(R1-dist1); | |
112 | nbsol1 = 1; | |
113 | ok = Standard_True; | |
114 | } | |
115 | } | |
116 | else if (Qualified1.IsOutside()) { | |
117 | if (R1-dist1 < Tolerance) { | |
118 | Radius(1) = Abs(R1-dist1); | |
119 | nbsol1 = 1; | |
120 | ok = Standard_True; | |
121 | } | |
122 | } | |
123 | else if (Qualified1.IsEnclosing()) { | |
124 | ok = Standard_True; | |
125 | nbsol1 = 1; | |
126 | Radius(1) = R1+dist1; | |
127 | } | |
128 | else if (Qualified1.IsUnqualified()) { | |
129 | ok = Standard_True; | |
130 | nbsol1 = 2; | |
131 | Radius(1) = Abs(R1-dist1); | |
132 | Radius(2) = R1+dist1; | |
133 | } | |
134 | if (ok) { | |
135 | ok = Standard_False; | |
136 | for (Standard_Integer ii = 1 ; ii <= nbsol1 ; ii++) { | |
137 | //pop if (Abs(dist2-Radius(ii))<=Tol && Abs(dist2-Radius(ii))<=Tol){ | |
138 | if (Abs(dist2-Radius(ii))<=Tol && Abs(dist3-Radius(ii))<=Tol){ | |
139 | nbsol3 = ii; | |
140 | ok = Standard_True; | |
141 | } | |
142 | } | |
143 | } | |
144 | ||
145 | if (ok) { | |
146 | // for (Standard_Integer k = 1 ; k <= nbsol3 ; k++) { | |
147 | if (NbrSol>=2) break; | |
148 | NbrSol++; | |
149 | // cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(k)); | |
150 | cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius(nbsol3)); | |
151 | // ========================================================== | |
152 | Standard_Real distcc1 = Center.Distance(center1); | |
153 | if (!Qualified1.IsUnqualified()) { | |
154 | qualifier1(NbrSol) = Qualified1.Qualifier(); | |
155 | } | |
156 | else if (Abs(distcc1+Radius(nbsol3)-R1) < Tol) { | |
157 | qualifier1(NbrSol) = GccEnt_enclosed; | |
158 | } | |
159 | else if (Abs(distcc1-R1-Radius(nbsol3)) < Tol) { | |
160 | qualifier1(NbrSol) = GccEnt_outside; | |
161 | } | |
162 | else { qualifier1(NbrSol) = GccEnt_enclosing; } | |
163 | qualifier2(NbrSol) = GccEnt_noqualifier; | |
164 | qualifier3(NbrSol) = GccEnt_noqualifier; | |
165 | if (Center.Distance(center1) <= Tolerance && | |
166 | Abs(Radius(nbsol3)-R1) <= Tolerance) { | |
167 | TheSame1(NbrSol) = 1; | |
168 | } | |
169 | else { | |
170 | TheSame1(NbrSol) = 0; | |
171 | gp_Dir2d dc(center1.XY()-Center.XY()); | |
172 | pnttg1sol(NbrSol)=gp_Pnt2d(Center.XY()+Radius(nbsol3)*dc.XY()); | |
173 | par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
174 | pnttg1sol(NbrSol)); | |
175 | pararg1(NbrSol)=ElCLib::Parameter(C1,pnttg1sol(NbrSol)); | |
176 | } | |
177 | ||
178 | TheSame2(NbrSol) = 0; | |
179 | pnttg2sol(NbrSol) = Point2; | |
180 | par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
181 | pnttg2sol(NbrSol)); | |
182 | pararg2(NbrSol)=0.; | |
183 | TheSame3(NbrSol) = 0; | |
184 | pnttg3sol(NbrSol) = Point3; | |
185 | par3sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol), | |
186 | pnttg3sol(NbrSol)); | |
187 | pararg3(NbrSol) = 0.; | |
188 | //} | |
189 | } | |
190 | } | |
191 | } | |
192 | WellDone = Standard_True; | |
193 | } | |
194 | } | |
195 | } | |
196 | } | |
197 | ||
198 |