0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GccAna / GccAna_Circ2d2TanOn_10.cxx
CommitLineData
7fd59977 1// File: GccAna_Circ2d2TanOn_10.cxx
2// Created: Thu Jan 2 16:00:00 1992
3// Author: Remi GILET
4// <reg@topsn3>
5
6#include <GccAna_Circ2d2TanOn.jxx>
7
8#include <ElCLib.hxx>
9#include <gp_Dir2d.hxx>
10#include <gp_Ax2d.hxx>
11#include <IntAna2d_AnaIntersection.hxx>
12#include <IntAna2d_IntPoint.hxx>
13#include <GccAna_LinPnt2dBisec.hxx>
14#include <GccInt_IType.hxx>
15#include <GccInt_Bisec.hxx>
16#include <GccInt_BLine.hxx>
17#include <IntAna2d_Conic.hxx>
18#include <GccEnt_BadQualifier.hxx>
19
20//=========================================================================
0d969553
Y
21// Creation of a circle tangent to straight line L1 and a point Point2. +
22// centered on a circle. +
23// We start by making difference between boundary cases that will be +
24// processed separately. +
25// In general case: +
7fd59977 26// ==================== +
0d969553
Y
27// We calculate bissectrices to L1 and Point2 that give us all +
28// all possible locations of centers of all circles +
29// tangent to L1 and Point2. +
30// We intersect these bissectrices with circle OnCirc which gives us +
31// points among which we'll choose the solutions. +
32// The choice is made using Qualifiers of L1. +
7fd59977 33//=========================================================================
34
35 GccAna_Circ2d2TanOn::
36 GccAna_Circ2d2TanOn (const GccEnt_QualifiedLin& Qualified1 ,
37 const gp_Pnt2d& Point2 ,
38 const gp_Circ2d& OnCirc ,
39 const Standard_Real Tolerance ):
40 cirsol(1,4) ,
41 qualifier1(1,4) ,
42 qualifier2(1,4) ,
43 TheSame1(1,4) ,
44 TheSame2(1,4) ,
45 pnttg1sol(1,4) ,
46 pnttg2sol(1,4) ,
47 pntcen(1,4) ,
48 par1sol(1,4) ,
49 par2sol(1,4) ,
50 pararg1(1,4) ,
51 pararg2(1,4) ,
52 parcen3(1,4)
53{
54
55 TheSame1.Init(0);
56 TheSame2.Init(0);
57 WellDone = Standard_False;
58 NbrSol = 0;
59 if (!(Qualified1.IsEnclosed() ||
60 Qualified1.IsOutside() || Qualified1.IsUnqualified())) {
61 GccEnt_BadQualifier::Raise();
62 return;
63 }
64 Standard_Real Tol = Abs(Tolerance);
65 gp_Dir2d dirx(1.,0.);
66 gp_Lin2d L1 = Qualified1.Qualified();
67 gp_Pnt2d originL1(L1.Location());
68 gp_Dir2d dirL1(L1.Direction());
69 gp_Dir2d normL1(-dirL1.Y(),dirL1.X());
70
71//=========================================================================
0d969553 72// Processing of boundary cases. +
7fd59977 73//=========================================================================
74
75 Standard_Real Ron = OnCirc.Radius();
76 Standard_Real distpc = OnCirc.Location().Distance(Point2);
77 gp_Dir2d dir(OnCirc.Location().XY()-Point2.XY());
78 gp_Pnt2d pinterm(Point2.XY()+(distpc+Ron)*dir.XY());
79 Standard_Real dist1 = L1.Distance(pinterm);
6e6cd5d9 80
7fd59977 81 if (Abs(dist1-distpc+Ron) <= Tol) {
82 dir = gp_Dir2d(-dirL1.Y(),dirL1.X());
83 gp_Dir2d direc(originL1.XY()-pinterm.XY());
84 if (Qualified1.IsOutside()) {
85 if (direc.Dot(dir) >= 0.0) { WellDone = Standard_True; }
86 }
87 else if (Qualified1.IsEnclosed()) {
88 if (direc.Dot(dir) <= 0.0) { WellDone = Standard_True; }
89 }
90 else { WellDone = Standard_True; }
91 if (WellDone) {
92 NbrSol++;
93 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(pinterm,dirx),dist1);
94// =======================================================
95 gp_Dir2d dc1(originL1.XY()-pinterm.XY());
96 Standard_Real sign = dc1.Dot(normL1);
97 if (!Qualified1.IsUnqualified()) {
98 qualifier1(NbrSol) = Qualified1.Qualifier();
99 }
100 else if (dc1.Dot(normL1) > 0.0) { qualifier1(NbrSol) = GccEnt_outside; }
101 else { qualifier1(NbrSol) = GccEnt_enclosed; }
102 qualifier2(NbrSol) = GccEnt_noqualifier;
103 dc1 = gp_Dir2d(sign*gp_XY(-dirL1.Y(),dirL1.X()));
104 pnttg1sol(NbrSol) = gp_Pnt2d(pinterm.XY()+dist1*dc1.XY());
105 par1sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol),pnttg1sol(NbrSol));
106 pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol));
107 pntcen(NbrSol) = pinterm;
108 parcen3(NbrSol)=ElCLib::Parameter(OnCirc,pntcen(NbrSol));
109 parcen3(NbrSol) = 0.;
110 pnttg2sol(NbrSol) = Point2;
111 pararg2(NbrSol) = 0.;
112 par2sol(NbrSol) = ElCLib::Parameter(cirsol(NbrSol),pnttg2sol(NbrSol));
113 return;
114 }
115 }
116
117//=========================================================================
0d969553 118// General case. +
7fd59977 119//=========================================================================
120
121 GccAna_LinPnt2dBisec Bis(L1,Point2);
122 if (Bis.IsDone()) {
123 Handle(GccInt_Bisec) Sol = Bis.ThisSolution();
124 GccInt_IType type = Sol->ArcType();
125 IntAna2d_AnaIntersection Intp;
126 if (type == GccInt_Lin) {
127 Intp.Perform(Sol->Line(),OnCirc);
128 }
129 if (type == GccInt_Par) {
130 Intp.Perform(OnCirc,IntAna2d_Conic(Sol->Parabola()));
131 }
132 if (Intp.IsDone()) {
133 if (!Intp.IsEmpty()) {
134 for (Standard_Integer j = 1 ; j <= Intp.NbPoints() ; j++) {
135 gp_Pnt2d Center(Intp.Point(j).Value());
136 Standard_Real Radius = L1.Distance(Center);
137// Standard_Integer nbsol = 1;
138 Standard_Boolean ok = Standard_False;
139 if (Qualified1.IsEnclosed()) {
140 if ((((originL1.X()-Center.X())*(-dirL1.Y()))+
141 ((originL1.Y()-Center.Y())*(dirL1.X())))<=0){
142 ok = Standard_True;
143 }
144 }
145 else if (Qualified1.IsOutside()) {
146 if ((((originL1.X()-Center.X())*(-dirL1.Y()))+
147 ((originL1.Y()-Center.Y())*(dirL1.X())))>=0){
148 ok = Standard_True;
149 }
150 }
151 else if (Qualified1.IsUnqualified()) {
152 ok = Standard_True;
153 }
154 if (ok) {
155 NbrSol++;
156 cirsol(NbrSol) = gp_Circ2d(gp_Ax2d(Center,dirx),Radius);
157// =======================================================
158 TheSame1(NbrSol) = 0;
159 TheSame2(NbrSol) = 0;
160 gp_Dir2d dc1(originL1.XY()-Center.XY());
161 Standard_Real sign = dc1.Dot(normL1);
162 if (!Qualified1.IsUnqualified()) {
163 qualifier1(NbrSol) = Qualified1.Qualifier();
164 }
165 else if (dc1.Dot(normL1) > 0.0) {
166 qualifier1(NbrSol) = GccEnt_outside;
167 }
168 else { qualifier1(NbrSol) = GccEnt_enclosed; }
169 qualifier2(NbrSol) = GccEnt_noqualifier;
170 dc1=gp_Dir2d(sign*gp_XY(-dirL1.Y(),dirL1.X()));
171 pnttg1sol(NbrSol) = gp_Pnt2d(Center.XY()+dist1*dc1.XY());
172 par1sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
173 pnttg1sol(NbrSol));
174 pararg1(NbrSol)=ElCLib::Parameter(L1,pnttg1sol(NbrSol));
175 pntcen(NbrSol) = Center;
176 parcen3(NbrSol) = ElCLib::Parameter(OnCirc,pntcen(NbrSol));
177 pnttg2sol(NbrSol) = Point2;
178 pararg2(NbrSol) = 0.;
179 par2sol(NbrSol)=ElCLib::Parameter(cirsol(NbrSol),
180 pnttg2sol(NbrSol));
181 qualifier2(NbrSol) = GccEnt_noqualifier;
182 }
183 }
184 }
185 WellDone = Standard_True;
186 }
187 }
188}
189