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