Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/opencascade/Blend_CSWalking_1.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_CSWalking::Blend_CSWalking(const TheCurve& Curv,
0016                                  const TheSurface& Surf,
0017                                  const Handle(TheTopolTool)& Domain):
0018        done(Standard_False),surf(Surf),
0019        curv(Curv)
0020 {
0021   domain = Domain;
0022 }
0023 
0024 
0025 
0026 void Blend_CSWalking::Perform(Blend_CSFunction& Func,
0027 //                            Blend_CSFuncInv& FuncInv,
0028                               const Standard_Real Pdep,   
0029                               const Standard_Real Pmax,
0030                               const Standard_Real MaxStep,
0031             const Standard_Real Tol3d,
0032                               const Standard_Real TolGuide,
0033                               const math_Vector& ParDep,
0034                               const Standard_Real Fleche,
0035                               const Standard_Boolean Appro)
0036 {
0037 
0038   done = Standard_False;
0039   iscomplete = Standard_False;
0040   comptra = Standard_False;
0041   line = new TheLine ();
0042   Standard_Integer Nbvar = Func.NbVariables();
0043   tolpoint3d = Tol3d;
0044   tolgui = Abs(TolGuide);
0045   fleche = Abs(Fleche);
0046   rebrou = Standard_False;
0047   pasmax = Abs(MaxStep);
0048   math_Vector sol(1,Nbvar);
0049 
0050   firstsol = new TColStd_HArray1OfReal(1,Nbvar);
0051 
0052   if (Pmax-Pdep >= 0.) {
0053     sens = 1.;
0054   }
0055   else {
0056     sens = -1.;
0057   }
0058 
0059   Blend_Status State;
0060   TheExtremity ptf1,ptf2;
0061 
0062   param = Pdep;
0063   firstparam = Pdep;
0064   Func.Set(param);
0065 
0066   if (Appro) {
0067 
0068     TopAbs_State situ;
0069 //    math_Vector tolerance(1,3),infbound(1,3),supbound(1,3);
0070     math_Vector tolerance(1,Nbvar),infbound(1,Nbvar),supbound(1,Nbvar);
0071     Func.GetTolerance(tolerance,tolpoint3d);
0072     Func.GetBounds(infbound,supbound);
0073     math_FunctionSetRoot rsnld(Func,tolerance,30);
0074 
0075     rsnld.Perform(Func,ParDep,infbound,supbound);
0076     
0077     if (!rsnld.IsDone()) {
0078       return;
0079     }
0080     rsnld.Root(sol);
0081 
0082 //    situ1 = TheTopolTool::Classify(surf1,gp_Pnt2d(sol(1),sol(2)),
0083 //                                 Max(tolerance(1),tolerance(2)));
0084 //    situ2 = TheTopolTool::Classify(surf2,gp_Pnt2d(sol(3),sol(4)),
0085 //                                 Max(tolerance(3),tolerance(4)));
0086 /*
0087     situ = domain->Classify(gp_Pnt2d(sol(1),sol(2)),
0088                               Min(tolerance(1),tolerance(2)));
0089 */
0090     situ = domain->Classify(Func.Pnt2d(),
0091                             Min(tolerance(1),tolerance(2)));
0092 
0093     if (situ != TopAbs_IN ) {
0094       return;
0095     }
0096   }
0097   else {
0098     sol = ParDep;
0099   }
0100 
0101   for (Standard_Integer i=1; i<= Nbvar; i++) {
0102     firstsol->ChangeValue(i) = sol(i);
0103   }
0104   State = TestArret(Func,sol,Standard_False,Blend_OK);
0105   if (State!=Blend_OK) {
0106     return;
0107   }
0108 #ifdef OCCT_DEBUG
0109   if (Blend_GettraceDRAWSECT()){
0110     Drawsect(surf,curv,param,Func);
0111   }
0112 #endif
0113   // Mettre a jour la ligne.
0114   line->Append(previousP);
0115   Standard_Real U,V,W;
0116   previousP.ParametersOnS(U,V);
0117   W = previousP.ParameterOnC();
0118   TheExtremity P1(previousP.PointOnS(),U,V,previousP.Parameter(),tolpoint3d);
0119   TheExtremity P2(previousP.PointOnC(),W,previousP.Parameter(),tolpoint3d);
0120   if (sens>0.) {
0121     line->SetStartPoints(P1,P2);
0122   }
0123   else {
0124     line->SetEndPoints(P1,P2);
0125   }
0126 
0127 //  InternalPerform(Func,FuncInv,Pmax);
0128   InternalPerform(Func,sol,Pmax);
0129 
0130   done = Standard_True;
0131 }
0132 
0133 
0134 
0135 Standard_Boolean Blend_CSWalking::Complete(Blend_CSFunction& Func,
0136 //                                         Blend_CSFuncInv& FuncInv,
0137                                            const Standard_Real Pmin)
0138 {
0139   if (!done) {throw StdFail_NotDone();}
0140   if (iscomplete) {return Standard_True;}
0141 
0142 /*
0143   if (sens >0.) {
0144     previousP = line->Point(1);
0145   }
0146   else {
0147     previousP = line->Point(line->NbPoints());
0148   }
0149 */
0150 
0151   sens = -sens;
0152 /*
0153   param = previousP.Parameter();
0154   previousP.ParametersOnS(sol(1),sol(2));
0155   sol(3) = previousP.ParameterOnC();
0156 */
0157   Standard_Integer Nbvar = Func.NbVariables();
0158   math_Vector sol(1,Nbvar);
0159   for (Standard_Integer i =1; i<= Nbvar; i++) {
0160     sol(i) = firstsol->Value(i);
0161   }
0162 
0163   param = firstparam;
0164 
0165 //  InternalPerform(Func,FuncInv,Pmin);
0166   InternalPerform(Func,sol,Pmin);
0167 
0168   sens = -sens;
0169   iscomplete = Standard_True;
0170   return Standard_True;
0171 }
0172