0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / Blend / Blend_CSWalking_4.gxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15void Blend_CSWalking::InternalPerform(Blend_CSFunction& Func,
16// Blend_CSFuncInv& FuncInv,
17 math_Vector& sol,
18 const Standard_Real Bound)
19{
20
21 Standard_Real stepw = pasmax;
22 Standard_Real parprec = param;
23
24 Blend_Status State;
25 TopAbs_State situ;
26 Standard_Real w,U,V;
27 Standard_Integer nbarc;
7fd59977 28 Standard_Integer Index = 0;
29 Standard_Boolean Isvtx = Standard_False;
7fd59977 30 Standard_Integer Nbvar = Func.NbVariables();
31 Standard_Boolean Arrive,recad,echecrecad;
32 gp_Pnt2d p2d;
33// math_Vector tolerance(1,3),infbound(1,3),supbound(1,3),parinit(1,3);
34// math_Vector solrst(1,3);
35 math_Vector tolerance(1,Nbvar),infbound(1,Nbvar),supbound(1,Nbvar),
36 parinit(1,Nbvar);
37 math_Vector solrst(1,Nbvar);
38 TheVertex Vtx;
39 TheExtremity Exts,Extc;
40
41 //IntSurf_Transition Tline,Tarc;
42
43 Func.GetTolerance(tolerance,tolesp);
44 Func.GetBounds(infbound,supbound);
45
46 math_FunctionSetRoot rsnld(Func,tolerance,30);
47 parinit = sol;
48
49 param = parprec + sens*stepw;
50 Arrive = (sens *(param - Bound) > 0.) ;
51
52// if (Arrive) {
53// line->Clear();
54// }
55
56 while (!Arrive) {
57
58 Func.Set(param);
59 rsnld.Perform(Func,parinit,infbound,supbound);
60
61 if (!rsnld.IsDone()) {
62 State = Blend_StepTooLarge;
63 }
64 else {
65 rsnld.Root(sol);
66
67// situ1 = TheTopolTool::Classify(surf1,gp_Pnt2d(sol(1),sol(2)),
68// Max(tolerance(1),tolerance(2)));
69// situ2 = TheTopolTool::Classify(surf2,gp_Pnt2d(sol(3),sol(4)),
70// Max(tolerance(3),tolerance(4)));
71/*
72 situ = domain->Classify(gp_Pnt2d(sol(1),sol(2)),
73 Min(tolerance(1),tolerance(2)));
74*/
75 situ = domain->Classify(Func.Pnt2d(),
76 Min(tolerance(1),tolerance(2)));
77
78 w = Bound;
79 recad = Standard_False;
80 echecrecad = Standard_False;
81
82 if (situ == TopAbs_OUT || situ == TopAbs_ON) {
83 // pb inverse sur surf
84// recad = Recadre(FuncInv,sol,solrst,Index,Isvtx,Vtx);
85 Isvtx = Standard_False; // en attendant Recadre
86 if (recad) {
87 w = solrst(2);
88 }
89 else {
90 echecrecad = Standard_True;
91 }
92 }
93 if (!echecrecad) {
94 if (recad) {
95
96 // sol sur surf
97 State = Blend_OnRst1;
98 param = w;
99 domain->Init();
100 nbarc = 1;
101 while (nbarc < Index) {
102 nbarc++;
103 domain->Next();
104 }
105 p2d = TheArcTool::Value(domain->Value(),solrst(1));
106 sol(1) = p2d.X();
107 sol(2) = p2d.Y();
108 sol(3) = solrst(3);
109 Func.Set(param);
110 }
111 else {
112 State = Blend_OK;
113 }
114 State = TestArret(Func,sol,Standard_True,State);
115 }
116 else {
117 // Echec recadrage. On sort avec PointsConfondus
118 State = Blend_SamePoints;
119 }
120 }
121
122 switch (State) {
123 case Blend_OK :
124 {
0797d9d3 125#ifdef OCCT_DEBUG
7fd59977 126 if (Blend_GettraceDRAWSECT()){
127 Drawsect(surf,curv,param,Func);
128 }
129#endif
130
131 // Mettre a jour la ligne.
132 if (sens>0.) {
133 line->Append(previousP);
134 }
135 else {
136 line->Prepend(previousP);
137 }
138 parinit = sol;
139 parprec = param;
140
141 if (param == Bound) {
142 Arrive = Standard_True;
143/*
144 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
145 Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
146*/
147 previousP.ParametersOnS(U,V);
148 Exts.SetValue(previousP.PointOnS(),U,V,
149 previousP.Parameter(),tolesp);
150 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
151 previousP.Parameter(),tolesp);
152 // Indiquer que fin sur Bound.
153 }
154 else {
155 param = param + sens*stepw;
156 if (sens*(param - Bound) > - tolgui) {
157 param = Bound;
158 }
159 }
160
161 }
162 break;
163
164 case Blend_StepTooLarge :
165 {
166 stepw = stepw/2.;
167 if (Abs(stepw) < tolgui) {
168/*
169 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
170 Extc.SetValue(previousP.PointOnC(),sol(3),sol(4),tolesp);
171*/
172 previousP.ParametersOnS(U,V);
173 Exts.SetValue(previousP.PointOnS(),U,V,
174 previousP.Parameter(),tolesp);
175 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
176 previousP.Parameter(),tolesp);
177 Arrive = Standard_True;
178 if (line->NbPoints()>=2) {
179 // Indiquer qu on s arrete en cours de cheminement
180 }
181// else {
182// line->Clear();
183// }
184 }
185 else {
186 param = parprec + sens*stepw; // on ne risque pas de depasser Bound.
187 }
188 }
189 break;
190
191 case Blend_StepTooSmall :
192 {
0797d9d3 193#ifdef OCCT_DEBUG
7fd59977 194 if (Blend_GettraceDRAWSECT()){
195 Drawsect(surf,curv,param,Func);
196 }
197#endif
198 // Mettre a jour la ligne.
199 if (sens>0.) {
200 line->Append(previousP);
201 }
202 else {
203 line->Prepend(previousP);
204 }
205 parinit = sol;
206 parprec = param;
207
208 stepw = Min(1.5*stepw,pasmax);
209 if (param == Bound) {
210 Arrive = Standard_True;
211/*
212 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
213 Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
214*/
215 previousP.ParametersOnS(U,V);
216 Exts.SetValue(previousP.PointOnS(),U,V,
217 previousP.Parameter(),tolesp);
218 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
219 previousP.Parameter(),tolesp);
220 // Indiquer que fin sur Bound.
221 }
222 else {
223 param = param + sens*stepw;
224 if (sens*(param - Bound) > - tolgui) {
225 param = Bound;
226 }
227 }
228 }
229 break;
230
231 case Blend_OnRst1 :
232 {
0797d9d3 233#ifdef OCCT_DEBUG
7fd59977 234 if (Blend_GettraceDRAWSECT()){
235 Drawsect(surf,curv,param,Func);
236 }
237#endif
238 if (sens>0.) {
239 line->Append(previousP);
240 }
241 else {
242 line->Prepend(previousP);
243 }
244 MakeExtremity(Exts,Index,solrst(1),Isvtx,Vtx);
245// Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
246 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
247 previousP.Parameter(),tolesp);
248 Arrive = Standard_True;
249 }
250 break;
251
252 case Blend_SamePoints :
253 {
254 // On arrete
04232180 255 std::cout << " Points confondus dans le cheminement" << std::endl;
7fd59977 256/*
257 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
258 Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
259*/
260 previousP.ParametersOnS(U,V);
261 Exts.SetValue(previousP.PointOnS(),U,V,
262 previousP.Parameter(),tolesp);
263 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
264 previousP.Parameter(),tolesp);
265 Arrive = Standard_True;
266 }
267 break;
1896126e 268
7fd59977 269 default:
270 break;
7fd59977 271 }
272 if (Arrive) {
273 if (sens > 0.) {
274 line->SetEndPoints(Exts,Extc);
275 }
276 else {
277 line->SetStartPoints(Exts,Extc);
278
279 }
280 }
281
282 }
283
284}
285
286
287