0024510: Remove unused local variables
[occt.git] / src / GccAna / GccAna_Circ2d2TanRad_2.cxx
CommitLineData
b311480e 1// Created on: 1991-09-24
2// Created by: Remi GILET
3// Copyright (c) 1991-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//
973c2be1 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.
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 <GccAna_Circ2d2TanRad.jxx>
18
19#include <gp_Circ2d.hxx>
20#include <ElCLib.hxx>
21#include <gp_Dir2d.hxx>
22#include <gp_Lin2d.hxx>
23#include <IntAna2d_AnaIntersection.hxx>
24#include <IntAna2d_IntPoint.hxx>
25#include <Standard_NegativeValue.hxx>
26#include <GccEnt_BadQualifier.hxx>
27
0d969553 28// circulare tangent to a circle a point and a given radius
7fd59977 29//=============================================================
30
31//========================================================================
0d969553
Y
32// Initialize WellDone to false. +
33// Return circle C1. +
34// Leave with error if the construction is impossible. +
35// Create parallel to C1 in the proper direction. +
36// Create circle with center in Point1 of radius Radius. +
37// Intersect the parallel and the circle. +
38// ==> The center point of the solution. +
39// Create the solution that will be added to already found solutions. +
40// Fill the fields. +
7fd59977 41//========================================================================
42
43GccAna_Circ2d2TanRad::
44 GccAna_Circ2d2TanRad (const GccEnt_QualifiedCirc& Qualified1 ,
45 const gp_Pnt2d& Point2 ,
46 const Standard_Real Radius ,
47 const Standard_Real Tolerance ):
48 qualifier1(1,4) ,
49 qualifier2(1,4),
50 TheSame1(1,4) ,
51 TheSame2(1,4) ,
52 cirsol(1,4) ,
53 pnttg1sol(1,4) ,
54 pnttg2sol(1,4) ,
55 par1sol(1,4) ,
56 par2sol(1,4) ,
57 pararg1(1,4) ,
58 pararg2(1,4)
59{
60
61 gp_Dir2d dirx(1.0,0.0);
62 Standard_Real Tol = Abs(Tolerance);
63 NbrSol = 0;
64 WellDone = Standard_False;
65 if (!(Qualified1.IsEnclosed() || Qualified1.IsEnclosing() ||
66 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
67 GccEnt_BadQualifier::Raise();
68 return;
69 }
70 Standard_Integer i ;
71 for ( i = 1 ; i <= 4 ; i++) {
72 TheSame1(i) = 0;
73 TheSame2(i) = 0;
74 }
75 Standard_Real deport = 0.;
76 Standard_Integer signe = 0;
77 Standard_Integer nbsol = 0;
78 gp_Circ2d C1 = Qualified1.Qualified();
79 TColgp_Array1OfCirc2d C(1,4);
80 Standard_Real R1 = C1.Radius();
81 Standard_Real distance = (C1.Location()).Distance(Point2);
82 Standard_Real dispc1 = C1.Distance(Point2);
83 gp_Dir2d dir1(Point2.XY()-(C1.Location().XY()));
84 gp_Pnt2d center1(C1.Location());
85 if (Radius < 0.0) { Standard_NegativeValue::Raise(); }
86 else {
87 if ( dispc1-Radius*2.0 > Tol) { WellDone = Standard_True; }
88 else if (Qualified1.IsEnclosed()) {
89// =================================
90 if ((distance-R1>Tol)||(Radius-R1>Tol)) { WellDone = Standard_True; }
91 else {
92 if (Abs(distance-R1) < Tol) {
93 nbsol = -1;
94 deport = R1-Radius;
95 signe = 1;
96 }
97 else {
98 C(1) = gp_Circ2d(C1.XAxis(),Abs(Radius-R1));
99 C(2) = gp_Circ2d(gp_Ax2d(Point2,dirx),Radius);
100 nbsol = 1;
101 }
102 }
103 }
104 else if (Qualified1.IsEnclosing()) {
105// ==================================
106 if ((Tol<R1-distance)||(Tol<R1-Radius)) { WellDone = Standard_True; }
107 else {
108 if (Abs(distance-R1) < Tol) {
109 nbsol = -1;
110 deport = R1-Radius;
111 signe = 1;
112 }
113 else {
114 C(1) = gp_Circ2d(C1.XAxis(),Abs(Radius-R1));
115 C(2) = gp_Circ2d(gp_Ax2d(Point2,dirx),Radius);
116 nbsol = 1;
117 }
118 }
119 }
120 else if (Qualified1.IsOutside()) {
121// ================================
122 if (Tol < R1-distance) { WellDone = Standard_True; }
123 else if ((Abs(distance-R1) < Tol) || (Abs(dispc1-Radius*2.0) < Tol)) {
124 nbsol = -1;
125 deport = R1+Radius;
126 signe = -1;
127 }
128 else {
129 C(1) = gp_Circ2d(C1.XAxis(),Radius+R1);
130 C(2) = gp_Circ2d(gp_Ax2d(Point2,dirx),Radius);
131 nbsol = 1;
132 }
133 }
134 else if (Qualified1.IsUnqualified()) {
135// ====================================
136 if (Abs(dispc1-Radius*2.0) < Tol) {
137 WellDone = Standard_True;
138 gp_Pnt2d Center(center1.XY()+(distance-Radius)*dir1.XY());
139 cirsol(1) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
140// ==================================================
141 if (Abs(Center.Distance(center1)-R1) < Tol) {
142 qualifier1(1) = GccEnt_enclosed;
143 }
144 else { qualifier1(1) = GccEnt_outside; }
145 qualifier2(1) = GccEnt_noqualifier;
146 pnttg1sol(1) = gp_Pnt2d(Center.XY()-Radius*dir1.XY());
147 pnttg2sol(1) = Point2;
148 WellDone = Standard_True;
149 NbrSol = 1;
150 }
151 else if ((Abs(R1-Radius)<Tol) && (Abs(distance-R1)<Tol)){
152 cirsol(1) = gp_Circ2d(C1);
153// =========================
154 qualifier1(1) = GccEnt_unqualified;
155 qualifier2(1) = GccEnt_noqualifier;
156 TheSame1(1) = 1;
157 pnttg2sol(1) = Point2;
158 WellDone = Standard_True;
159 NbrSol = 1;
160 C(1) = gp_Circ2d(C1.XAxis(),Radius+R1);
161 C(2) = gp_Circ2d(gp_Ax2d(Point2,dirx),Radius);
162 nbsol = 1;
163 }
164 else {
165 C(1) = gp_Circ2d(C1.XAxis(),Abs(Radius-R1));
166 C(2) = gp_Circ2d(gp_Ax2d(Point2,dirx),Radius);
167 C(3) = gp_Circ2d(C1.XAxis(),Radius+R1);
168 C(4) = gp_Circ2d(gp_Ax2d(Point2,dirx),Radius);
169 nbsol = 2;
170 }
171 }
172 if (nbsol > 0) {
173 for (Standard_Integer j = 1 ; j <= nbsol ; j++) {
174 IntAna2d_AnaIntersection Intp(C(2*j-1),C(2*j));
175 if (Intp.IsDone()) {
176 if (!Intp.IsEmpty()) {
177 for (i = 1 ; i <= Intp.NbPoints() ; i++) {
178 NbrSol++;
179 gp_Pnt2d Center(Intp.Point(i).Value());
180 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
181// =======================================================
182 Standard_Real distcc1 = center1.Distance(Center);
183 if (!Qualified1.IsUnqualified()) {
184 qualifier1(NbrSol) = Qualified1.Qualifier();
185 }
186 else if (Abs(distcc1+Radius-R1) < Tol) {
187 qualifier1(NbrSol) = GccEnt_enclosed;
188 }
189 else if (Abs(distcc1-R1-Radius) < Tol) {
190 qualifier1(NbrSol) = GccEnt_outside;
191 }
192 else { qualifier1(NbrSol) = GccEnt_enclosing; }
193 qualifier2(NbrSol) = GccEnt_noqualifier;
194 dir1 = gp_Dir2d(Center.XY()-center1.XY());
195#ifdef DEB
196 gp_Dir2d dir2(Center.XY()-Point2.XY());
197#endif
198 if ((Center.Distance(center1) > C1.Radius()) &&
199 (Radius < Center.Distance(center1)+C1.Radius())) {
200 pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()-Radius*dir1.XY());
201 }
202 else if ((Center.Distance(center1) < C1.Radius()) &&
203 (Radius < C1.Radius())) {
204 pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+Radius*dir1.XY());
205 }
206 else {
207 pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()-Radius*dir1.XY());
208 }
209 pnttg2sol(NbrSol) = Point2;
210 }
211 }
212 WellDone = Standard_True;
213 }
214 }
215 }
216 else if (nbsol < 0) {
217 gp_Pnt2d Center(center1.XY()+deport*dir1.XY());
218 cirsol(1) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
219// ==================================================
220 qualifier1(1) = Qualified1.Qualifier();
221 qualifier2(1) = GccEnt_noqualifier;
222 if (Abs(deport) <= Tol && Abs(Radius-R1) <= Tol) {
223 TheSame1(1) = 1;
224 }
225 else {
226 pnttg1sol(1) = gp_Pnt2d(Center.XY()+signe*Radius*dir1.XY());
227 }
228 pnttg2sol(1) = Point2;
229 WellDone = Standard_True;
230 NbrSol = 1;
231 }
232 }
233 for (i = 1 ; i <= NbrSol ; i++) {
234 par1sol(i)=ElCLib::Parameter(cirsol(i),pnttg1sol(i));
235 if (TheSame1(i) == 0) {
236 pararg1(i)=ElCLib::Parameter(C1,pnttg1sol(i));
237 }
238 par2sol(i) = ElCLib::Parameter(cirsol(i),pnttg2sol(i));
239 pararg2(i) = 0.;
240 }
241}
242
243
244
245
246