0022651: Impossible to build OCC as static library due to using Standard_EXPORT inste...
[occt.git] / src / IntImp / IntImp_Int2S.gxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
0797d9d3 15#ifndef OCCT_DEBUG
7fd59977 16#define No_Standard_RangeError
17#define No_Standard_OutOfRange
18#endif
19
20
21#include <IntImp_ComputeTangence.hxx>
22#include <math_FunctionSetRoot.hxx>
23#include <math_Vector.hxx>
24#include <IntImp_ConstIsoparametric.hxx>
25#include <Standard_ConstructionError.hxx>
26#include <Precision.hxx>
c63628e8 27
7fd59977 28IntImp_Int2S::IntImp_Int2S(const ThePSurface& surf1,
c63628e8 29 const ThePSurface& surf2,
30 const Standard_Real TolTangency ) :
31done(Standard_True),
32empty(Standard_True),
33myZerParFunc(surf1,surf2),
34tol(TolTangency*TolTangency)
7fd59977 35{
36 ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
37 va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
38 ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
39 va1 = ThePSurfaceTool::LastVParameter(surf1); //-- ThePSurfaceTool::VIntervalLast(surf1);
c63628e8 40
7fd59977 41 ub0 = ThePSurfaceTool::FirstUParameter(surf2); //-- ThePSurfaceTool::UIntervalFirst(surf2);
42 vb0 = ThePSurfaceTool::FirstVParameter(surf2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
43 ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
44 vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
c63628e8 45
7fd59977 46 ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
47 vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
c63628e8 48
7fd59977 49 ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
50 vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
51}
52
53
54IntImp_Int2S::IntImp_Int2S(const TColStd_Array1OfReal& Param,
c63628e8 55 const ThePSurface& surf1,
56 const ThePSurface& surf2,
57 const Standard_Real TolTangency ) :
58done(Standard_True),
59empty(Standard_True),
60myZerParFunc(surf1,surf2),
61tol(TolTangency*TolTangency)
7fd59977 62{
63 math_FunctionSetRoot Rsnld(myZerParFunc,15); //-- Modif lbr 18 MAI ?????????????
64 ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
65 va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
66 ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
67 va1 = ThePSurfaceTool::LastVParameter(surf1); //-- ThePSurfaceTool::VIntervalLast(surf1);
c63628e8 68
7fd59977 69 ub0 = ThePSurfaceTool::FirstUParameter(surf2); //-- ThePSurfaceTool::UIntervalFirst(surf2);
70 vb0 = ThePSurfaceTool::FirstVParameter(surf2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
71 ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
72 vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
c63628e8 73
7fd59977 74 ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
75 vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
c63628e8 76
7fd59977 77 ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
78 vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
79 Perform(Param,Rsnld);
80}
81
c63628e8 82IntImp_ConstIsoparametric IntImp_Int2S:: Perform(const TColStd_Array1OfReal& Param,
83 math_FunctionSetRoot& Rsnld,
84 const IntImp_ConstIsoparametric ChoixIso)
7fd59977 85{
41194117
K
86 Standard_Real BornInfBuf[3], BornSupBuf[3], ToleranceBuf[3], UVapBuf[3];
87 Standard_Real UvresBuf[4];
c63628e8 88 math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3),
89 Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3);
41194117
K
90 TColStd_Array1OfReal Uvres (UvresBuf[0], 1, 4);
91
7fd59977 92 IntImp_ConstIsoparametric BestChoix;
c63628e8 93
94 myZerParFunc.ComputeParameters(ChoixIso,Param,UVap,BornInf,BornSup,Tolerance);
7fd59977 95 Rsnld.SetTolerance(Tolerance);
96 Rsnld.Perform(myZerParFunc,UVap,BornInf,BornSup);
97 BestChoix = ChoixIso;
98 if (Rsnld.IsDone()) {
99 if (Abs(myZerParFunc.Root()) <= tol) { //distance des 2 points
100 // dans la tolerance
101 Rsnld.Root(UVap);
102 empty = Standard_False;
103 tangent = myZerParFunc.IsTangent(UVap,Uvres,BestChoix);
104 pint.SetValue(myZerParFunc.Point(),Uvres(1),Uvres(2),Uvres(3),Uvres(4));
105 if (!tangent) {
c63628e8 106 d3d = myZerParFunc.Direction();
107 d2d1 = myZerParFunc.DirectionOnS1();
108 d2d2 = myZerParFunc.DirectionOnS2();
7fd59977 109 }
110 }
111 else {
112 empty = Standard_True;
113 }
114 }
115 else {
116 empty = Standard_True;
117 }
118 return BestChoix;
119}
120
c63628e8 121IntImp_ConstIsoparametric IntImp_Int2S:: Perform(const TColStd_Array1OfReal& Param,
122 math_FunctionSetRoot& Rsnld)
7fd59977 123{
124 gp_Vec DPUV[4];
125 gp_Pnt P1,P2;
126 Standard_Real Epsuv[4];
41194117
K
127 Standard_Real DuvBuf[4];
128 TColStd_Array1OfReal Duv (DuvBuf[0], 1, 4);
7fd59977 129 Standard_Real UVd[4],UVf[4];
130 IntImp_ConstIsoparametric ChoixIso[4];
68df8478 131 IntImp_ConstIsoparametric BestChoix = ChoixRef(0);
7fd59977 132 const ThePSurface& Caro1 = myZerParFunc.AuxillarSurface1();
133 const ThePSurface& Caro2 = myZerParFunc.AuxillarSurface2();
134
135 ThePSurfaceTool::D1(Caro1, Param(1),Param(2),P1,DPUV[0],DPUV[1]);
136 ThePSurfaceTool::D1(Caro2, Param(3),Param(4),P2,DPUV[2],DPUV[3]);
137
138 Epsuv[0] = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion());
139 Epsuv[1] = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion());
140
141 Epsuv[2] = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion());
142 Epsuv[3] = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion());
143
c63628e8 144 for (Standard_Integer j=0;j<=3;j++)
145 UVd[j] = Param(j+1);
7fd59977 146
147 empty = Standard_True;
148
149 Standard_Boolean Tangent = IntImp_ComputeTangence(DPUV,Epsuv,UVd,ChoixIso);
c63628e8 150 if (Tangent)
151 return BestChoix;
152
7fd59977 153 Standard_Integer i=0;
154 IntImp_ConstIsoparametric CurrentChoix = BestChoix; //-- Modif 17 Mai 93
c63628e8 155
156 while (empty && i<= 3)
157 {
7fd59977 158 CurrentChoix = Perform(Param,Rsnld,ChoixIso[i]);
159 if(!empty) {
160 BestChoix = CurrentChoix;
161 }
162 i++;
163 }
164 if (!empty) { // verifier que l on ne deborde pas les frontieres
165 pint.Parameters(Duv(1),Duv(2),Duv(3),Duv(4));
c63628e8 166
7fd59977 167 UVd[0] = ua0; //-- ThePSurfaceTool::UIntervalFirst(Caro1);
168 UVd[1] = va0; //-- ThePSurfaceTool::VIntervalFirst(Caro1);
169 UVf[0] = ua1; //-- ThePSurfaceTool::UIntervalLast(Caro1);
170 UVf[1] = va1; //-- ThePSurfaceTool::VIntervalLast(Caro1);
171
172 UVd[2] = ub0; //-- ThePSurfaceTool::UIntervalFirst(Caro2);
173 UVd[3] = vb0; //-- ubThePSurfaceTool::VIntervalFirst(Caro2);
174 UVf[2] = ub1; //-- ThePSurfaceTool::UIntervalLast(Caro2);
175 UVf[3] = vb1; //-- ThePSurfaceTool::VIntervalLast(Caro2);
c63628e8 176
7fd59977 177 Standard_Integer Nc,Iiso;
178 if (Duv(1) <= UVd[0]-Epsuv[0]) {
179 Duv(1) = UVd[0];
180 Nc =0;
181 Iiso=0;
182 }
183 else if (Duv(1) >= UVf[0]+ Epsuv[0]) {
184 Duv(1) = UVf[0];
185 Nc =0;
186 Iiso=0;
187 }
188 else if (Duv(2) <= UVd[1] -Epsuv[1]) {
189 Duv(2) = UVd[1];
190 Nc =0;
191 Iiso=1;
192 }
193 else if (Duv(2) >= UVf[1]+Epsuv[1]) {
194 Duv(2) = UVf[1];
195 Nc =0;
196 Iiso=1;
197 }
198 else if (Duv(3) <= UVd[2]-Epsuv[2]) {
199 Duv(3) = UVd[2];
200 Nc =2;
201 Iiso = 2;
202 }
203 else if (Duv(3) >= UVf[2]+Epsuv[2]) {
204 Duv(3) = UVf[2];
205 Nc =2;
206 Iiso = 2;
207 }
208 else if (Duv(4) <= UVd[3]-Epsuv[3]) {
209 Duv(4) = UVd[3];
210 Nc =2;
211 Iiso = 3;
212 }
213 else if (Duv(4) >= UVf[3]+Epsuv[3]) {
214 Duv(4) = UVf[3];
215 Nc =2;
216 Iiso =3;
217 }
218 else return BestChoix; // on a gagne
219 empty = Standard_True;
68df8478 220 BestChoix = ChoixRef(Iiso); //en attendant
7fd59977 221 BestChoix = Perform(Duv,Rsnld,BestChoix);
222 if (!empty) { // verification si l on ne deborde pas sur le carreau
223 // reciproque
224 Nc =3-Nc;
c63628e8 225 if (Duv(Nc) <= UVd[Nc-1]-Epsuv[Nc-1])
226 Duv(Nc)=UVd[Nc-1];
227 else if (Duv(Nc) >=UVf[Nc-1]+Epsuv[Nc-1])
228 Duv(Nc)=UVf[Nc-1];
229 else if (Duv(Nc+1) <= UVd[Nc])
230 {
231 Nc = Nc + 1;
232 Duv(Nc)=UVd[Nc-1];
7fd59977 233 }
c63628e8 234 else if (Duv(Nc+1) >=UVf[Nc])
235 {
236 Nc = Nc + 1;
237 Duv(Nc)=UVf[Nc-1];
7fd59977 238 }
c63628e8 239 else
240 return BestChoix;
241
7fd59977 242 empty = Standard_True;
c63628e8 243
244 if(Nc == 4)
245 Nc = 0;
246
68df8478 247 BestChoix = ChoixRef(Nc); //en attendant
7fd59977 248 BestChoix = Perform(Duv,Rsnld,BestChoix);
249 }
250 }
251 return BestChoix;
252}