summaryrefslogtreecommitdiff
path: root/inc/Blend_CSWalking_1.gxx
blob: fd7a3ddb45b929cf4fca29b06f3fd061500346b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Blend_CSWalking::Blend_CSWalking(const TheCurve& Curv,
				 const TheSurface& Surf,
				 const Handle(TheTopolTool)& Domain):
       done(Standard_False),surf(Surf),
       curv(Curv)
{
  domain = Domain;
}



void Blend_CSWalking::Perform(Blend_CSFunction& Func,
//			      Blend_CSFuncInv& FuncInv,
			      const Standard_Real Pdep,   
			      const Standard_Real Pmax,
			      const Standard_Real MaxStep,
			      const Standard_Real TolGuide,
			      const math_Vector& ParDep,
			      const Standard_Real Tolesp,
			      const Standard_Real Fleche,
			      const Standard_Boolean Appro)
{

  done = Standard_False;
  iscomplete = Standard_False;
  comptra = Standard_False;
  line = new TheLine ();
  Standard_Integer Nbvar = Func.NbVariables();
  tolesp = Abs(Tolesp);
  tolgui = Abs(TolGuide);
  fleche = Abs(Fleche);
  rebrou = Standard_False;
  pasmax = Abs(MaxStep);
  math_Vector sol(1,Nbvar);

  firstsol = new TColStd_HArray1OfReal(1,Nbvar);

  if (Pmax-Pdep >= 0.) {
    sens = 1.;
  }
  else {
    sens = -1.;
  }

  Blend_Status State;
  TheExtremity ptf1,ptf2;

  param = Pdep;
  firstparam = Pdep;
  Func.Set(param);

  if (Appro) {

    TopAbs_State situ;
//    math_Vector tolerance(1,3),infbound(1,3),supbound(1,3);
    math_Vector tolerance(1,Nbvar),infbound(1,Nbvar),supbound(1,Nbvar);
    Func.GetTolerance(tolerance,tolesp);
    Func.GetBounds(infbound,supbound);
    math_FunctionSetRoot rsnld(Func,tolerance,30);

    rsnld.Perform(Func,ParDep,infbound,supbound);
    
    if (!rsnld.IsDone()) {
      return;
    }
    rsnld.Root(sol);

//    situ1 = TheTopolTool::Classify(surf1,gp_Pnt2d(sol(1),sol(2)),
//				   Max(tolerance(1),tolerance(2)));
//    situ2 = TheTopolTool::Classify(surf2,gp_Pnt2d(sol(3),sol(4)),
//				   Max(tolerance(3),tolerance(4)));
/*
    situ = domain->Classify(gp_Pnt2d(sol(1),sol(2)),
			      Min(tolerance(1),tolerance(2)));
*/
    situ = domain->Classify(Func.Pnt2d(),
			    Min(tolerance(1),tolerance(2)));

    if (situ != TopAbs_IN ) {
      return;
    }
  }
  else {
    sol = ParDep;
  }

  for (Standard_Integer i=1; i<= Nbvar; i++) {
    firstsol->ChangeValue(i) = sol(i);
  }
  State = TestArret(Func,sol,Standard_False,Blend_OK);
  if (State!=Blend_OK) {
    return;
  }
#ifdef DEB
  if (Blend_GettraceDRAWSECT()){
    Drawsect(surf,curv,param,Func);
  }
#endif
  // Mettre a jour la ligne.
  line->Append(previousP);
  Standard_Real U,V,W;
  previousP.ParametersOnS(U,V);
  W = previousP.ParameterOnC();
  TheExtremity P1(previousP.PointOnS(),U,V,previousP.Parameter(),tolesp);
  TheExtremity P2(previousP.PointOnC(),W,previousP.Parameter(),tolesp);
  if (sens>0.) {
    line->SetStartPoints(P1,P2);
  }
  else {
    line->SetEndPoints(P1,P2);
  }

//  InternalPerform(Func,FuncInv,Pmax);
  InternalPerform(Func,sol,Pmax);

  done = Standard_True;
}



Standard_Boolean Blend_CSWalking::Complete(Blend_CSFunction& Func,
//					   Blend_CSFuncInv& FuncInv,
					   const Standard_Real Pmin)
{
  if (!done) {StdFail_NotDone::Raise();}
  if (iscomplete) {return Standard_True;}

/*
  if (sens >0.) {
    previousP = line->Point(1);
  }
  else {
    previousP = line->Point(line->NbPoints());
  }
*/

  sens = -sens;
/*
  param = previousP.Parameter();
  previousP.ParametersOnS(sol(1),sol(2));
  sol(3) = previousP.ParameterOnC();
*/
  Standard_Integer Nbvar = Func.NbVariables();
  math_Vector sol(1,Nbvar);
  for (Standard_Integer i =1; i<= Nbvar; i++) {
    sol(i) = firstsol->Value(i);
  }

  param = firstparam;

//  InternalPerform(Func,FuncInv,Pmin);
  InternalPerform(Func,sol,Pmin);

  sens = -sens;
  iscomplete = Standard_True;
  return Standard_True;
}