Warning, /include/opencascade/IntImp_Int2S.gxx is written in an unsupported language. File is not indexed.
0001 // Copyright (c) 1995-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014
0015 #ifndef OCCT_DEBUG
0016 #define No_Standard_RangeError
0017 #define No_Standard_OutOfRange
0018 #endif
0019
0020
0021 #include <IntImp_ComputeTangence.hxx>
0022 #include <math_FunctionSetRoot.hxx>
0023 #include <math_Vector.hxx>
0024 #include <IntImp_ConstIsoparametric.hxx>
0025 #include <Standard_ConstructionError.hxx>
0026 #include <Precision.hxx>
0027
0028 IntImp_Int2S::IntImp_Int2S(const ThePSurface& surf1,
0029 const ThePSurface& surf2,
0030 const Standard_Real TolTangency ) :
0031 done(Standard_True),
0032 empty(Standard_True),
0033 tangent(Standard_False),
0034 myZerParFunc(surf1,surf2),
0035 tol(TolTangency*TolTangency)
0036 {
0037 ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
0038 va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
0039 ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
0040 va1 = ThePSurfaceTool::LastVParameter(surf1); //-- ThePSurfaceTool::VIntervalLast(surf1);
0041
0042 ub0 = ThePSurfaceTool::FirstUParameter(surf2); //-- ThePSurfaceTool::UIntervalFirst(surf2);
0043 vb0 = ThePSurfaceTool::FirstVParameter(surf2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
0044 ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
0045 vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
0046
0047 ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
0048 vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
0049
0050 ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
0051 vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
0052 }
0053
0054
0055 IntImp_Int2S::IntImp_Int2S(const TColStd_Array1OfReal& Param,
0056 const ThePSurface& surf1,
0057 const ThePSurface& surf2,
0058 const Standard_Real TolTangency ) :
0059 done(Standard_True),
0060 empty(Standard_True),
0061 myZerParFunc(surf1,surf2),
0062 tol(TolTangency*TolTangency)
0063 {
0064 math_FunctionSetRoot Rsnld(myZerParFunc,15); //-- Modif lbr 18 MAI ?????????????
0065 ua0 = ThePSurfaceTool::FirstUParameter(surf1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
0066 va0 = ThePSurfaceTool::FirstVParameter(surf1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
0067 ua1 = ThePSurfaceTool::LastUParameter(surf1); //-- ThePSurfaceTool::UIntervalLast(surf1);
0068 va1 = ThePSurfaceTool::LastVParameter(surf1); //-- ThePSurfaceTool::VIntervalLast(surf1);
0069
0070 ub0 = ThePSurfaceTool::FirstUParameter(surf2); //-- ThePSurfaceTool::UIntervalFirst(surf2);
0071 vb0 = ThePSurfaceTool::FirstVParameter(surf2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
0072 ub1 = ThePSurfaceTool::LastUParameter(surf2); //-- ThePSurfaceTool::UIntervalLast(surf2);
0073 vb1 = ThePSurfaceTool::LastVParameter(surf2); //-- ThePSurfaceTool::VIntervalLast(surf2);
0074
0075 ures1 = ThePSurfaceTool::UResolution(surf1,Precision::Confusion());
0076 vres1 = ThePSurfaceTool::VResolution(surf1,Precision::Confusion());
0077
0078 ures2 = ThePSurfaceTool::UResolution(surf2,Precision::Confusion());
0079 vres2 = ThePSurfaceTool::VResolution(surf2,Precision::Confusion());
0080 Perform(Param,Rsnld);
0081 }
0082
0083 IntImp_ConstIsoparametric IntImp_Int2S:: Perform(const TColStd_Array1OfReal& Param,
0084 math_FunctionSetRoot& Rsnld,
0085 const IntImp_ConstIsoparametric ChoixIso)
0086 {
0087 Standard_Real BornInfBuf[3] = {}, BornSupBuf[3] = {}, ToleranceBuf[3] = {}, UVapBuf[3] = {};
0088 Standard_Real UvresBuf[4] = {};
0089 math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3),
0090 Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3);
0091 TColStd_Array1OfReal Uvres (UvresBuf[0], 1, 4);
0092
0093 IntImp_ConstIsoparametric BestChoix;
0094
0095 myZerParFunc.ComputeParameters(ChoixIso,Param,UVap,BornInf,BornSup,Tolerance);
0096 Rsnld.SetTolerance(Tolerance);
0097 Rsnld.Perform(myZerParFunc,UVap,BornInf,BornSup);
0098 BestChoix = ChoixIso;
0099 if (Rsnld.IsDone()) {
0100 if (Abs(myZerParFunc.Root()) <= tol) { //distance des 2 points
0101 // dans la tolerance
0102 Rsnld.Root(UVap);
0103 empty = Standard_False;
0104 tangent = myZerParFunc.IsTangent(UVap,Uvres,BestChoix);
0105 pint.SetValue(myZerParFunc.Point(),Uvres(1),Uvres(2),Uvres(3),Uvres(4));
0106 if (!tangent) {
0107 d3d = myZerParFunc.Direction();
0108 d2d1 = myZerParFunc.DirectionOnS1();
0109 d2d2 = myZerParFunc.DirectionOnS2();
0110 }
0111 }
0112 else {
0113 empty = Standard_True;
0114 }
0115 }
0116 else {
0117 empty = Standard_True;
0118 }
0119 return BestChoix;
0120 }
0121
0122 IntImp_ConstIsoparametric IntImp_Int2S:: Perform(const TColStd_Array1OfReal& Param,
0123 math_FunctionSetRoot& Rsnld)
0124 {
0125 gp_Vec DPUV[4];
0126 gp_Pnt P1,P2;
0127 Standard_Real Epsuv[4];
0128 Standard_Real DuvBuf[4];
0129 TColStd_Array1OfReal Duv (DuvBuf[0], 1, 4);
0130 Standard_Real UVd[4],UVf[4];
0131 IntImp_ConstIsoparametric ChoixIso[4];
0132 IntImp_ConstIsoparametric BestChoix = ChoixRef(0);
0133 const ThePSurface& Caro1 = myZerParFunc.AuxillarSurface1();
0134 const ThePSurface& Caro2 = myZerParFunc.AuxillarSurface2();
0135
0136 ThePSurfaceTool::D1(Caro1, Param(1),Param(2),P1,DPUV[0],DPUV[1]);
0137 ThePSurfaceTool::D1(Caro2, Param(3),Param(4),P2,DPUV[2],DPUV[3]);
0138
0139 Epsuv[0] = ThePSurfaceTool::UResolution(Caro1,Precision::Confusion());
0140 Epsuv[1] = ThePSurfaceTool::VResolution(Caro1,Precision::Confusion());
0141
0142 Epsuv[2] = ThePSurfaceTool::UResolution(Caro2,Precision::Confusion());
0143 Epsuv[3] = ThePSurfaceTool::VResolution(Caro2,Precision::Confusion());
0144
0145 for (Standard_Integer j=0;j<=3;j++)
0146 UVd[j] = Param(j+1);
0147
0148 empty = Standard_True;
0149
0150 Standard_Boolean Tangent = IntImp_ComputeTangence(DPUV,Epsuv,UVd,ChoixIso);
0151 if (Tangent)
0152 return BestChoix;
0153
0154 Standard_Integer i=0;
0155 IntImp_ConstIsoparametric CurrentChoix = BestChoix; //-- Modif 17 Mai 93
0156
0157 while (empty && i<= 3)
0158 {
0159 CurrentChoix = Perform(Param,Rsnld,ChoixIso[i]);
0160 if(!empty) {
0161 BestChoix = CurrentChoix;
0162 }
0163 i++;
0164 }
0165 if (!empty) { // verifier que l on ne deborde pas les frontieres
0166 pint.Parameters(Duv(1),Duv(2),Duv(3),Duv(4));
0167
0168 UVd[0] = ua0; //-- ThePSurfaceTool::UIntervalFirst(Caro1);
0169 UVd[1] = va0; //-- ThePSurfaceTool::VIntervalFirst(Caro1);
0170 UVf[0] = ua1; //-- ThePSurfaceTool::UIntervalLast(Caro1);
0171 UVf[1] = va1; //-- ThePSurfaceTool::VIntervalLast(Caro1);
0172
0173 UVd[2] = ub0; //-- ThePSurfaceTool::UIntervalFirst(Caro2);
0174 UVd[3] = vb0; //-- ubThePSurfaceTool::VIntervalFirst(Caro2);
0175 UVf[2] = ub1; //-- ThePSurfaceTool::UIntervalLast(Caro2);
0176 UVf[3] = vb1; //-- ThePSurfaceTool::VIntervalLast(Caro2);
0177
0178 Standard_Integer Nc,Iiso;
0179 if (Duv(1) <= UVd[0]-Epsuv[0]) {
0180 Duv(1) = UVd[0];
0181 Nc =0;
0182 Iiso=0;
0183 }
0184 else if (Duv(1) >= UVf[0]+ Epsuv[0]) {
0185 Duv(1) = UVf[0];
0186 Nc =0;
0187 Iiso=0;
0188 }
0189 else if (Duv(2) <= UVd[1] -Epsuv[1]) {
0190 Duv(2) = UVd[1];
0191 Nc =0;
0192 Iiso=1;
0193 }
0194 else if (Duv(2) >= UVf[1]+Epsuv[1]) {
0195 Duv(2) = UVf[1];
0196 Nc =0;
0197 Iiso=1;
0198 }
0199 else if (Duv(3) <= UVd[2]-Epsuv[2]) {
0200 Duv(3) = UVd[2];
0201 Nc =2;
0202 Iiso = 2;
0203 }
0204 else if (Duv(3) >= UVf[2]+Epsuv[2]) {
0205 Duv(3) = UVf[2];
0206 Nc =2;
0207 Iiso = 2;
0208 }
0209 else if (Duv(4) <= UVd[3]-Epsuv[3]) {
0210 Duv(4) = UVd[3];
0211 Nc =2;
0212 Iiso = 3;
0213 }
0214 else if (Duv(4) >= UVf[3]+Epsuv[3]) {
0215 Duv(4) = UVf[3];
0216 Nc =2;
0217 Iiso =3;
0218 }
0219 else return BestChoix; // on a gagne
0220 empty = Standard_True;
0221 BestChoix = ChoixRef(Iiso); //en attendant
0222 BestChoix = Perform(Duv,Rsnld,BestChoix);
0223 if (!empty) { // verification si l on ne deborde pas sur le carreau
0224 // reciproque
0225 Nc =3-Nc;
0226 if (Duv(Nc) <= UVd[Nc-1]-Epsuv[Nc-1])
0227 Duv(Nc)=UVd[Nc-1];
0228 else if (Duv(Nc) >=UVf[Nc-1]+Epsuv[Nc-1])
0229 Duv(Nc)=UVf[Nc-1];
0230 else if (Duv(Nc+1) <= UVd[Nc])
0231 {
0232 Nc = Nc + 1;
0233 Duv(Nc)=UVd[Nc-1];
0234 }
0235 else if (Duv(Nc+1) >=UVf[Nc])
0236 {
0237 Nc = Nc + 1;
0238 Duv(Nc)=UVf[Nc-1];
0239 }
0240 else
0241 return BestChoix;
0242
0243 empty = Standard_True;
0244
0245 if(Nc == 4)
0246 Nc = 0;
0247
0248 BestChoix = ChoixRef(Nc); //en attendant
0249 BestChoix = Perform(Duv,Rsnld,BestChoix);
0250 }
0251 }
0252 return BestChoix;
0253 }