7fd59977 |
1 | //-- File IntImp_Int2S.gxx |
2 | |
3 | |
4 | #ifndef DEB |
5 | #define No_Standard_RangeError |
6 | #define No_Standard_OutOfRange |
7 | #endif |
8 | |
9 | |
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> |
16 | |
17 | |
18 | //Standard_IMPORT extern IntImp_ConstIsoparametric *ChoixRef; |
19 | |
20 | |
21 | IntImp_Int2S::IntImp_Int2S() { |
22 | Standard_ConstructionError::Raise(" Empty Constructor : IntImp_Int2S"); |
23 | } |
24 | |
25 | |
26 | IntImp_Int2S::IntImp_Int2S(const ThePSurface& surf1, |
27 | const ThePSurface& surf2, |
28 | const Standard_Real TolTangency ) : |
29 | done(Standard_True), |
30 | empty(Standard_True), |
31 | myZerParFunc(surf1,surf2), |
32 | tol(TolTangency*TolTangency) |
33 | { |
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); |
38 | |
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); |
43 | |
44 | ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion()); |
45 | vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion()); |
46 | |
47 | ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion()); |
48 | vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion()); |
49 | } |
50 | |
51 | |
52 | IntImp_Int2S::IntImp_Int2S(const TColStd_Array1OfReal& Param, |
53 | const ThePSurface& surf1, |
54 | const ThePSurface& surf2, |
55 | const Standard_Real TolTangency ) : |
56 | done(Standard_True), |
57 | empty(Standard_True), |
58 | myZerParFunc(surf1,surf2), |
59 | tol(TolTangency*TolTangency) |
60 | { |
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); |
66 | |
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); |
71 | |
72 | ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion()); |
73 | vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion()); |
74 | |
75 | ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion()); |
76 | vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion()); |
77 | Perform(Param,Rsnld); |
78 | } |
79 | |
80 | IntImp_ConstIsoparametric IntImp_Int2S:: |
81 | Perform(const TColStd_Array1OfReal& Param, |
82 | math_FunctionSetRoot& Rsnld, |
83 | const IntImp_ConstIsoparametric ChoixIso ) |
84 | { |
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); |
92 | BestChoix = ChoixIso; |
93 | if (Rsnld.IsDone()) { |
94 | if (Abs(myZerParFunc.Root()) <= tol) { //distance des 2 points |
95 | // dans la tolerance |
96 | Rsnld.Root(UVap); |
97 | empty = Standard_False; |
98 | tangent = myZerParFunc.IsTangent(UVap,Uvres,BestChoix); |
99 | pint.SetValue(myZerParFunc.Point(),Uvres(1),Uvres(2),Uvres(3),Uvres(4)); |
100 | if (!tangent) { |
101 | d3d = myZerParFunc.Direction(); |
102 | d2d1 = myZerParFunc.DirectionOnS1(); |
103 | d2d2 = myZerParFunc.DirectionOnS2(); |
104 | } |
105 | } |
106 | else { |
107 | empty = Standard_True; |
108 | } |
109 | } |
110 | else { |
111 | empty = Standard_True; |
112 | } |
113 | return BestChoix; |
114 | } |
115 | |
116 | IntImp_ConstIsoparametric IntImp_Int2S:: Perform( |
117 | const TColStd_Array1OfReal& Param, |
118 | math_FunctionSetRoot& Rsnld) |
119 | { |
120 | gp_Vec DPUV[4]; |
121 | gp_Pnt P1,P2; |
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(); |
129 | |
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]); |
132 | |
133 | Epsuv[0] = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion()); |
134 | Epsuv[1] = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion()); |
135 | |
136 | Epsuv[2] = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion()); |
137 | Epsuv[3] = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion()); |
138 | |
139 | for (Standard_Integer j=0;j<=3;j++) UVd[j] = Param(j+1); |
140 | |
141 | empty = Standard_True; |
142 | |
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]); |
149 | if(!empty) { |
150 | BestChoix = CurrentChoix; |
151 | } |
152 | i++; |
153 | } |
154 | if (!empty) { // verifier que l on ne deborde pas les frontieres |
155 | pint.Parameters(Duv(1),Duv(2),Duv(3),Duv(4)); |
156 | |
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); |
161 | |
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); |
166 | |
167 | Standard_Integer Nc,Iiso; |
168 | if (Duv(1) <= UVd[0]-Epsuv[0]) { |
169 | Duv(1) = UVd[0]; |
170 | Nc =0; |
171 | Iiso=0; |
172 | } |
173 | else if (Duv(1) >= UVf[0]+ Epsuv[0]) { |
174 | Duv(1) = UVf[0]; |
175 | Nc =0; |
176 | Iiso=0; |
177 | } |
178 | else if (Duv(2) <= UVd[1] -Epsuv[1]) { |
179 | Duv(2) = UVd[1]; |
180 | Nc =0; |
181 | Iiso=1; |
182 | } |
183 | else if (Duv(2) >= UVf[1]+Epsuv[1]) { |
184 | Duv(2) = UVf[1]; |
185 | Nc =0; |
186 | Iiso=1; |
187 | } |
188 | else if (Duv(3) <= UVd[2]-Epsuv[2]) { |
189 | Duv(3) = UVd[2]; |
190 | Nc =2; |
191 | Iiso = 2; |
192 | } |
193 | else if (Duv(3) >= UVf[2]+Epsuv[2]) { |
194 | Duv(3) = UVf[2]; |
195 | Nc =2; |
196 | Iiso = 2; |
197 | } |
198 | else if (Duv(4) <= UVd[3]-Epsuv[3]) { |
199 | Duv(4) = UVd[3]; |
200 | Nc =2; |
201 | Iiso = 3; |
202 | } |
203 | else if (Duv(4) >= UVf[3]+Epsuv[3]) { |
204 | Duv(4) = UVf[3]; |
205 | Nc =2; |
206 | Iiso =3; |
207 | } |
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 |
213 | // reciproque |
214 | Nc =3-Nc; |
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]) { |
218 | Nc = Nc +1; |
219 | Duv(Nc)=UVd[Nc-1]; |
220 | } |
221 | else if (Duv(Nc+1) >=UVf[Nc]) { |
222 | Nc = Nc +1; |
223 | Duv(Nc)=UVf[Nc-1]; |
224 | } |
225 | else return BestChoix; |
226 | empty = Standard_True; |
227 | BestChoix = ChoixRef[Nc]; //en attendant |
228 | BestChoix = Perform(Duv,Rsnld,BestChoix); |
229 | } |
230 | } |
231 | return BestChoix; |
232 | } |
233 | |
234 | |
235 | |