0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GccAna / GccAna_Circ2d2TanRad_4.cxx
CommitLineData
7fd59977 1// File: GccAna_Circ2d2TanRad_4.cxx
2// Created: Tue Sep 24 09:15:20 1991
3// Author: Remi GILET
4// <reg@topsn2>
5
6#include <GccAna_Circ2d2TanRad.jxx>
7
8#include <ElCLib.hxx>
9#include <gp_Circ2d.hxx>
10#include <gp_Lin2d.hxx>
11#include <gp_Ax2d.hxx>
12#include <IntAna2d_AnaIntersection.hxx>
13#include <IntAna2d_IntPoint.hxx>
14#include <TColStd_Array1OfReal.hxx>
15#include <Standard_NegativeValue.hxx>
16#include <gp.hxx>
17#include <GccEnt_BadQualifier.hxx>
18
19#include <Precision.hxx>
20
0d969553 21// circular tangent to two lines of given radius
7fd59977 22//===============================================
23//========================================================================
0d969553
Y
24// Initialize WellDone to false. +
25// Return two lines L1 and L2. +
26// Leave with error if the construction is impossible. +
27// Create parallel lines to L1 and L2 in the proper direction. +
28// Intersect parallels ==> The center point of the solution. +
29// Create the solution to be added to the already found solutions. +
30// Fill the fields. +
7fd59977 31//========================================================================
32
33GccAna_Circ2d2TanRad::
34 GccAna_Circ2d2TanRad (const GccEnt_QualifiedLin& Qualified1 ,
35 const GccEnt_QualifiedLin& Qualified2 ,
36 const Standard_Real Radius ,
37 const Standard_Real
38#ifdef DEB
39 Tolerance
40#endif
41 ):
42 qualifier1(1,4) ,
43 qualifier2(1,4),
44 TheSame1(1,4) ,
45 TheSame2(1,4) ,
46 cirsol(1,4) ,
47 pnttg1sol(1,4) ,
48 pnttg2sol(1,4) ,
49 par1sol(1,4) ,
50 par2sol(1,4) ,
51 pararg1(1,4) ,
52 pararg2(1,4)
53{
54
55 gp_Dir2d dirx(1.0,0.0);
7fd59977 56 TColStd_Array1OfReal cote1(1,2);
57 TColStd_Array1OfReal cote2(1,2);
58 Standard_Integer nbrcote1=0;
59 Standard_Integer nbrcote2=0;
60 NbrSol = 0;
61 WellDone = Standard_False;
62 if (!(Qualified1.IsEnclosed() ||
63 Qualified1.IsOutside() || Qualified1.IsUnqualified()) ||
64 !(Qualified2.IsEnclosed() ||
65 Qualified2.IsOutside() || Qualified2.IsUnqualified())) {
66 GccEnt_BadQualifier::Raise();
67 return;
68 }
69 gp_Lin2d L1 = Qualified1.Qualified();
70 gp_Lin2d L2 = Qualified2.Qualified();
71 Standard_Real x1dir = (L1.Direction()).X();
72 Standard_Real y1dir = (L1.Direction()).Y();
73 Standard_Real lx1loc = (L1.Location()).X();
74 Standard_Real ly1loc = (L1.Location()).Y();
75 Standard_Real x2dir = (L2.Direction()).X();
76 Standard_Real y2dir = (L2.Direction()).Y();
77 Standard_Real lx2loc = (L2.Location()).X();
78 Standard_Real ly2loc = (L2.Location()).Y();
79 gp_Pnt2d origin1(lx1loc,ly1loc);
80 gp_Pnt2d origin2(lx2loc,ly2loc);
81 gp_Dir2d normL1(x1dir,y1dir);
82 gp_Dir2d normL2(x2dir,y2dir);
83 if (Radius < 0.0) { Standard_NegativeValue::Raise(); }
84 else {
85 if (L1.Direction().IsParallel(L2.Direction(),Precision::Angular())) {
86 WellDone = Standard_True;
87 }
88 else {
89 if (Qualified1.IsEnclosed() && Qualified2.IsEnclosed()) {
90// =======================================================
91 nbrcote1 = 1;
92 nbrcote2 = 1;
93 cote1(1) = 1.0;
94 cote2(1) = 1.0;
95 }
96 else if(Qualified1.IsEnclosed() && Qualified2.IsOutside()) {
97// ==========================================================
98 nbrcote1 = 1;
99 nbrcote2 = 1;
100 cote1(1) = 1.0;
101 cote2(1) = -1.0;
102 }
103 else if (Qualified1.IsOutside() && Qualified2.IsEnclosed()) {
104// ===========================================================
105 nbrcote1 = 1;
106 nbrcote2 = 1;
107 cote1(1) = -1.0;
108 cote2(1) = 1.0;
109 }
110 else if(Qualified1.IsOutside() && Qualified2.IsOutside()) {
111// =========================================================
112 nbrcote1 = 1;
113 nbrcote2 = 1;
114 cote1(1) = -1.0;
115 cote2(1) = -1.0;
116 }
117 if(Qualified1.IsEnclosed() && Qualified2.IsUnqualified()) {
118// =========================================================
119 nbrcote1 = 1;
120 nbrcote2 = 2;
121 cote1(1) = 1.0;
122 cote2(1) = 1.0;
123 cote2(2) = -1.0;
124 }
125 if(Qualified1.IsUnqualified() && Qualified2.IsEnclosed()) {
126// =========================================================
127 nbrcote1 = 2;
128 nbrcote2 = 1;
129 cote1(1) = 1.0;
130 cote1(2) = -1.0;
131 cote2(1) = 1.0;
132 }
133 else if(Qualified1.IsOutside() && Qualified2.IsUnqualified()) {
134// =============================================================
135 nbrcote1 = 1;
136 nbrcote2 = 2;
137 cote1(1) = -1.0;
138 cote2(1) = 1.0;
139 cote2(2) = -1.0;
140 }
141 if(Qualified1.IsUnqualified() && Qualified2.IsOutside()) {
142// ========================================================
143 nbrcote1 = 2;
144 nbrcote2 = 1;
145 cote1(1) = 1.0;
146 cote1(2) = -1.0;
147 cote2(1) = -1.0;
148 }
149 else if(Qualified1.IsUnqualified() && Qualified2.IsUnqualified()) {
150// =================================================================
151 nbrcote1 = 2;
152 nbrcote2 = 2;
153 cote1(1) = 1.0;
154 cote1(2) = -1.0;
155 cote2(1) = 1.0;
156 cote2(2) = -1.0;
157 }
158 for (Standard_Integer jcote1 = 1 ; jcote1 <= nbrcote1 ; jcote1++) {
159 for (Standard_Integer jcote2 = 1 ; jcote2 <= nbrcote2 ; jcote2++) {
160 gp_Lin2d linint1(gp_Pnt2d(lx1loc-cote1(jcote1)*y1dir*Radius,
161 ly1loc+cote1(jcote1)*x1dir*Radius),
162 L1.Direction());
163 gp_Lin2d linint2(gp_Pnt2d(lx2loc-cote2(jcote2)*y2dir*Radius,
164 ly2loc+cote2(jcote2)*x2dir*Radius),
165 L2.Direction());
166 IntAna2d_AnaIntersection Intp(linint1,linint2);
167 if (Intp.IsDone()) {
168 if (!Intp.IsEmpty()) {
169 for (Standard_Integer i = 1 ; i <= Intp.NbPoints() ; i++) {
170 NbrSol++;
171 gp_Pnt2d Center(Intp.Point(i).Value());
172 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
173// =======================================================
174 gp_Dir2d dc1(origin1.XY()-Center.XY());
175 gp_Dir2d dc2(origin2.XY()-Center.XY());
176 if (!Qualified1.IsUnqualified()) {
177 qualifier1(NbrSol) = Qualified1.Qualifier();
178 }
179 else if (dc1.Dot(normL1) > 0.0) {
180 qualifier1(NbrSol) = GccEnt_outside;
181 }
182 else { qualifier1(NbrSol) = GccEnt_enclosed; }
183 if (!Qualified2.IsUnqualified()) {
184 qualifier2(NbrSol) = Qualified2.Qualifier();
185 }
186 else if (dc2.Dot(normL2) > 0.0) {
187 qualifier2(NbrSol) = GccEnt_outside;
188 }
189 else { qualifier2(NbrSol) = GccEnt_enclosed; }
190 TheSame1(NbrSol) = 0;
191 TheSame2(NbrSol) = 0;
192 pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+
193 cote1(jcote1)*Radius*gp_XY(y1dir,-x1dir));
194 pnttg2sol(NbrSol) = gp_Pnt2d(Center.XY()+
195 cote2(jcote2)*Radius*gp_XY(y2dir,-x2dir));
196 }
197 }
198 WellDone = Standard_True;
199 }
200 }
201 }
202 }
203 }
204 for (Standard_Integer i = 1 ; i <= NbrSol ; i++) {
205 par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
206 pararg1(i)=ElCLib::Parameter(L1,pnttg1sol(i));
207 par2sol(i)=ElCLib::Parameter(cirsol(i),pnttg2sol(i));
208 pararg2(i)=ElCLib::Parameter(L2,pnttg2sol(i));
209 }
210}
211
212
213