Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/opencascade/Blend_CSWalking_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_CSWalking::TestArret(Blend_CSFunction& Function,
0016                                         const math_Vector& Sol,
0017                                         const Standard_Boolean TestDefl,
0018                                         const Blend_Status State)
0019 
0020 // On regarde si le point donne est solution.
0021 // Si c est le cas,
0022 //  On verifie le critere de fleche sur surf et curv
0023 //   Si OK, on classifie les point sur surf
0024 //    Si le point est  dedans : on retourne Blend_OK
0025 //    sinon on resout le pb inverse sur la surface
0026 //   sinon (fleche non OK)
0027 //    on renvoie Blend_StepTooLarge.
0028 // sinon on renvoie Blend_StepTooLarge.
0029 //
0030 
0031 
0032 {
0033   gp_Pnt pt1,pt2;
0034   gp_Vec V1,V2;
0035   gp_Vec Tgp1,Nor1;
0036   gp_Vec2d V12d;
0037   gp_Pnt2d pt2d;
0038   Standard_Real pOnC;
0039   Blend_Status State1,State2;
0040   IntSurf_TypeTrans tras = IntSurf_Undecided;
0041 
0042   if (Function.IsSolution(Sol,tolpoint3d)) {
0043 
0044     pt1  = Function.PointOnS();
0045     pt2  = Function.PointOnC();
0046     pt2d = Function.Pnt2d();
0047     pOnC = Function.ParameterOnC();
0048     V1   = Function.TangentOnS();
0049     V2   = Function.TangentOnC();
0050     V12d = Function.Tangent2d();
0051 
0052     if (TestDefl) {
0053 
0054 
0055       // Verification du critere de fleche sur chaque surface
0056       //et sur la ligne guide
0057     
0058       State1 = CheckDeflectionOnSurf(pt1,
0059 //                                   gp_Pnt2d(sol(1),sol(2)),
0060                                      pt2d,
0061                                      V1,V12d);
0062 //      State2 = CheckDeflectionOnCurv(pt2,sol(3),V2);
0063 // Pour des pb dans les cheminements point/face on met
0064 // temporairement le test sur la courbe au placard. 
0065 //      State2 = CheckDeflectionOnCurv(pt2,pOnC,V2);
0066       State2 = Blend_StepTooSmall;
0067     }
0068     else {
0069       State1 = Blend_OK;
0070       State2 = Blend_OK;
0071     }
0072       
0073     if (State1 == Blend_Backward) {
0074       State1 = Blend_StepTooLarge;
0075       rebrou= Standard_True;
0076     }
0077 
0078     if (State2 == Blend_Backward) {
0079       State2 = Blend_StepTooLarge;
0080       rebrou = Standard_True;
0081     }
0082 
0083     if (State1 == Blend_StepTooLarge ||
0084         State2 == Blend_StepTooLarge) {
0085 
0086       return Blend_StepTooLarge;
0087     }
0088 
0089 
0090     if (!comptra) {
0091 //      Function.Tangent(sol(1),sol(2),Tgp1,Nor1);
0092       Function.Tangent(pt2d.X(),pt2d.Y(),Tgp1,Nor1);
0093       Standard_Real testra = Tgp1.Dot(Nor1.Crossed(V1));
0094       if (Abs(testra) > Precision::Confusion()) {
0095         if (testra < 0.) {
0096           tras = IntSurf_In;
0097         }
0098         else if (testra >0.) {
0099           tras = IntSurf_Out;
0100         }
0101         comptra = Standard_True;
0102         line->Set(tras);
0103       }
0104     }
0105 
0106     if (State1 == Blend_OK ||
0107         State2 == Blend_OK ) {
0108 
0109       previousP.SetValue(Function.PointOnS(),
0110                          Function.PointOnC(),
0111                          param,
0112 //                       sol(1),sol(2),
0113 //                       sol(3),
0114                          pt2d.X(),pt2d.Y(),
0115                          pOnC,
0116                          V1,V2,
0117                          V12d);
0118                          
0119 
0120       return State;
0121     }
0122     if (State1 == Blend_StepTooSmall &&
0123         State2 == Blend_StepTooSmall) {
0124 
0125       previousP.SetValue(Function.PointOnS(),
0126                          Function.PointOnC(),
0127                          param,
0128 //                       sol(1),sol(2),
0129 //                       sol(3),
0130                          pt2d.X(),pt2d.Y(),
0131                          pOnC,
0132                          V1,V2,
0133                          V12d);
0134       if (State == Blend_OK) {
0135         return Blend_StepTooSmall;
0136       }
0137       else {
0138         return State;
0139       }
0140     }
0141 
0142     if (State == Blend_OK) {
0143       return Blend_SamePoints;
0144     }
0145     else {
0146       return State;
0147     }
0148 
0149   }
0150   else {
0151     return Blend_StepTooLarge;
0152   }
0153 }
0154 
0155 
0156 Blend_Status Blend_CSWalking::CheckDeflectionOnSurf
0157   (const gp_Pnt& Psurf,
0158    const gp_Pnt2d& Ponsurf,
0159    const gp_Vec& Tgsurf,
0160    const gp_Vec2d& Tgonsurf)
0161 {
0162   // regle par tests dans U4 correspond a 11.478 d
0163   const Standard_Real CosRef3D = 0.98;
0164 
0165   const Standard_Real CosRef2D = 0.88; // correspond a 25 d
0166 
0167   Standard_Real Norme, prevNorme, Cosi, Cosi2; // JAG MODIF 25.04.94
0168   Standard_Real FlecheCourante;
0169   Standard_Real Du,Dv,Duv;
0170   Standard_Real paramu,paramv,tolu,tolv;
0171 //  TColgp_Array1OfPnt Poles(1,4);
0172 //  gp_Pnt POnCurv,Milieu;
0173   gp_Pnt prevP;
0174   gp_Vec prevTg;
0175   gp_Vec2d previousd2d;
0176 
0177   prevP = previousP.PointOnS();
0178   prevTg = previousP.TangentOnS();
0179   tolu = TheSurfaceTool::UResolution(surf,tolpoint3d);
0180   tolv = TheSurfaceTool::VResolution(surf,tolpoint3d);
0181 
0182   gp_Vec Corde(prevP,Psurf);
0183   Norme = Corde.SquareMagnitude();
0184   prevNorme = prevTg.SquareMagnitude(); // JAG MODIF 25.04.94
0185 
0186 
0187   const Standard_Real toler3d = tolpoint3d;
0188   if (Norme <= toler3d * toler3d || prevNorme <= toler3d * toler3d) { // JAG MODIF 25.04.94
0189     // il faudra peut etre  forcer meme point  JAG MODIF 25.04.94
0190     return Blend_SamePoints;
0191   }
0192   Cosi = sens*Corde*prevTg;
0193   if (Cosi <0.) { // angle 3d>pi/2. --> retour arriere
0194     return Blend_Backward;
0195   }
0196 
0197   Cosi2 = Cosi * Cosi / prevNorme / Norme;
0198   if (Cosi2 < CosRef3D) { 
0199     return Blend_StepTooLarge;
0200   }
0201   
0202   previousP.ParametersOnS(paramu,paramv);
0203   previousd2d = previousP.Tangent2d();
0204 
0205   Du = Ponsurf.X() - paramu;
0206   Dv = Ponsurf.Y() - paramv;
0207   Duv = Du * Du + Dv * Dv;
0208   if ((Abs(Du) < tolu && Abs(Dv) < tolv) ||  // JAG MODIF 25.04.94
0209       (Abs(previousd2d.X()) < tolu && Abs(previousd2d.Y()) < tolv)){
0210     // il faudra peut etre  forcer meme point   JAG MODIF 25.04.94
0211     return Blend_SamePoints; //point confondu 2d
0212   }
0213   Cosi = sens*(Du * previousd2d.X() + Dv * previousd2d.Y());
0214   if (Cosi < 0) {
0215     return Blend_Backward; 
0216   }
0217 
0218   // Voir s il faut faire le controle sur le signe de prevtg*Tgsurf
0219   Cosi = sens*Corde*Tgsurf;
0220   Cosi2 = Cosi * Cosi / Tgsurf.SquareMagnitude() / Norme;
0221   if (Cosi2 < CosRef3D || Cosi < 0.) { 
0222     return Blend_StepTooLarge;
0223   }
0224 
0225   // Voir s il faut faire le controle sur le signe de Cosi
0226   Cosi = sens*(Du * Tgonsurf.X() +  Dv * Tgonsurf.Y())/Tgonsurf.Magnitude();
0227   Cosi2 = Cosi * Cosi / Duv;
0228   if (Cosi2 < CosRef2D || Cosi <0.) { 
0229     return Blend_StepTooLarge;
0230   }
0231 
0232   // Estimation de la fleche courante
0233 /*
0234   Norme = Sqrt(Norme)/3.;
0235   Poles(1) = prevP;
0236   Poles(4) = Psurf;
0237   Poles(2) = Poles(1).XYZ() + sens*Norme* prevTg.Normalized().XYZ();
0238   Poles(3) = Poles(4).XYZ() - sens*Norme* Tgsurf.Normalized().XYZ();
0239   BzCLib::PntPole(0.5,Poles,POnCurv);
0240   Milieu = (Poles(1).XYZ() + Poles(4).XYZ())*0.5;
0241   FlecheCourante = Milieu.Distance(POnCurv);
0242   
0243   if (FlecheCourante <= 0.5*fleche) {
0244 */
0245   FlecheCourante = (prevTg.Normalized().XYZ()-Tgsurf.Normalized().XYZ()).SquareModulus()*Norme/64.;
0246 
0247   if (FlecheCourante <= 0.25*fleche*fleche) {
0248 
0249     return Blend_StepTooSmall;
0250   }
0251   if (FlecheCourante > fleche*fleche) {
0252     // pas trop grand : commentaire interessant
0253     return Blend_StepTooLarge;
0254   }
0255 
0256   return Blend_OK;
0257 }
0258 
0259 
0260 
0261 Blend_Status Blend_CSWalking::CheckDeflectionOnCurv
0262   (const gp_Pnt& Pcurv,
0263    const Standard_Real Param,
0264    const gp_Vec& Tgcurv)
0265 {
0266   // regle par tests dans U4 correspond a 11.478 d
0267   const Standard_Real CosRef3D = 0.98;
0268 
0269   Standard_Real Norme, prevNorme, Cosi, Cosi2; // JAG MODIF 25.04.94
0270   Standard_Real FlecheCourante;
0271   Standard_Real Du,paramu,tolu;
0272 //  TColgp_Array1OfPnt Poles(1,4);
0273 //  gp_Pnt POnCurv,Milieu;
0274   gp_Pnt prevP;
0275   gp_Vec prevTg;
0276 
0277   prevP = previousP.PointOnC();
0278   prevTg = previousP.TangentOnC();
0279   tolu = TheCurveTool::Resolution(curv,tolpoint3d);
0280 
0281   gp_Vec Corde(prevP,Pcurv);
0282   Norme = Corde.SquareMagnitude();
0283   prevNorme = prevTg.SquareMagnitude(); // JAG MODIF 25.04.94
0284 
0285 
0286   const Standard_Real toler3d = tolpoint3d;
0287 // if (Norme <= tolesp*tolesp || prevNorme <= tolesp*tolesp) { // JAG MODIF 25.04.94
0288   if (Norme <= toler3d * toler3d) { // le 95.01.10
0289     // il faudra peut etre  forcer meme point  JAG MODIF 25.04.94
0290     return Blend_SamePoints;
0291   }
0292   else if (prevNorme > toler3d * toler3d) {
0293     Cosi = sens*Corde*prevTg;
0294     if (Cosi <0.) { // angle 3d>pi/2. --> retour arriere
0295       return Blend_Backward;
0296     }
0297     
0298     Cosi2 = Cosi * Cosi / prevNorme / Norme;
0299     if (Cosi2 < CosRef3D) { 
0300       return Blend_StepTooLarge;
0301     }
0302   }
0303   
0304   paramu = previousP.ParameterOnC();
0305   Du = Param - paramu;
0306   if (Abs(Du) < tolu){
0307     // il faudra peut etre  forcer meme point   JAG MODIF 25.04.94
0308     return Blend_SamePoints; //point confondu 2d
0309   }
0310 
0311   // Voir s il faut faire le controle sur le signe de prevtg*Tgsurf
0312 
0313   if (Tgcurv.Magnitude() <= tolpoint3d) {
0314     return Blend_SamePoints; // GROS BOBARD EN ATTENDANT
0315   }
0316 
0317   Cosi = sens*Corde*Tgcurv;
0318   Cosi2 = Cosi * Cosi / Tgcurv.SquareMagnitude() / Norme;
0319   if (Cosi2 < CosRef3D || Cosi < 0.) { 
0320     return Blend_StepTooLarge;
0321   }
0322 
0323   if (prevNorme > toler3d * toler3d) {
0324 
0325     // Estimation de la fleche courante
0326 /*    
0327     Norme = Sqrt(Norme)/3.;
0328     Poles(1) = prevP;
0329     Poles(4) = Pcurv;
0330     Poles(2) = Poles(1).XYZ() + sens*Norme* prevTg.Normalized().XYZ();
0331     Poles(3) = Poles(4).XYZ() - sens*Norme* Tgcurv.Normalized().XYZ();
0332     BzCLib::PntPole(0.5,Poles,POnCurv);
0333     Milieu = (Poles(1).XYZ() + Poles(4).XYZ())*0.5;
0334     FlecheCourante = Milieu.Distance(POnCurv);
0335     if (FlecheCourante <= 0.5*fleche) {
0336 */
0337     FlecheCourante = (prevTg.Normalized().XYZ()-Tgcurv.Normalized().XYZ()).SquareModulus()*Norme/64.;
0338 
0339     if (FlecheCourante <= 0.25*fleche*fleche) {
0340       return Blend_StepTooSmall;
0341     }
0342     if (FlecheCourante > fleche*fleche) {
0343       // pas trop grand : commentaire interessant
0344       return Blend_StepTooLarge;
0345     }
0346   }
0347   return Blend_OK;
0348 }
0349 
0350 
0351 
0352 
0353 
0354