1 // File: ApproxInt_PrmPrmSvSurfaces.gxx
2 // Created: Wed Mar 17 12:42:28 1993
3 // Author: Laurent BUCHARD
6 #define TOLTANGENCY 0.0000000001
9 #include <TColStd_Array1OfReal.hxx>
10 #include <math_FunctionSetRoot.hxx>
12 #define Debug(expr) cout<<" expr :"<<expr;
13 #define MySurf1 MyIntersectionOn2S.Function().AuxillarSurface1()
14 #define MySurf2 MyIntersectionOn2S.Function().AuxillarSurface2()
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)
25 //--------------------------------------------------------------------------------
26 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute( Standard_Real& u1
40 if(MyHasBeenComputed) {
41 if( (MyParOnS1.X()==u1)&&(MyParOnS1.Y()==v1)
42 &&(MyParOnS2.X()==u2)&&(MyParOnS2.Y()==v2)) {
45 else if(MyHasBeenComputedbis == Standard_False) {
50 MyParOnS1bis = MyParOnS1;
51 MyParOnS2bis = MyParOnS2;
52 MyIsTangentbis = MyIsTangent;
53 MyHasBeenComputedbis = MyHasBeenComputed;
56 if(MyHasBeenComputedbis) {
57 if( (MyParOnS1bis.X()==u1)&&(MyParOnS1bis.Y()==v1)
58 &&(MyParOnS2bis.X()==u2)&&(MyParOnS2bis.Y()==v2)) {
61 gp_Vec2d TV1(MyTguv1);
62 gp_Vec2d TV2(MyTguv2);
64 gp_Pnt2d TP1(MyParOnS1);
65 gp_Pnt2d TP2(MyParOnS2);
66 Standard_Boolean TB=MyIsTangent;
72 MyParOnS1 = MyParOnS1bis;
73 MyParOnS2 = MyParOnS2bis;
74 MyIsTangent = MyIsTangentbis;
89 MyIsTangent = Standard_True;
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);
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);
107 MyHasBeenComputed = Standard_True;
108 MyPnt = P = MyIntersectionOn2S.Point().Value();
110 MyIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
111 MyParOnS1.SetCoord(tu1,tv1);
112 MyParOnS2.SetCoord(tu2,tv2);
114 if(MyIntersectionOn2S.IsTangent()) {
115 MyIsTangent=Standard_False;
116 MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
117 return(Standard_False);
119 MyTg = Tg = MyIntersectionOn2S.Direction();
120 MyTguv1 = Tguv1 = MyIntersectionOn2S.DirectionOnS1();
121 MyTguv2 = Tguv2 = MyIntersectionOn2S.DirectionOnS2();
123 //----------------------------------------------------------------------
124 //-- Si ( Tg ) TU et TV sont normes
126 //-- On a Tg = DeltaU * TU + DeltaV * TV
128 //-- soit : Tg.TU = DeltaU TU.TU + DeltaV TU.TV
129 //-- Tg.TV = DeltaU TV.TU + DeltaV TV.TV
133 //-- Tg.TU TV.TV - Tg.TV * TU.TV
134 //-- DeltaU = -------------------------------
135 //-- TU.TU TV.TV - (TU.TV)**2
137 //-- Tg.TV TU.TU - Tg.TU * TU.TV
138 //-- DeltaV = -------------------------------
139 //-- TU.TU TV.TV - (TU.TV)**2
143 Tg.Normalize(); MyTg = Tg;
145 Standard_Real DeltaU,DeltaV;
148 Standard_Real TUTV,TgTU,TgTV,TUTU,TVTV,DIS;
149 //------------------------------------------------------------
152 ThePSurfaceTool::D1(MySurf1,u1,v1,Pbid,TU,TV);
159 DIS = TUTU * TVTV - TUTV * TUTV;
161 DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ;
162 DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
164 Tguv1.SetCoord(DeltaU,DeltaV); MyTguv1 = Tguv1;
166 //------------------------------------------------------------
169 ThePSurfaceTool::D1(MySurf2,u2,v2,Pbid,TU,TV);
176 DIS = TUTU * TVTV - TUTV * TUTV;
178 DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ;
179 DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
181 Tguv2.SetCoord(DeltaU,DeltaV); MyTguv2 = Tguv2;
183 return(Standard_True);
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,
194 Standard_Real tu1=u1;
195 Standard_Real tu2=u2;
196 Standard_Real tv1=v1;
197 Standard_Real tv2=v2;
199 Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
201 this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
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,
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);
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,
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);
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,
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);
256 //--------------------------------------------------------------------------------
262 //------------------------------------------------------------
265 ThePSurfaceTool::D1(MySurf1,u1,v1,P,TU,TV);
270 UmTUTV2 = 1.0 - TUTV * TUTV;
272 DeltaU = (TgTU - TgTV * TUTV ) / UmTUTV2 ;
273 DeltaV = (TgTV - TgTU * TUTV ) / UmTUTV2 ;
275 Delta = 1.0 / Sqrt(DeltaU * DeltaU + DeltaV * DeltaV);
277 Tguv1.Multiplied(Delta); MyTguv1 = Tguv1;
279 //------------------------------------------------------------
282 ThePSurfaceTool::D1(MySurf2,u2,v2,P,TU,TV);
287 UmTUTV2 = 1.0 - TUTV * TUTV;
289 DeltaU = (TgTU - TgTV * TUTV ) / UmTUTV2 ;
290 DeltaV = (TgTV - TgTU * TUTV ) / UmTUTV2 ;
292 Delta = 1.0 / Sqrt(DeltaU * DeltaU + DeltaV * DeltaV);
294 Tguv2.Multiplied(Delta); MyTguv2 = Tguv2;
296 return(Standard_True);