0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / ApproxInt / ApproxInt_PrmPrmSvSurfaces.gxx
1 // File:        ApproxInt_PrmPrmSvSurfaces.gxx
2 // Created:     Wed Mar 17 12:42:28 1993
3 // Author:      Laurent BUCHARD
4 //              <lbr@topsn3>
5
6 #define TOLTANGENCY 0.0000000001
7
8
9 #include <TColStd_Array1OfReal.hxx>
10 #include <math_FunctionSetRoot.hxx>
11
12 #define Debug(expr)  cout<<" expr :"<<expr;
13 #define MySurf1 MyIntersectionOn2S.Function().AuxillarSurface1()
14 #define MySurf2 MyIntersectionOn2S.Function().AuxillarSurface2()
15
16
17 //--------------------------------------------------------------------------------
18 ApproxInt_PrmPrmSvSurfaces::ApproxInt_PrmPrmSvSurfaces( const ThePSurface& Surf1
19                                                        ,const ThePSurface& Surf2):
20        MyHasBeenComputed(Standard_False),
21        MyHasBeenComputedbis(Standard_False),
22        MyIntersectionOn2S(Surf1,Surf2,TOLTANGENCY)
23
24 }
25 //--------------------------------------------------------------------------------
26 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute( Standard_Real& u1
27                                                      ,Standard_Real& v1
28                                                      ,Standard_Real& u2
29                                                      ,Standard_Real& v2
30                                                      ,gp_Pnt& P
31                                                      ,gp_Vec& Tg
32                                                      ,gp_Vec2d& Tguv1
33                                                      ,gp_Vec2d& Tguv2) { 
34   
35   Standard_Real tu1=u1;
36   Standard_Real tu2=u2;
37   Standard_Real tv1=v1;
38   Standard_Real tv2=v2;
39   
40   if(MyHasBeenComputed) { 
41     if(  (MyParOnS1.X()==u1)&&(MyParOnS1.Y()==v1)
42        &&(MyParOnS2.X()==u2)&&(MyParOnS2.Y()==v2)) {
43       return(MyIsTangent);
44     }
45     else if(MyHasBeenComputedbis == Standard_False) { 
46       MyTgbis         = MyTg;
47       MyTguv1bis      = MyTguv1;
48       MyTguv2bis      = MyTguv2;
49       MyPntbis        = MyPnt;
50       MyParOnS1bis    = MyParOnS1;
51       MyParOnS2bis    = MyParOnS2;
52       MyIsTangentbis  = MyIsTangent;
53       MyHasBeenComputedbis = MyHasBeenComputed; 
54     }
55   }
56   if(MyHasBeenComputedbis) { 
57     if(  (MyParOnS1bis.X()==u1)&&(MyParOnS1bis.Y()==v1)
58        &&(MyParOnS2bis.X()==u2)&&(MyParOnS2bis.Y()==v2)) {
59
60       gp_Vec            TV(MyTg);
61       gp_Vec2d          TV1(MyTguv1);
62       gp_Vec2d          TV2(MyTguv2);
63       gp_Pnt            TP(MyPnt);
64       gp_Pnt2d          TP1(MyParOnS1);
65       gp_Pnt2d          TP2(MyParOnS2);
66       Standard_Boolean  TB=MyIsTangent;
67
68       MyTg        = MyTgbis;
69       MyTguv1     = MyTguv1bis;
70       MyTguv2     = MyTguv2bis;
71       MyPnt       = MyPntbis;
72       MyParOnS1   = MyParOnS1bis;
73       MyParOnS2   = MyParOnS2bis;
74       MyIsTangent = MyIsTangentbis;
75
76       MyTgbis         = TV;
77       MyTguv1bis      = TV1;
78       MyTguv2bis      = TV2;
79       MyPntbis        = TP;
80       MyParOnS1bis    = TP1;
81       MyParOnS2bis    = TP2;
82       MyIsTangentbis  = TB;
83
84       return(MyIsTangent);
85     }
86   }
87
88
89   MyIsTangent = Standard_True;
90
91   static TColStd_Array1OfReal Param(1,4);
92   Param(1) = u1; Param(2) = v1;
93   Param(3) = u2; Param(4) = v2;
94   math_FunctionSetRoot  Rsnld(MyIntersectionOn2S.Function());
95   MyIntersectionOn2S.Perform(Param,Rsnld);
96   if (!MyIntersectionOn2S.IsDone())  { 
97     MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
98     return(Standard_False);
99   }
100   if (MyIntersectionOn2S.IsEmpty()) {
101     MyIsTangent=Standard_False;
102     //cout<<"\n----- Parametree Parametree : IsEmpty ds Compute "<<endl;
103     //Debug(u1); Debug(u2); Debug(v1); Debug(v2);   cout<<endl;
104     MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
105     return(Standard_False);
106   }
107   MyHasBeenComputed = Standard_True;
108   MyPnt = P = MyIntersectionOn2S.Point().Value();
109   
110   MyIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
111   MyParOnS1.SetCoord(tu1,tv1);
112   MyParOnS2.SetCoord(tu2,tv2);
113   
114   if(MyIntersectionOn2S.IsTangent()) { 
115     MyIsTangent=Standard_False;
116     MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
117     return(Standard_False); 
118   }
119   MyTg    = Tg    = MyIntersectionOn2S.Direction();
120   MyTguv1 = Tguv1 = MyIntersectionOn2S.DirectionOnS1();
121   MyTguv2 = Tguv2 = MyIntersectionOn2S.DirectionOnS2();
122
123   //----------------------------------------------------------------------
124   //-- Si ( Tg )    TU et TV sont normes 
125   //-- 
126   //-- On a    Tg   =  DeltaU  *  TU    +   DeltaV  *  TV
127   //-- 
128   //-- soit :  Tg.TU  =  DeltaU  TU.TU  +   DeltaV  TU.TV
129   //--         Tg.TV  =  DeltaU  TV.TU  +   DeltaV  TV.TV 
130   //-- 
131   //-- Donc : 
132   //--
133   //--               Tg.TU TV.TV  - Tg.TV * TU.TV
134   //--   DeltaU = -------------------------------
135   //--               TU.TU TV.TV  - (TU.TV)**2
136   //-- 
137   //--               Tg.TV TU.TU  - Tg.TU * TU.TV
138   //--   DeltaV = -------------------------------
139   //--               TU.TU TV.TV  - (TU.TV)**2
140   //--
141   //--
142
143   Tg.Normalize();    MyTg = Tg; 
144
145   Standard_Real DeltaU,DeltaV;
146   gp_Vec TU,TV;
147   gp_Pnt Pbid;
148   Standard_Real TUTV,TgTU,TgTV,TUTU,TVTV,DIS;
149   //------------------------------------------------------------
150   //-- Calcul de Tguv1
151   //--
152   ThePSurfaceTool::D1(MySurf1,u1,v1,Pbid,TU,TV);
153   
154   TUTU = TU.Dot(TU);
155   TVTV = TV.Dot(TV);
156   TUTV = TU.Dot(TV);
157   TgTU = Tg.Dot(TU);
158   TgTV = Tg.Dot(TV);
159   DIS  = TUTU * TVTV - TUTV * TUTV;
160   
161   DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ; 
162   DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
163
164   Tguv1.SetCoord(DeltaU,DeltaV);  MyTguv1 = Tguv1;
165
166   //------------------------------------------------------------
167   //-- Calcul de Tguv2
168   //--  
169   ThePSurfaceTool::D1(MySurf2,u2,v2,Pbid,TU,TV);
170
171   TUTU = TU.Dot(TU);
172   TVTV = TV.Dot(TV);
173   TUTV = TU.Dot(TV);
174   TgTU = Tg.Dot(TU);
175   TgTV = Tg.Dot(TV);
176   DIS  = TUTU * TVTV - TUTV * TUTV;
177
178   DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ; 
179   DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
180   
181   Tguv2.SetCoord(DeltaU,DeltaV);  MyTguv2 = Tguv2;
182
183   return(Standard_True);
184 }
185 //--------------------------------------------------------------------------------
186 void ApproxInt_PrmPrmSvSurfaces::Pnt(const Standard_Real u1,
187                                      const Standard_Real v1,
188                                      const Standard_Real u2,
189                                      const Standard_Real v2,
190                                      gp_Pnt& P) { 
191   gp_Pnt aP;
192   gp_Vec aT;
193   gp_Vec2d aTS1,aTS2;
194   Standard_Real tu1=u1;
195   Standard_Real tu2=u2;
196   Standard_Real tv1=v1;
197   Standard_Real tv2=v2;
198 #ifdef DEB
199   Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
200 #else
201   this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
202 #endif
203   P=MyPnt;
204 }
205 //--------------------------------------------------------------------------------
206 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Tangency(const Standard_Real u1,
207                                                       const Standard_Real v1,
208                                                       const Standard_Real u2,
209                                                       const Standard_Real v2,
210                                                       gp_Vec& T) { 
211   gp_Pnt aP;
212   gp_Vec aT;
213   gp_Vec2d aTS1,aTS2;
214   Standard_Real tu1=u1;
215   Standard_Real tu2=u2;
216   Standard_Real tv1=v1;
217   Standard_Real tv2=v2;
218   Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
219   T=MyTg;
220   return(t);
221 }
222 //--------------------------------------------------------------------------------
223 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf1(const Standard_Real u1,
224                                                              const Standard_Real v1,
225                                                              const Standard_Real u2,
226                                                              const Standard_Real v2,
227                                                              gp_Vec2d& T) { 
228   gp_Pnt aP;
229   gp_Vec aT;
230   gp_Vec2d aTS1,aTS2;
231   Standard_Real tu1=u1;
232   Standard_Real tu2=u2;
233   Standard_Real tv1=v1;
234   Standard_Real tv2=v2;
235   Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
236   T=MyTguv1;
237   return(t);
238 }
239 //--------------------------------------------------------------------------------
240 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf2(const Standard_Real u1,
241                                                              const Standard_Real v1,
242                                                              const Standard_Real u2,
243                                                              const Standard_Real v2,
244                                                              gp_Vec2d& T) { 
245   gp_Pnt aP;
246   gp_Vec aT;
247   gp_Vec2d aTS1,aTS2;
248   Standard_Real tu1=u1;
249   Standard_Real tu2=u2;
250   Standard_Real tv1=v1;
251   Standard_Real tv2=v2;
252   Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
253   T=MyTguv2;
254   return(t);
255 }
256 //--------------------------------------------------------------------------------
257
258
259
260
261 #if 0 
262   //------------------------------------------------------------
263   //-- Calcul de Tguv1
264   //--
265   ThePSurfaceTool::D1(MySurf1,u1,v1,P,TU,TV);
266   
267   TUTV = TU.Dot(TV);
268   TgTU = Tg.Dot(TU);
269   TgTV = Tg.Dot(TV);
270   UmTUTV2 = 1.0 - TUTV * TUTV;
271   
272   DeltaU = (TgTU - TgTV * TUTV ) / UmTUTV2 ; 
273   DeltaV = (TgTV - TgTU * TUTV ) / UmTUTV2 ;
274
275   Delta = 1.0 / Sqrt(DeltaU * DeltaU + DeltaV * DeltaV);
276   
277   Tguv1.Multiplied(Delta);  MyTguv1 = Tguv1;
278
279   //------------------------------------------------------------
280   //-- Calcul de Tguv2
281   //--  
282   ThePSurfaceTool::D1(MySurf2,u2,v2,P,TU,TV);
283
284   TUTV = TU.Dot(TV);
285   TgTU = Tg.Dot(TU);
286   TgTV = Tg.Dot(TV);
287   UmTUTV2 = 1.0 - TUTV * TUTV;
288   
289   DeltaU = (TgTU - TgTV * TUTV ) / UmTUTV2 ; 
290   DeltaV = (TgTV - TgTU * TUTV ) / UmTUTV2 ;
291   
292   Delta = 1.0 / Sqrt(DeltaU * DeltaU + DeltaV * DeltaV);
293   
294   Tguv2.Multiplied(Delta);  MyTguv2 = Tguv2;
295
296   return(Standard_True);
297 }
298 #endif
299
300
301
302