1 // Created on: 1993-03-17
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #define TOLTANGENCY 0.0000000001
25 #include <TColStd_Array1OfReal.hxx>
26 #include <math_FunctionSetRoot.hxx>
28 #define Debug(expr) cout<<" expr :"<<expr;
29 #define MySurf1 MyIntersectionOn2S.Function().AuxillarSurface1()
30 #define MySurf2 MyIntersectionOn2S.Function().AuxillarSurface2()
33 //--------------------------------------------------------------------------------
34 ApproxInt_PrmPrmSvSurfaces::ApproxInt_PrmPrmSvSurfaces( const ThePSurface& Surf1
35 ,const ThePSurface& Surf2):
36 MyHasBeenComputed(Standard_False),
37 MyHasBeenComputedbis(Standard_False),
38 MyIntersectionOn2S(Surf1,Surf2,TOLTANGENCY)
41 //--------------------------------------------------------------------------------
42 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Compute( Standard_Real& u1
56 if(MyHasBeenComputed) {
57 if( (MyParOnS1.X()==u1)&&(MyParOnS1.Y()==v1)
58 &&(MyParOnS2.X()==u2)&&(MyParOnS2.Y()==v2)) {
61 else if(MyHasBeenComputedbis == Standard_False) {
66 MyParOnS1bis = MyParOnS1;
67 MyParOnS2bis = MyParOnS2;
68 MyIsTangentbis = MyIsTangent;
69 MyHasBeenComputedbis = MyHasBeenComputed;
72 if(MyHasBeenComputedbis) {
73 if( (MyParOnS1bis.X()==u1)&&(MyParOnS1bis.Y()==v1)
74 &&(MyParOnS2bis.X()==u2)&&(MyParOnS2bis.Y()==v2)) {
77 gp_Vec2d TV1(MyTguv1);
78 gp_Vec2d TV2(MyTguv2);
80 gp_Pnt2d TP1(MyParOnS1);
81 gp_Pnt2d TP2(MyParOnS2);
82 Standard_Boolean TB=MyIsTangent;
88 MyParOnS1 = MyParOnS1bis;
89 MyParOnS2 = MyParOnS2bis;
90 MyIsTangent = MyIsTangentbis;
105 MyIsTangent = Standard_True;
107 static TColStd_Array1OfReal Param(1,4);
108 Param(1) = u1; Param(2) = v1;
109 Param(3) = u2; Param(4) = v2;
110 math_FunctionSetRoot Rsnld(MyIntersectionOn2S.Function());
111 MyIntersectionOn2S.Perform(Param,Rsnld);
112 if (!MyIntersectionOn2S.IsDone()) {
113 MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
114 return(Standard_False);
116 if (MyIntersectionOn2S.IsEmpty()) {
117 MyIsTangent=Standard_False;
118 //cout<<"\n----- Parametree Parametree : IsEmpty ds Compute "<<endl;
119 //Debug(u1); Debug(u2); Debug(v1); Debug(v2); cout<<endl;
120 MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
121 return(Standard_False);
123 MyHasBeenComputed = Standard_True;
124 MyPnt = P = MyIntersectionOn2S.Point().Value();
126 MyIntersectionOn2S.Point().Parameters(u1,v1,u2,v2);
127 MyParOnS1.SetCoord(tu1,tv1);
128 MyParOnS2.SetCoord(tu2,tv2);
130 if(MyIntersectionOn2S.IsTangent()) {
131 MyIsTangent=Standard_False;
132 MyHasBeenComputed = MyHasBeenComputedbis = Standard_False;
133 return(Standard_False);
135 MyTg = Tg = MyIntersectionOn2S.Direction();
136 MyTguv1 = Tguv1 = MyIntersectionOn2S.DirectionOnS1();
137 MyTguv2 = Tguv2 = MyIntersectionOn2S.DirectionOnS2();
139 //----------------------------------------------------------------------
140 //-- Si ( Tg ) TU et TV sont normes
142 //-- On a Tg = DeltaU * TU + DeltaV * TV
144 //-- soit : Tg.TU = DeltaU TU.TU + DeltaV TU.TV
145 //-- Tg.TV = DeltaU TV.TU + DeltaV TV.TV
149 //-- Tg.TU TV.TV - Tg.TV * TU.TV
150 //-- DeltaU = -------------------------------
151 //-- TU.TU TV.TV - (TU.TV)**2
153 //-- Tg.TV TU.TU - Tg.TU * TU.TV
154 //-- DeltaV = -------------------------------
155 //-- TU.TU TV.TV - (TU.TV)**2
159 Tg.Normalize(); MyTg = Tg;
161 Standard_Real DeltaU,DeltaV;
164 Standard_Real TUTV,TgTU,TgTV,TUTU,TVTV,DIS;
165 //------------------------------------------------------------
168 ThePSurfaceTool::D1(MySurf1,u1,v1,Pbid,TU,TV);
175 DIS = TUTU * TVTV - TUTV * TUTV;
177 DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ;
178 DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
180 Tguv1.SetCoord(DeltaU,DeltaV); MyTguv1 = Tguv1;
182 //------------------------------------------------------------
185 ThePSurfaceTool::D1(MySurf2,u2,v2,Pbid,TU,TV);
192 DIS = TUTU * TVTV - TUTV * TUTV;
194 DeltaU = (TgTU * TVTV - TgTV * TUTV ) / DIS ;
195 DeltaV = (TgTV * TUTU - TgTU * TUTV ) / DIS ;
197 Tguv2.SetCoord(DeltaU,DeltaV); MyTguv2 = Tguv2;
199 return(Standard_True);
201 //--------------------------------------------------------------------------------
202 void ApproxInt_PrmPrmSvSurfaces::Pnt(const Standard_Real u1,
203 const Standard_Real v1,
204 const Standard_Real u2,
205 const Standard_Real v2,
210 Standard_Real tu1=u1;
211 Standard_Real tu2=u2;
212 Standard_Real tv1=v1;
213 Standard_Real tv2=v2;
215 Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
217 this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
221 //--------------------------------------------------------------------------------
222 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::Tangency(const Standard_Real u1,
223 const Standard_Real v1,
224 const Standard_Real u2,
225 const Standard_Real v2,
230 Standard_Real tu1=u1;
231 Standard_Real tu2=u2;
232 Standard_Real tv1=v1;
233 Standard_Real tv2=v2;
234 Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
238 //--------------------------------------------------------------------------------
239 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf1(const Standard_Real u1,
240 const Standard_Real v1,
241 const Standard_Real u2,
242 const Standard_Real v2,
247 Standard_Real tu1=u1;
248 Standard_Real tu2=u2;
249 Standard_Real tv1=v1;
250 Standard_Real tv2=v2;
251 Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
255 //--------------------------------------------------------------------------------
256 Standard_Boolean ApproxInt_PrmPrmSvSurfaces::TangencyOnSurf2(const Standard_Real u1,
257 const Standard_Real v1,
258 const Standard_Real u2,
259 const Standard_Real v2,
264 Standard_Real tu1=u1;
265 Standard_Real tu2=u2;
266 Standard_Real tv1=v1;
267 Standard_Real tv2=v2;
268 Standard_Boolean t=this->Compute(tu1,tv1,tu2,tv2,aP,aT,aTS1,aTS2);
272 //--------------------------------------------------------------------------------
278 //------------------------------------------------------------
281 ThePSurfaceTool::D1(MySurf1,u1,v1,P,TU,TV);
286 UmTUTV2 = 1.0 - TUTV * TUTV;
288 DeltaU = (TgTU - TgTV * TUTV ) / UmTUTV2 ;
289 DeltaV = (TgTV - TgTU * TUTV ) / UmTUTV2 ;
291 Delta = 1.0 / Sqrt(DeltaU * DeltaU + DeltaV * DeltaV);
293 Tguv1.Multiplied(Delta); MyTguv1 = Tguv1;
295 //------------------------------------------------------------
298 ThePSurfaceTool::D1(MySurf2,u2,v2,P,TU,TV);
303 UmTUTV2 = 1.0 - TUTV * TUTV;
305 DeltaU = (TgTU - TgTV * TUTV ) / UmTUTV2 ;
306 DeltaV = (TgTV - TgTU * TUTV ) / UmTUTV2 ;
308 Delta = 1.0 / Sqrt(DeltaU * DeltaU + DeltaV * DeltaV);
310 Tguv2.Multiplied(Delta); MyTguv2 = Tguv2;
312 return(Standard_True);