Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/opencascade/Blend_Walking_2.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 Blend_Status Blend_Walking::TestArret(Blend_Function& Function,
0016                                       const Blend_Status State,
0017                                       const Standard_Boolean TestDefl,
0018                                       const Standard_Boolean TestSolu,
0019                                       const Standard_Boolean TestLengthStep)
0020 
0021 // On regarde si le point donne est solution.
0022 // Si c est le cas,
0023 //  On verifie le critere de fleche sur surf1 et surf2
0024 //   Si OK, on classifie les points sur surf1 et sur surf2.
0025 //    Si les deux sont dedans : on retourne Blend_OK
0026 //    sinon si un seul est dedans
0027 //     on resout le pb inverse sur la restriction concernee
0028 //    sinon on resout le pb inverse sur la surface pour laquelle
0029 //     le point est le plus loin.
0030 //   sinon (fleche non OK)
0031 //    on renvoie Blend_StepTooLarge.
0032 // sinon on renvoie Blend_StepTooLarge.
0033 //
0034 
0035 {
0036   gp_Pnt pt1,pt2;
0037   gp_Vec V1,V2;
0038   gp_Vec Tgp1,Tgp2,Nor1,Nor2;
0039   gp_Vec2d V12d,V22d;
0040   Blend_Status State1,State2;
0041   IntSurf_TypeTrans tras1,tras2;
0042   Blend_Point curpoint;
0043   Standard_Boolean loctwist1 = Standard_False, loctwist2 = Standard_False;
0044   Standard_Real tolsolu = tolpoint3d;
0045 
0046   if ( !TestSolu) tolsolu *= 1000; //Ca doit toujours etre bon
0047   if (Function.IsSolution(sol,tolsolu)) {
0048 
0049 #ifdef OCCT_DEBUG
0050     sectioncalculee = 1;
0051 #endif
0052     Standard_Boolean curpointistangent = Function.IsTangencyPoint();
0053     pt1  = Function.PointOnS1();
0054     pt2  = Function.PointOnS2();
0055     if(curpointistangent){
0056       curpoint.SetValue(pt1,pt2,param,
0057                         sol(1),sol(2),sol(3),sol(4));
0058     }
0059     else{
0060       V1   = Function.TangentOnS1();
0061       V2   = Function.TangentOnS2();
0062       V12d = Function.Tangent2dOnS1();
0063       V22d = Function.Tangent2dOnS2();
0064       curpoint.SetValue(pt1,pt2,param,
0065                         sol(1),sol(2),sol(3),sol(4),
0066                         V1,V2,V12d,V22d);
0067       if(Function.TwistOnS1()) loctwist1 = Standard_True;
0068       if(Function.TwistOnS2()) loctwist2 = Standard_True;
0069     }
0070 
0071     if (TestDefl && check) {
0072 
0073       // Verification du critere de fleche sur chaque surface
0074       //et sur la ligne guide
0075     
0076       State1 = CheckDeflection(Standard_True,curpoint);
0077       State2 = CheckDeflection(Standard_False,curpoint);
0078     }
0079     else {
0080        State1 = Blend_OK;
0081        State2 = Blend_OK;
0082        if (TestLengthStep) {
0083          // On verifie juste que le pas n'est pas trop grand
0084          // (Cas des prolongements foireux)
0085          Standard_Real curparamu,curparamv, prevparamu,prevparamv;
0086          math_Vector inf(1,4), sup(1,4);
0087          Function.GetBounds(inf, sup);
0088          sup -= inf;
0089          sup *= 0.05; // Pas max : 5% du domaine
0090      
0091          curpoint.ParametersOnS1(curparamu,curparamv);
0092          previousP.ParametersOnS1(prevparamu,prevparamv);
0093          if (Abs(curparamu-prevparamu) > sup(1)) State1 = Blend_StepTooLarge;
0094          if (Abs(curparamv-prevparamv) > sup(2)) State1 = Blend_StepTooLarge;     
0095          curpoint.ParametersOnS2(curparamu,curparamv);
0096          previousP.ParametersOnS2(prevparamu,prevparamv);
0097          if (Abs(curparamu-prevparamu) > sup(3)) State2 = Blend_StepTooLarge;
0098          if (Abs(curparamv-prevparamv) > sup(4)) State2 = Blend_StepTooLarge;
0099        }
0100     }
0101       
0102     if (State1 == Blend_Backward) {
0103       State1 = Blend_StepTooLarge;
0104       rebrou= Standard_True;
0105     }
0106 
0107     if (State2 == Blend_Backward) {
0108       State2 = Blend_StepTooLarge;
0109       rebrou = Standard_True;
0110     }
0111 
0112     if (State1 == Blend_StepTooLarge ||
0113         State2 == Blend_StepTooLarge) {
0114       
0115       return Blend_StepTooLarge;
0116     }
0117     
0118 
0119     // Ici seulement on peut statuer sur le twist
0120     // Car les rejet ont ete effectue (BUC60322)
0121     if (loctwist1) twistflag1 = Standard_True;
0122     if (loctwist2) twistflag2 = Standard_True;
0123 
0124     if (!comptra && !curpointistangent) {
0125       Function.Tangent(sol(1),sol(2),sol(3),sol(4),Tgp1,Tgp2,Nor1,Nor2);
0126       Nor1.Normalize();
0127       Nor2.Normalize();
0128       Standard_Real testra = Tgp1.Dot(Nor1.Crossed(V1));
0129       if (Abs(testra) > Precision::Confusion()) {
0130         tras1 = IntSurf_In;
0131         if ((testra > 0. && !loctwist1) || (testra < 0. && loctwist1)) {
0132           tras1 = IntSurf_Out;
0133         }
0134       
0135         testra = Tgp2.Dot(Nor2.Crossed(V2));
0136         if (Abs(testra) > Precision::Confusion()) {
0137           tras2 = IntSurf_Out;
0138           if ((testra > 0. && !loctwist2) || (testra < 0. && loctwist2)) {
0139             tras2 = IntSurf_In;
0140           }
0141           comptra = Standard_True;
0142           line->Set(tras1,tras2);
0143         }
0144       }
0145     }
0146 
0147     if (State1 == Blend_OK ||
0148         State2 == Blend_OK ) {
0149       previousP = curpoint;
0150       return State;
0151     }
0152 
0153     if (State1 == Blend_StepTooSmall &&
0154         State2 == Blend_StepTooSmall) {
0155       previousP = curpoint;
0156       if (State == Blend_OK) {
0157         return Blend_StepTooSmall;
0158       }
0159       else {
0160         return State;
0161       }
0162     }
0163 
0164     if (State == Blend_OK) {
0165       return Blend_SamePoints;
0166     }
0167     else {
0168       return State;
0169     }
0170 
0171   }
0172   else {
0173     return Blend_StepTooLarge;
0174   }
0175 }
0176 
0177 
0178 Blend_Status Blend_Walking::CheckDeflection
0179   (const Standard_Boolean OnFirst,
0180    const Blend_Point&     CurPoint)
0181 {
0182   // regle par tests dans U4 correspond a 11.478 d
0183   const Standard_Real CosRef3D = 0.98;
0184 
0185   const Standard_Real CosRef2D = 0.88; // correspond a 25 d
0186 
0187   Standard_Real Norme, Cosi, Cosi2;
0188   Standard_Real prevNorme = 0.;
0189   Standard_Real FlecheCourante;
0190   Standard_Real Du,Dv,Duv;
0191   Standard_Real tolu,tolv;
0192 
0193   gp_Pnt Psurf;
0194   gp_Vec Tgsurf;
0195   gp_Vec2d Tgonsurf;
0196   Standard_Real curparamu, curparamv;
0197   Standard_Boolean curpointistangent = CurPoint.IsTangencyPoint();
0198 
0199   gp_Pnt prevP;
0200   gp_Vec prevTg;
0201   gp_Vec2d previousd2d;
0202   Standard_Real prevparamu, prevparamv;
0203   Standard_Boolean prevpointistangent = previousP.IsTangencyPoint();
0204 
0205   if (OnFirst) {
0206     Psurf = CurPoint.PointOnS1();
0207     if(!curpointistangent){
0208       Tgsurf = CurPoint.TangentOnS1();
0209     }
0210     prevP = previousP.PointOnS1();
0211     if(!prevpointistangent){
0212       prevTg = previousP.TangentOnS1();
0213     }
0214     tolu = TheSurfaceTool::UResolution(surf1,tolpoint3d);
0215     tolv = TheSurfaceTool::VResolution(surf1,tolpoint3d);
0216   }
0217   else {
0218     Psurf = CurPoint.PointOnS2();
0219     if(!curpointistangent){
0220       Tgsurf = CurPoint.TangentOnS2();
0221     }
0222     prevP = previousP.PointOnS2();
0223     if(!prevpointistangent){
0224       prevTg = previousP.TangentOnS2();
0225     }
0226     tolu = TheSurfaceTool::UResolution(surf2,tolpoint3d);
0227     tolv = TheSurfaceTool::VResolution(surf2,tolpoint3d);
0228   }
0229 
0230   gp_Vec Corde(prevP,Psurf);
0231   Norme = Corde.SquareMagnitude();
0232 //  if(!curpointistangent) curNorme = Tgsurf.SquareMagnitude();
0233   if(!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
0234 
0235 
0236   const Standard_Real toler3d = 0.01 * tolpoint3d;
0237   if (Norme <= toler3d * toler3d){
0238     // il faudra peut etre  forcer meme point
0239     return Blend_SamePoints;
0240   }
0241   if(!prevpointistangent){
0242     if(prevNorme <= toler3d * toler3d) {
0243       return Blend_SamePoints;
0244     }
0245     Cosi = sens*Corde*prevTg;
0246     if (Cosi <0.) { // angle 3d>pi/2. --> retour arriere
0247       return Blend_Backward;
0248     }
0249     
0250     Cosi2 = Cosi * Cosi / prevNorme / Norme;
0251     if (Cosi2 < CosRef3D) { 
0252       return Blend_StepTooLarge;
0253     }
0254   }
0255 
0256   if(!curpointistangent){
0257     // Voir s il faut faire le controle sur le signe de prevtg*Tgsurf
0258     Cosi = sens*Corde*Tgsurf;
0259     Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
0260     if (Cosi2 < CosRef3D || Cosi < 0.) { 
0261       return Blend_StepTooLarge;
0262     }
0263   }  
0264     
0265   if(check2d){
0266     if (OnFirst) {
0267       CurPoint.ParametersOnS1(curparamu,curparamv);
0268       if(!curpointistangent) Tgonsurf = CurPoint.Tangent2dOnS1();
0269       previousP.ParametersOnS1(prevparamu,prevparamv);
0270       if(!prevpointistangent) previousd2d = previousP.Tangent2dOnS1();
0271     }
0272     else {
0273       CurPoint.ParametersOnS2(curparamu,curparamv);
0274       if(!curpointistangent) Tgonsurf = CurPoint.Tangent2dOnS2();
0275       previousP.ParametersOnS2(prevparamu,prevparamv);
0276       if(!prevpointistangent) previousd2d = previousP.Tangent2dOnS2();
0277     }
0278     
0279     Du = curparamu - prevparamu;
0280     Dv = curparamv - prevparamv;
0281     Duv = Du * Du + Dv * Dv;
0282 //    SqrtDuv = Sqrt(Duv);
0283     if (Abs(Du) < tolu && Abs(Dv) < tolv){
0284       // il faudra peut etre  forcer meme point
0285       return Blend_SamePoints; //point confondu 2d
0286     }
0287     if(!prevpointistangent){
0288       if(Abs(previousd2d.X()) < tolu && Abs(previousd2d.Y()) < tolv){
0289         // il faudra peut etre  forcer meme point
0290         return Blend_SamePoints; //point confondu 2d
0291       }
0292       Cosi = sens*(Du * previousd2d.X() + Dv * previousd2d.Y());
0293       if (Cosi < 0) {
0294         return Blend_Backward; 
0295       }
0296     }    
0297     if(!curpointistangent){
0298       // Voir s il faut faire le controle sur le signe de Cosi
0299       Cosi = sens*(Du * Tgonsurf.X() +  Dv * Tgonsurf.Y())/Tgonsurf.Magnitude();
0300       Cosi2 = Cosi * Cosi / Duv;
0301       if (Cosi2 < CosRef2D || Cosi <0.) { 
0302         return Blend_StepTooLarge;
0303       }
0304     }
0305   }
0306   if(!curpointistangent && !prevpointistangent){
0307     // Estimation de la fleche courante
0308     FlecheCourante = (prevTg.Normalized().XYZ()-Tgsurf.Normalized().XYZ()).SquareModulus()*Norme/64.;
0309     
0310     if (FlecheCourante <= 0.25*fleche*fleche) {
0311       return Blend_StepTooSmall;
0312     }
0313     if (FlecheCourante > fleche*fleche) {
0314       // pas trop grand : commentaire interessant
0315       return Blend_StepTooLarge;
0316     }
0317   }
0318   return Blend_OK;
0319 }