0022627: Change OCCT memory management defaults
[occt.git] / src / Blend / Blend_CSWalking_1.gxx
1 Blend_CSWalking::Blend_CSWalking(const TheCurve& Curv,
2                                  const TheSurface& Surf,
3                                  const Handle(TheTopolTool)& Domain):
4        done(Standard_False),surf(Surf),
5        curv(Curv)
6 {
7   domain = Domain;
8 }
9
10
11
12 void Blend_CSWalking::Perform(Blend_CSFunction& Func,
13 //                            Blend_CSFuncInv& FuncInv,
14                               const Standard_Real Pdep,   
15                               const Standard_Real Pmax,
16                               const Standard_Real MaxStep,
17                               const Standard_Real TolGuide,
18                               const math_Vector& ParDep,
19                               const Standard_Real Tolesp,
20                               const Standard_Real Fleche,
21                               const Standard_Boolean Appro)
22 {
23
24   done = Standard_False;
25   iscomplete = Standard_False;
26   comptra = Standard_False;
27   line = new TheLine ();
28   Standard_Integer Nbvar = Func.NbVariables();
29   tolesp = Abs(Tolesp);
30   tolgui = Abs(TolGuide);
31   fleche = Abs(Fleche);
32   rebrou = Standard_False;
33   pasmax = Abs(MaxStep);
34   math_Vector sol(1,Nbvar);
35
36   firstsol = new TColStd_HArray1OfReal(1,Nbvar);
37
38   if (Pmax-Pdep >= 0.) {
39     sens = 1.;
40   }
41   else {
42     sens = -1.;
43   }
44
45   Blend_Status State;
46   TheExtremity ptf1,ptf2;
47
48   param = Pdep;
49   firstparam = Pdep;
50   Func.Set(param);
51
52   if (Appro) {
53
54     TopAbs_State situ;
55 //    math_Vector tolerance(1,3),infbound(1,3),supbound(1,3);
56     math_Vector tolerance(1,Nbvar),infbound(1,Nbvar),supbound(1,Nbvar);
57     Func.GetTolerance(tolerance,tolesp);
58     Func.GetBounds(infbound,supbound);
59     math_FunctionSetRoot rsnld(Func,tolerance,30);
60
61     rsnld.Perform(Func,ParDep,infbound,supbound);
62     
63     if (!rsnld.IsDone()) {
64       return;
65     }
66     rsnld.Root(sol);
67
68 //    situ1 = TheTopolTool::Classify(surf1,gp_Pnt2d(sol(1),sol(2)),
69 //                                 Max(tolerance(1),tolerance(2)));
70 //    situ2 = TheTopolTool::Classify(surf2,gp_Pnt2d(sol(3),sol(4)),
71 //                                 Max(tolerance(3),tolerance(4)));
72 /*
73     situ = domain->Classify(gp_Pnt2d(sol(1),sol(2)),
74                               Min(tolerance(1),tolerance(2)));
75 */
76     situ = domain->Classify(Func.Pnt2d(),
77                             Min(tolerance(1),tolerance(2)));
78
79     if (situ != TopAbs_IN ) {
80       return;
81     }
82   }
83   else {
84     sol = ParDep;
85   }
86
87   for (Standard_Integer i=1; i<= Nbvar; i++) {
88     firstsol->ChangeValue(i) = sol(i);
89   }
90   State = TestArret(Func,sol,Standard_False,Blend_OK);
91   if (State!=Blend_OK) {
92     return;
93   }
94 #ifdef DEB
95   if (Blend_GettraceDRAWSECT()){
96     Drawsect(surf,curv,param,Func);
97   }
98 #endif
99   // Mettre a jour la ligne.
100   line->Append(previousP);
101   Standard_Real U,V,W;
102   previousP.ParametersOnS(U,V);
103   W = previousP.ParameterOnC();
104   TheExtremity P1(previousP.PointOnS(),U,V,previousP.Parameter(),tolesp);
105   TheExtremity P2(previousP.PointOnC(),W,previousP.Parameter(),tolesp);
106   if (sens>0.) {
107     line->SetStartPoints(P1,P2);
108   }
109   else {
110     line->SetEndPoints(P1,P2);
111   }
112
113 //  InternalPerform(Func,FuncInv,Pmax);
114   InternalPerform(Func,sol,Pmax);
115
116   done = Standard_True;
117 }
118
119
120
121 Standard_Boolean Blend_CSWalking::Complete(Blend_CSFunction& Func,
122 //                                         Blend_CSFuncInv& FuncInv,
123                                            const Standard_Real Pmin)
124 {
125   if (!done) {StdFail_NotDone::Raise();}
126   if (iscomplete) {return Standard_True;}
127
128 /*
129   if (sens >0.) {
130     previousP = line->Point(1);
131   }
132   else {
133     previousP = line->Point(line->NbPoints());
134   }
135 */
136
137   sens = -sens;
138 /*
139   param = previousP.Parameter();
140   previousP.ParametersOnS(sol(1),sol(2));
141   sol(3) = previousP.ParameterOnC();
142 */
143   Standard_Integer Nbvar = Func.NbVariables();
144   math_Vector sol(1,Nbvar);
145   for (Standard_Integer i =1; i<= Nbvar; i++) {
146     sol(i) = firstsol->Value(i);
147   }
148
149   param = firstparam;
150
151 //  InternalPerform(Func,FuncInv,Pmin);
152   InternalPerform(Func,sol,Pmin);
153
154   sens = -sens;
155   iscomplete = Standard_True;
156   return Standard_True;
157 }
158