1 //-- File IntImp_Int2S.gxx
5 #define No_Standard_RangeError
6 #define No_Standard_OutOfRange
10 #include <IntImp_ComputeTangence.hxx>
11 #include <math_FunctionSetRoot.hxx>
12 #include <math_Vector.hxx>
13 #include <IntImp_ConstIsoparametric.hxx>
14 #include <Standard_ConstructionError.hxx>
15 #include <Precision.hxx>
18 //Standard_IMPORT extern IntImp_ConstIsoparametric *ChoixRef;
21 IntImp_Int2S::IntImp_Int2S() {
22 Standard_ConstructionError::Raise(" Empty Constructor : IntImp_Int2S");
26 IntImp_Int2S::IntImp_Int2S(const ThePSurface& surf1,
27 const ThePSurface& surf2,
28 const Standard_Real TolTangency ) :
31 myZerParFunc(surf1,surf2),
32 tol(TolTangency*TolTangency)
34 ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
35 va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
36 ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
37 va1 = ThePSurfaceTool::LastVParameter(surf1); //-- ThePSurfaceTool::VIntervalLast(surf1);
39 ub0 = ThePSurfaceTool::FirstUParameter(surf2); //-- ThePSurfaceTool::UIntervalFirst(surf2);
40 vb0 = ThePSurfaceTool::FirstVParameter(surf2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
41 ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
42 vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
44 ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
45 vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
47 ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
48 vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
52 IntImp_Int2S::IntImp_Int2S(const TColStd_Array1OfReal& Param,
53 const ThePSurface& surf1,
54 const ThePSurface& surf2,
55 const Standard_Real TolTangency ) :
58 myZerParFunc(surf1,surf2),
59 tol(TolTangency*TolTangency)
61 math_FunctionSetRoot Rsnld(myZerParFunc,15); //-- Modif lbr 18 MAI ?????????????
62 ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
63 va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
64 ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
65 va1 = ThePSurfaceTool::LastVParameter(surf1); //-- ThePSurfaceTool::VIntervalLast(surf1);
67 ub0 = ThePSurfaceTool::FirstUParameter(surf2); //-- ThePSurfaceTool::UIntervalFirst(surf2);
68 vb0 = ThePSurfaceTool::FirstVParameter(surf2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
69 ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
70 vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
72 ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
73 vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
75 ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
76 vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
80 IntImp_ConstIsoparametric IntImp_Int2S::
81 Perform(const TColStd_Array1OfReal& Param,
82 math_FunctionSetRoot& Rsnld,
83 const IntImp_ConstIsoparametric ChoixIso )
85 static math_Vector BornInf(1,3),BornSup(1,3),Tolerance(1,3),UVap(1,3);
86 static TColStd_Array1OfReal Uvres(1,4);
87 IntImp_ConstIsoparametric BestChoix;
88 myZerParFunc.ComputeParameters(ChoixIso,Param,UVap,
89 BornInf,BornSup,Tolerance);
90 Rsnld.SetTolerance(Tolerance);
91 Rsnld.Perform(myZerParFunc,UVap,BornInf,BornSup);
94 if (Abs(myZerParFunc.Root()) <= tol) { //distance des 2 points
97 empty = Standard_False;
98 tangent = myZerParFunc.IsTangent(UVap,Uvres,BestChoix);
99 pint.SetValue(myZerParFunc.Point(),Uvres(1),Uvres(2),Uvres(3),Uvres(4));
101 d3d = myZerParFunc.Direction();
102 d2d1 = myZerParFunc.DirectionOnS1();
103 d2d2 = myZerParFunc.DirectionOnS2();
107 empty = Standard_True;
111 empty = Standard_True;
116 IntImp_ConstIsoparametric IntImp_Int2S:: Perform(
117 const TColStd_Array1OfReal& Param,
118 math_FunctionSetRoot& Rsnld)
122 Standard_Real Epsuv[4];
123 static TColStd_Array1OfReal Duv(1,4);
124 Standard_Real UVd[4],UVf[4];
125 IntImp_ConstIsoparametric ChoixIso[4];
126 IntImp_ConstIsoparametric BestChoix=ChoixRef[0];
127 const ThePSurface& Caro1 = myZerParFunc.AuxillarSurface1();
128 const ThePSurface& Caro2 = myZerParFunc.AuxillarSurface2();
130 ThePSurfaceTool::D1(Caro1, Param(1),Param(2),P1,DPUV[0],DPUV[1]);
131 ThePSurfaceTool::D1(Caro2, Param(3),Param(4),P2,DPUV[2],DPUV[3]);
133 Epsuv[0] = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion());
134 Epsuv[1] = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion());
136 Epsuv[2] = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion());
137 Epsuv[3] = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion());
139 for (Standard_Integer j=0;j<=3;j++) UVd[j] = Param(j+1);
141 empty = Standard_True;
143 Standard_Boolean Tangent = IntImp_ComputeTangence(DPUV,Epsuv,UVd,ChoixIso);
144 if (Tangent) return BestChoix;
145 Standard_Integer i=0;
146 IntImp_ConstIsoparametric CurrentChoix = BestChoix; //-- Modif 17 Mai 93
147 while (empty && i<= 3) {
148 CurrentChoix = Perform(Param,Rsnld,ChoixIso[i]);
150 BestChoix = CurrentChoix;
154 if (!empty) { // verifier que l on ne deborde pas les frontieres
155 pint.Parameters(Duv(1),Duv(2),Duv(3),Duv(4));
157 UVd[0] = ua0; //-- ThePSurfaceTool::UIntervalFirst(Caro1);
158 UVd[1] = va0; //-- ThePSurfaceTool::VIntervalFirst(Caro1);
159 UVf[0] = ua1; //-- ThePSurfaceTool::UIntervalLast(Caro1);
160 UVf[1] = va1; //-- ThePSurfaceTool::VIntervalLast(Caro1);
162 UVd[2] = ub0; //-- ThePSurfaceTool::UIntervalFirst(Caro2);
163 UVd[3] = vb0; //-- ubThePSurfaceTool::VIntervalFirst(Caro2);
164 UVf[2] = ub1; //-- ThePSurfaceTool::UIntervalLast(Caro2);
165 UVf[3] = vb1; //-- ThePSurfaceTool::VIntervalLast(Caro2);
167 Standard_Integer Nc,Iiso;
168 if (Duv(1) <= UVd[0]-Epsuv[0]) {
173 else if (Duv(1) >= UVf[0]+ Epsuv[0]) {
178 else if (Duv(2) <= UVd[1] -Epsuv[1]) {
183 else if (Duv(2) >= UVf[1]+Epsuv[1]) {
188 else if (Duv(3) <= UVd[2]-Epsuv[2]) {
193 else if (Duv(3) >= UVf[2]+Epsuv[2]) {
198 else if (Duv(4) <= UVd[3]-Epsuv[3]) {
203 else if (Duv(4) >= UVf[3]+Epsuv[3]) {
208 else return BestChoix; // on a gagne
209 empty = Standard_True;
210 BestChoix = ChoixRef[Iiso]; //en attendant
211 BestChoix = Perform(Duv,Rsnld,BestChoix);
212 if (!empty) { // verification si l on ne deborde pas sur le carreau
215 if (Duv(Nc) <= UVd[Nc-1]-Epsuv[Nc-1]) Duv(Nc)=UVd[Nc-1];
216 else if (Duv(Nc) >=UVf[Nc-1]+Epsuv[Nc-1]) Duv(Nc)=UVf[Nc-1];
217 else if (Duv(Nc+1) <= UVd[Nc]) {
221 else if (Duv(Nc+1) >=UVf[Nc]) {
225 else return BestChoix;
226 empty = Standard_True;
227 BestChoix = ChoixRef[Nc]; //en attendant
228 BestChoix = Perform(Duv,Rsnld,BestChoix);