Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/opencascade/IntImp_ZerParFunc.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 <Standard_ConstructionError.hxx>
0023 #include <Precision.hxx>
0024 
0025 #define SURF1 (*((ThePSurface *)(surf1)))
0026 #define SURF2 (*((ThePSurface *)(surf2)))
0027 
0028 
0029 IntImp_ZerParFunc::IntImp_ZerParFunc(const ThePSurface& S1 ,
0030                                      const ThePSurface& S2)
0031 : compute(Standard_False),
0032   tangent(Standard_False),
0033   paramConst(0.0)
0034 {
0035     surf1 = (Standard_Address)(&S1);
0036     surf2 = (Standard_Address)(&S2);
0037 
0038     ua0 = ThePSurfaceTool::FirstUParameter(SURF1); //-- ThePSurfaceTool::UIntervalFirst(surf1);
0039     va0 = ThePSurfaceTool::FirstVParameter(SURF1); //-- ThePSurfaceTool::VIntervalFirst(surf1);
0040     ua1 = ThePSurfaceTool::LastUParameter(SURF1);  //-- ThePSurfaceTool::UIntervalLast(surf1);
0041     va1 = ThePSurfaceTool::LastVParameter(SURF1);  //-- ThePSurfaceTool::VIntervalLast(surf1);
0042 
0043     ub0 = ThePSurfaceTool::FirstUParameter(SURF2); //-- ThePSurfaceTool::UIntervalFirst(SURF2);
0044     vb0 = ThePSurfaceTool::FirstVParameter(SURF2); //-- ThePSurfaceTool::VIntervalFirst(surf2);
0045     ub1 = ThePSurfaceTool::LastUParameter(SURF2);  //-- ThePSurfaceTool::UIntervalLast(surf2);
0046     vb1 = ThePSurfaceTool::LastVParameter(SURF2);  //-- ThePSurfaceTool::VIntervalLast(surf2);
0047 
0048     ures1 = ThePSurfaceTool::UResolution(SURF1,Precision::Confusion());
0049     vres1 = ThePSurfaceTool::VResolution(SURF1,Precision::Confusion());
0050 
0051     ures2 = ThePSurfaceTool::UResolution(SURF2,Precision::Confusion());
0052     vres2 = ThePSurfaceTool::VResolution(SURF2,Precision::Confusion());
0053     memset (f, 0, sizeof (f));
0054     compute = Standard_False;  
0055     tangent = Standard_False;
0056 }
0057 
0058 Standard_Integer IntImp_ZerParFunc::NbVariables() const { return 3;}
0059 
0060 Standard_Integer IntImp_ZerParFunc::NbEquations() const { return 3;}
0061 
0062 Standard_Boolean IntImp_ZerParFunc::Value(const math_Vector& X,
0063                                           math_Vector& F) {
0064 
0065   switch (chxIso) {
0066   case IntImp_UIsoparametricOnCaro1:
0067     {
0068       pntsol1= ThePSurfaceTool::Value(SURF1,paramConst,X(1));
0069       pntsol2= ThePSurfaceTool::Value(SURF2,X(2),X(3));
0070     }
0071     break;
0072   case IntImp_VIsoparametricOnCaro1:
0073     {
0074       pntsol1= ThePSurfaceTool::Value(SURF1,X(1),paramConst);
0075       pntsol2= ThePSurfaceTool::Value(SURF2,X(2),X(3));
0076     }
0077     break;
0078   case IntImp_UIsoparametricOnCaro2:
0079     {
0080       pntsol1= ThePSurfaceTool::Value(SURF1,X(1),X(2));
0081       pntsol2= ThePSurfaceTool::Value(SURF2,paramConst,X(3));
0082     }
0083     break;
0084   case IntImp_VIsoparametricOnCaro2:
0085     {
0086       pntsol1= ThePSurfaceTool::Value(SURF1,X(1),X(2));
0087       pntsol2= ThePSurfaceTool::Value(SURF2,X(3),paramConst);
0088     }
0089     break;
0090   }
0091 
0092   f[0] = F(1) = pntsol1.X() - pntsol2.X();
0093   f[1] = F(2) = pntsol1.Y() - pntsol2.Y();
0094   f[2] = F(3) = pntsol1.Z() - pntsol2.Z();
0095   return Standard_True;
0096 }
0097 
0098 Standard_Boolean IntImp_ZerParFunc::Derivatives (const math_Vector& X,
0099                                                  math_Matrix& D) {
0100   
0101   switch (chxIso) {
0102   case IntImp_UIsoparametricOnCaro1:
0103     {
0104       ThePSurfaceTool::D1(SURF1,paramConst,X(1),pntsol1,dpuv[0],dpuv[1]);
0105       ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
0106       D(1,1) = dpuv[1].X();
0107       D(1,2) =-dpuv[2].X();
0108       D(1,3) =-dpuv[3].X();
0109       D(2,1) = dpuv[1].Y();
0110       D(2,2) =-dpuv[2].Y();
0111       D(2,3) =-dpuv[3].Y();
0112       D(3,1) = dpuv[1].Z();
0113       D(3,2) =-dpuv[2].Z();
0114       D(3,3) =-dpuv[3].Z();
0115     }
0116     break;
0117   case IntImp_VIsoparametricOnCaro1:
0118     {
0119       ThePSurfaceTool::D1(SURF1,X(1),paramConst,pntsol1,dpuv[0],dpuv[1]);
0120       ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
0121       D(1,1) = dpuv[0].X();
0122       D(1,2) =-dpuv[2].X();
0123       D(1,3) =-dpuv[3].X();
0124       D(2,1) = dpuv[0].Y();
0125       D(2,2) =-dpuv[2].Y();
0126       D(2,3) =-dpuv[3].Y();
0127       D(3,1) = dpuv[0].Z();
0128       D(3,2) =-dpuv[2].Z();
0129       D(3,3) =-dpuv[3].Z();
0130     }
0131     break;
0132   case IntImp_UIsoparametricOnCaro2:
0133     {
0134       ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
0135       ThePSurfaceTool::D1(SURF2,paramConst,X(3),pntsol2,dpuv[2],dpuv[3]);
0136       D(1,1) = dpuv[0].X();
0137       D(1,2) = dpuv[1].X();
0138       D(1,3) =-dpuv[3].X();
0139       D(2,1) = dpuv[0].Y();
0140       D(2,2) = dpuv[1].Y();
0141       D(2,3) =-dpuv[3].Y();
0142       D(3,1) = dpuv[0].Z();
0143       D(3,2) = dpuv[1].Z();
0144       D(3,3) =-dpuv[3].Z();
0145     }
0146     break;
0147   case IntImp_VIsoparametricOnCaro2:
0148     {
0149       ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
0150       ThePSurfaceTool::D1(SURF2,X(3),paramConst,pntsol2,dpuv[2],dpuv[3]);
0151       D(1,1) = dpuv[0].X();
0152       D(1,2) = dpuv[1].X();
0153       D(1,3) =-dpuv[2].X();
0154       D(2,1) = dpuv[0].Y();
0155       D(2,2) = dpuv[1].Y();
0156       D(2,3) =-dpuv[2].Y();
0157       D(3,1) = dpuv[0].Z();
0158       D(3,2) = dpuv[1].Z();
0159       D(3,3) =-dpuv[2].Z();
0160     }
0161     break;
0162   }
0163   return Standard_True;
0164 }
0165 
0166 Standard_Boolean IntImp_ZerParFunc::Values( const math_Vector& X,
0167                                            math_Vector& F,
0168                                            math_Matrix& D) {
0169 
0170   switch (chxIso) {
0171   case IntImp_UIsoparametricOnCaro1:
0172     {
0173       ThePSurfaceTool::D1(SURF1,paramConst,X(1),pntsol1,dpuv[0],dpuv[1]);
0174       ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
0175       D(1,1) = dpuv[1].X();
0176       D(1,2) =-dpuv[2].X();
0177       D(1,3) =-dpuv[3].X();
0178       D(2,1) = dpuv[1].Y();
0179       D(2,2) =-dpuv[2].Y();
0180       D(2,3) =-dpuv[3].Y();
0181       D(3,1) = dpuv[1].Z();
0182       D(3,2) =-dpuv[2].Z();
0183       D(3,3) =-dpuv[3].Z();
0184     }
0185     break;
0186   case IntImp_VIsoparametricOnCaro1:
0187     {
0188       ThePSurfaceTool::D1(SURF1,X(1),paramConst,pntsol1,dpuv[0],dpuv[1]);
0189       ThePSurfaceTool::D1(SURF2,X(2),X(3),pntsol2,dpuv[2],dpuv[3]);
0190       D(1,1) = dpuv[0].X();
0191       D(1,2) =-dpuv[2].X();
0192       D(1,3) =-dpuv[3].X();
0193       D(2,1) = dpuv[0].Y();
0194       D(2,2) =-dpuv[2].Y();
0195       D(2,3) =-dpuv[3].Y();
0196       D(3,1) = dpuv[0].Z();
0197       D(3,2) =-dpuv[2].Z();
0198       D(3,3) =-dpuv[3].Z();
0199     }
0200     break;
0201   case IntImp_UIsoparametricOnCaro2:
0202     {
0203       ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
0204       ThePSurfaceTool::D1(SURF2,paramConst,X(3),pntsol2,dpuv[2],dpuv[3]);
0205       D(1,1) = dpuv[0].X();
0206       D(1,2) = dpuv[1].X();
0207       D(1,3) =-dpuv[3].X();
0208       D(2,1) = dpuv[0].Y();
0209       D(2,2) = dpuv[1].Y();
0210       D(2,3) =-dpuv[3].Y();
0211       D(3,1) = dpuv[0].Z();
0212       D(3,2) = dpuv[1].Z();
0213       D(3,3) =-dpuv[3].Z();
0214     }
0215     break;
0216   case IntImp_VIsoparametricOnCaro2:
0217     {
0218       ThePSurfaceTool::D1(SURF1,X(1),X(2),pntsol1,dpuv[0],dpuv[1]);
0219       ThePSurfaceTool::D1(SURF2,X(3),paramConst,pntsol2,dpuv[2],dpuv[3]);
0220       D(1,1) = dpuv[0].X();
0221       D(1,2) = dpuv[1].X();
0222       D(1,3) =-dpuv[2].X();
0223       D(2,1) = dpuv[0].Y();
0224       D(2,2) = dpuv[1].Y();
0225       D(2,3) =-dpuv[2].Y();
0226       D(3,1) = dpuv[0].Z();
0227       D(3,2) = dpuv[1].Z();
0228       D(3,3) =-dpuv[2].Z();
0229     }
0230     break;
0231   }
0232   f[0] = F(1) = pntsol1.X() - pntsol2.X();
0233   f[1] = F(2) = pntsol1.Y() - pntsol2.Y();
0234   f[2] = F(3) = pntsol1.Z() - pntsol2.Z();
0235   return Standard_True;
0236 }
0237 
0238 void IntImp_ZerParFunc::ComputeParameters(
0239                       const IntImp_ConstIsoparametric  ChoixIso,
0240                       const TColStd_Array1OfReal& Param,  
0241                       math_Vector&  UVap,
0242                       math_Vector&  BornInf,
0243                       math_Vector&  BornSup,
0244                       math_Vector&  Tolerance ) {
0245 
0246   chxIso = ChoixIso;
0247   switch (chxIso) {
0248   case IntImp_UIsoparametricOnCaro1:
0249     {
0250       paramConst = Param(1);
0251       UVap(1) = Param(2);
0252       UVap(2) = Param(3);
0253       UVap(3) = Param(4);
0254       
0255       BornInf(1) = va0;
0256       BornSup(1) = va1;
0257       
0258       BornInf(2) = ub0;
0259       BornInf(3) = vb0;
0260       BornSup(2) = ub1;
0261       BornSup(3) = vb1;
0262       
0263       Tolerance(1)= vres1;
0264       Tolerance(2)= ures2;
0265       Tolerance(3)= vres2;
0266     }
0267     break;
0268   case IntImp_VIsoparametricOnCaro1:
0269     {
0270       paramConst = Param(2);
0271       UVap(1) = Param(1);
0272       UVap(2) = Param(3);
0273       UVap(3) = Param(4);
0274       BornInf(1) = ua0;
0275       BornSup(1) = ua1;
0276       
0277       BornInf(2) = ub0;
0278       BornSup(2) = ub1;
0279       BornInf(3) = vb0;
0280       BornSup(3) = vb1;
0281 
0282       Tolerance(1)= ures1;
0283       Tolerance(2)= ures2;
0284       Tolerance(3)= vres2;
0285     }
0286     break;
0287   case IntImp_UIsoparametricOnCaro2:
0288     {
0289       paramConst = Param(3); 
0290       UVap(1) = Param(1);
0291       UVap(2) = Param(2);
0292       UVap(3) = Param(4);
0293       
0294       BornInf(1) = ua0;
0295       BornSup(1) = ua1;
0296       BornInf(2) = va0;
0297       BornSup(2) = va1;
0298       
0299       BornInf(3) = vb0;
0300       BornSup(3) = vb1;
0301 
0302       Tolerance(1)= ures1;
0303       Tolerance(2)= vres1;
0304       Tolerance(3)= vres2;
0305     }
0306     break;
0307   case IntImp_VIsoparametricOnCaro2:
0308     {
0309       paramConst = Param(4); 
0310       UVap(1) = Param(1);
0311       UVap(2) = Param(2);
0312       UVap(3) = Param(3);
0313       
0314       BornInf(1) = ua0;
0315       BornSup(1) = ua1;
0316       BornInf(2) = va0;
0317       BornSup(2) = va1;
0318 
0319       BornInf(3) = ub0;
0320       BornSup(3) = ub1;
0321 
0322       Tolerance(1)= ures1;
0323       Tolerance(2)= vres1;
0324       Tolerance(3)= ures2;
0325     }
0326     break;
0327   }
0328 
0329   Standard_Real Incr1 = (BornSup(1)-BornInf(1))*0.01;
0330   Standard_Real Incr2 = (BornSup(2)-BornInf(2))*0.01;
0331   Standard_Real Incr3 = (BornSup(3)-BornInf(3))*0.01;
0332   BornInf(1) -= Incr1;
0333   BornSup(1) += Incr1;
0334   BornInf(2) -= Incr2;
0335   BornSup(2) += Incr2;
0336   BornInf(3) -= Incr3;
0337   BornSup(3) += Incr3;
0338 } 
0339 
0340 
0341 Standard_Boolean IntImp_ZerParFunc::IsTangent(
0342               const math_Vector& UVap,
0343               TColStd_Array1OfReal& Param,
0344               IntImp_ConstIsoparametric& BestChoix) 
0345 {
0346   switch (chxIso) {
0347   case IntImp_UIsoparametricOnCaro1:
0348     {
0349       Param(1) = paramConst;
0350       Param(2) = UVap(1) ;
0351       Param(3) = UVap(2) ;
0352       Param(4) = UVap(3) ;
0353     }
0354     break;
0355   case IntImp_VIsoparametricOnCaro1:
0356     {
0357       Param(2) = paramConst;
0358       Param(1) = UVap(1) ;
0359       Param(3) = UVap(2) ;
0360       Param(4) = UVap(3) ;
0361     }
0362     break;
0363   case IntImp_UIsoparametricOnCaro2:
0364     {
0365       Param(3) = paramConst;
0366       Param(1) = UVap(1) ;
0367       Param(2) = UVap(2) ;
0368       Param(4) = UVap(3) ;
0369     }
0370     break;
0371   case IntImp_VIsoparametricOnCaro2:
0372     {
0373       Param(4) = paramConst;
0374       Param(1) = UVap(1) ;
0375       Param(2) = UVap(2) ;
0376       Param(3) = UVap(3) ;
0377     }
0378     break;
0379   }
0380 
0381   IntImp_ConstIsoparametric TabIso[4];
0382   Standard_Real EpsUV[4];
0383   EpsUV[0] = ures1;
0384   EpsUV[1] = vres1;
0385   
0386   EpsUV[2] = ures2;
0387   EpsUV[3] = vres2;
0388 
0389 
0390   tangent = IntImp_ComputeTangence(dpuv,EpsUV,tgduv,TabIso);
0391   if (!tangent) 
0392     chxIso = TabIso[0];
0393   BestChoix = chxIso;
0394   return tangent;
0395 }
0396      
0397 
0398 #undef SURF1
0399 #undef SURF2
0400 
0401 
0402 
0403 
0404 
0405 
0406