1 //-- File IntWalk_IWalking_3.gxx
5 #define No_Standard_RangeError
6 #define No_Standard_OutOfRange
9 // modified by NIZHNY-MKK Thu Nov 2 15:07:26 2000.BEGIN
10 static Standard_Boolean TestPassedSolutionWithNegativeState(const TColStd_SequenceOfInteger& etat,
11 const TColStd_SequenceOfReal& Umult,
12 const TColStd_SequenceOfReal& Vmult,
13 const TColStd_SequenceOfReal& ustart,
14 const TColStd_SequenceOfReal& vstart,
15 const Standard_Real& prevUp,
16 const Standard_Real& prevVp,
17 const TColStd_SequenceOfInteger& nbMultiplicities,
18 const math_Vector& tolerance,
21 Standard_Integer& Irang);
22 // modified by NIZHNY-MKK Thu Nov 2 15:07:39 2000.END
25 void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult,
26 const TColStd_SequenceOfReal& Vmult,
27 const ThePOPIterator& Pnts1,
29 Standard_Boolean& Rajout)
31 // traitement ligne ouvert.
33 // 1) pour tout point de depart non passant et non tangent et non encore traite
34 // calcul du pas d'avancement = pas en fonction de la fleche et du pas max.
36 // 2) calcul d'un point approche (ce point est sur la tangente a la section
37 // de distance = pas du point interieur)
40 // (l'ensemble des points calcules ne depassent pas un point dans la
41 // liste des points de depart)
43 // (l'ensemble des points ne forme pas une ligne ouverte allant
44 // d 'une frontiere du domaine a un autre ou d un point de tangence
45 // a une frontiere ou de 2 points de tangence : cas singuliers)
47 // 1) cadrage du point approche sur les frontieres si necessaire (il
50 // 3) si point non trouve on divise le pas
52 // 5) calcul du pas en fonction de la fleche et du pas maxi,
58 Standard_Integer I, N;
59 static math_Vector BornInf(1,2), BornSup(1,2), UVap(1,2);
60 Standard_Real PasC, PasCu, PasCv;
61 Standard_Boolean Arrive; // indique si ligne terminee
62 Standard_Boolean Cadre; //indique si on est sur frontiere du domaine
63 Standard_Boolean ArretAjout; //indique si on est sur point ajoute
65 Handle(IntWalk_TheIWLine) CurrentLine; // ligne en construction
66 Standard_Boolean Tgtend;
68 IntWalk_StatusDeflection Status, StatusPrecedent;
70 Standard_Integer NbDivision;
71 // nombre de fois que l on a divise le pas pour une section
73 Standard_Integer StepSign;
75 ThePointOfPath PathPnt;
82 math_FunctionSetRoot Rsnld(Func, tolerance);
83 Standard_Integer nbPath = Pnts1.Length();
85 // modified by NIZHNY-MKK Fri Oct 27 12:32:34 2000.BEGIN
86 TColStd_SequenceOfInteger movementdirectioninfo;
87 for (I = 1; I <= nbPath; I++) {
88 movementdirectioninfo.Append(0);
90 // modified by NIZHNY-MKK Fri Oct 27 12:32:38 2000.END
92 for (I = 1; I <= nbPath; I++) {
93 //point de depart de cheminement
94 // if (etat1(I) > 11) {
95 // modified by NIZHNY-MKK Fri Oct 27 12:33:37 2000.BEGIN
96 if ((etat1(I) > 11) || ((etat1(I) < -11) && (movementdirectioninfo(I)!=0))) {
97 // modified by NIZHNY-MKK Fri Oct 27 12:33:43 2000.END
98 PathPnt = Pnts1.Value(I);
99 CurrentLine = new IntWalk_TheIWLine ();
100 CurrentLine->SetTangencyAtBegining(Standard_False);
101 Tgtend = Standard_False;
102 CurrentLine->AddStatusFirst(Standard_False, Standard_True, I, PathPnt);
103 UVap(1) = ustart1(I);
104 UVap(2) = vstart1(I);
105 MakeWalkingPoint(11, UVap(1), UVap(2), Func, previousPoint);
106 previousd3d = Func.Direction3d();
107 previousd2d = Func.Direction2d();
108 CurrentLine->AddPoint(previousPoint);
109 // modified by NIZHNY-MKK Fri Oct 27 12:34:32 2000.BEGIN
110 if(movementdirectioninfo(I) !=0) {
111 if(movementdirectioninfo(I) < 0) {
113 CurrentLine->SetTangentVector(previousd3d.Reversed(),1);
116 CurrentLine->SetTangentVector(previousd3d,1);
119 Standard_Real tyutuyt=ThePointOfPathTool::Direction3d(PathPnt) * previousd3d;
122 CurrentLine->SetTangentVector(previousd3d.Reversed(),1);
126 CurrentLine->SetTangentVector(previousd3d,1);
129 // modified by NIZHNY-MKK Fri Oct 27 12:34:37 2000.END
131 // Modified by Sergey KHROMOV - Tue Nov 20 10:41:45 2001 Begin
132 etat1(I) = - abs(etat1(I));
133 movementdirectioninfo(I) = (movementdirectioninfo(I)==0) ? StepSign : 0;
134 // Modified by Sergey KHROMOV - Tue Nov 20 10:41:56 2001 End
135 // premier pas d avancement
136 Standard_Real d2dx = Abs(previousd2d.X());
137 Standard_Real d2dy = Abs(previousd2d.Y());
138 if (d2dx < tolerance(1)) {
139 PasC = pas * (VM-Vm)/d2dy;
141 else if (d2dy < tolerance(2)) {
142 PasC = pas * (UM-Um)/d2dx;
145 PasC = pas * Min((UM-Um)/d2dx,(VM-Vm)/d2dy);
148 Arrive = Standard_False;
149 ArretAjout = Standard_False;
151 StatusPrecedent = IntWalk_OK;
152 // modified by NIZHNY-MKK Fri Oct 27 12:39:37 2000
153 Standard_Integer IndexOfPathPointDoNotCheck=0;
155 while (!Arrive) { // tant que un des tests d arret est non verifie
157 Cadre = Cadrage(BornInf,BornSup,UVap,PasC,StepSign);
164 Rsnld.Perform(Func,UVap,BornInf,BornSup);
171 BornInf(1) = Um; BornSup(1) = UM; BornInf(2) = Vm; BornSup(2) = VM;
173 if (Rsnld.IsDone()) {
174 if (Abs(Func.Root()) > Func.Tolerance()) {
176 PasCu = Abs(PasC*previousd2d.X());
177 PasCv = Abs(PasC*previousd2d.Y());
178 if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
179 if (CurrentLine->NbPoints() == 1) break;
180 Arrive = Standard_True;
181 CurrentLine->AddStatusLast(Standard_False);
182 Tgtend = Standard_True; // a voir
183 Rajout = Standard_True;
184 seqAjout.Append(lines.Length() + 1);
189 Arrive = TestArretPassage(Umult, Vmult, Func, UVap, N);
191 Cadre = Standard_False;
192 //au cas ou on aurait cadre et arrive en meme temps
196 ArretAjout =TestArretAjout(Func, UVap, N, Psol);
199 Tgtend = lines.Value(N)->IsTangentAtEnd();
203 // modified by NIZHNY-MKK Thu Nov 2 15:09:08 2000.BEGIN
204 if(!(Rajout && ArretAjout)) {
205 Standard_Real prevUp, prevVp;
207 previousPoint.ParametersOnS2(prevUp, prevVp);
210 previousPoint.ParametersOnS1(prevUp, prevVp);
212 Arrive = TestPassedSolutionWithNegativeState(etat1, Umult, Vmult, ustart1, vstart1, prevUp, prevVp,
213 nbMultiplicities, tolerance, Func, UVap, N);
215 Cadre = Standard_False;
218 // modified by NIZHNY-MKK Thu Nov 2 15:09:13 2000.END
219 if (!ArretAjout && Cadre) {
220 if (CurrentLine->NbPoints() == 1) break; // annuler la ligne
221 TestArretCadre(Umult, Vmult, CurrentLine, Func, UVap, N);
223 if (N <= 0) { // jag 941017
224 MakeWalkingPoint(2, UVap(1), UVap(2), Func, Psol);
225 Tgtend = Func.IsTangent();
230 Status = TestDeflection(Func, Arrive, UVap, StatusPrecedent,
231 NbDivision,PasC,StepSign);
232 StatusPrecedent = Status;
233 if (Status == IntWalk_PasTropGrand) {
234 Arrive = Standard_False;
235 ArretAjout = Standard_False;
236 Tgtend = Standard_False; // jag 940615
238 previousPoint.ParametersOnS2(UVap(1), UVap(2));
241 previousPoint.ParametersOnS1(UVap(1), UVap(2));
244 else if (ArretAjout || Cadre) {
245 Arrive = Standard_True;
246 CurrentLine->AddStatusLast(Standard_False);
247 if (Status != IntWalk_ArretSurPointPrecedent) {
248 CurrentLine->AddPoint(Psol);
251 Rajout = Standard_True;
252 seqAjout.Append(lines.Length()+1);
255 else if (Status == IntWalk_ArretSurPointPrecedent) {
256 if (CurrentLine->NbPoints() == 1) { //annuler la ligne
257 Arrive = Standard_False;
260 Arrive = Standard_True;
261 Rajout = Standard_True;
262 seqAjout.Append(lines.Length() + 1);
263 CurrentLine->AddStatusLast(Standard_False);
264 Tgtend = Standard_True; // a voir
267 if (CurrentLine->NbPoints() == 1 && // annuler la ligne
268 (N == I || Status == IntWalk_PointConfondu) ) {
269 // si N == I on s est probablement trompe de uv
270 // principal ou bien le point
271 // est un point d accumulation
272 // si point confondu les donnees de depart sont mauvaises
273 Arrive = Standard_False;
276 // on a necessairement N > 0 jag 940617
277 // point d arret donne en entree
278 PathPnt = Pnts1.Value(N);
280 Standard_Integer etat1N=etat1(N);
281 // modified by NIZHNY-MKK Thu Nov 2 15:09:51 2000.BEGIN
282 // if (etat1N < 11) { // point passant qui est un arret
283 if (Abs(etat1N) < 11) { // point passant qui est un arret
284 // modified by NIZHNY-MKK Thu Nov 2 15:12:11 2000.END
285 if (Status == IntWalk_ArretSurPoint) {
286 CurrentLine->AddStatusLast(Standard_False);
287 Tgtend = Standard_True; // a voir
290 Arrive = Standard_False;
292 CurrentLine->AddIndexPassing(N);
294 else { // point d arret donne en entree
296 Tgtend = Standard_True;
298 CurrentLine->AddStatusLast(Standard_True, N, PathPnt);
300 AddPointInCurrentLine(N,PathPnt,CurrentLine);
301 if ((etat1N != 1 && etat1N != 11)) {
302 // modified by NIZHNY-MKK Fri Oct 27 12:43:05 2000.BEGIN
303 // etat1(N)= - etat1N;
304 etat1(N)= - Abs(etat1N);
305 movementdirectioninfo(N) = (movementdirectioninfo(N)==0) ? StepSign : 0;
306 if(Arrive && movementdirectioninfo(N)!=0) {
307 IndexOfPathPointDoNotCheck = N;
311 Rajout = Standard_True;
312 seqAjout.Append(lines.Length() + 1);
314 // modified by NIZHNY-MKK Fri Oct 27 12:45:33 2000.END
317 else if (Status == IntWalk_ArretSurPoint) {
318 Arrive = Standard_True;
319 CurrentLine->AddStatusLast(Standard_False);
320 Tgtend = Standard_True;
321 MakeWalkingPoint(1, UVap(1), UVap(2), Func, Psol);
322 CurrentLine->AddPoint(Psol);
323 Rajout = Standard_True;
324 seqAjout.Append(lines.Length() + 1);
326 else if (Status == IntWalk_OK) {
327 MakeWalkingPoint(2, UVap(1), UVap(2), Func, previousPoint);
328 previousd3d = Func.Direction3d();
329 previousd2d = Func.Direction2d();
330 CurrentLine->AddPoint(previousPoint);
334 else { // pas de solution numerique
336 PasCu = Abs(PasC*previousd2d.X());
337 PasCv = Abs(PasC*previousd2d.Y());
338 if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
339 if (CurrentLine->NbPoints()==1) break;
340 Arrive = Standard_True;
341 CurrentLine->AddStatusLast(Standard_False);
342 Tgtend = Standard_True; // a voir
343 Rajout = Standard_True;
344 seqAjout.Append(lines.Length() + 1);
347 } // fin de la ligne commencee
350 CurrentLine->SetTangencyAtEnd(Tgtend);
351 lines.Append(CurrentLine);
352 // modified by NIZHNY-MKK Fri Oct 27 12:59:29 2000.BEGIN
353 movementdirectioninfo(I)=0;
355 // modified by NIZHNY-MKK Fri Oct 27 12:59:42 2000.END
358 //-- lbr le 5 juin 97 (Pb ds Contap)
359 for(Standard_Integer av=1; av<=nbPath; av++) {
360 // modified by NIZHNY-MKK Fri Oct 27 13:00:22 2000.BEGIN
361 // if (etat1(av) > 11) {
362 if ((etat1(av) > 11) ||
364 (av!=IndexOfPathPointDoNotCheck) &&
366 (movementdirectioninfo(av)!=0))) {
367 // modified by NIZHNY-MKK Fri Oct 27 13:00:26 2000.END
368 Standard_Real Uav=ustart1(av);
369 Standard_Real Vav=vstart1(av);
370 Standard_Real Uavp,Vavp;
371 const IntSurf_PntOn2S &avP=CurrentLine->Value(CurrentLine->NbPoints());
373 avP.ParametersOnS2(Uavp,Vavp);
376 avP.ParametersOnS1(Uavp,Vavp);
380 Uav*=0.001; Vav*=0.001;
381 if(Abs(Uav)<tolerance(1) && Abs(Vav)<tolerance(2)) {
382 // modified by NIZHNY-MKK Fri Oct 27 13:01:38 2000.BEGIN
383 // etat1(av)=-etat1(av);
385 movementdirectioninfo(av) = 0;
387 etat1(av)=-etat1(av);
388 movementdirectioninfo(av) = StepSign;
390 // modified by NIZHNY-MKK Fri Oct 27 13:01:42 2000.END
391 CurrentLine->AddStatusLast(Standard_True, av, Pnts1.Value(av));
392 //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<<endl;
395 const IntSurf_PntOn2S &avPP=CurrentLine->Value(1);
397 avPP.ParametersOnS2(Uavp,Vavp);
400 avPP.ParametersOnS1(Uavp,Vavp);
406 Uav*=0.001; Vav*=0.001;
407 if(Abs(Uav)<tolerance(1) && Abs(Vav)<tolerance(2)) {
408 // modified by NIZHNY-MKK Fri Oct 27 13:02:49 2000.BEGIN
409 // etat1(av)=-etat1(av);
411 movementdirectioninfo(av) = 0;
413 etat1(av)=-etat1(av);
414 movementdirectioninfo(av) = -StepSign;
416 // modified by NIZHNY-MKK Fri Oct 27 13:02:52 2000.END
417 //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<<endl;
418 CurrentLine->AddStatusFirst(Standard_False, Standard_True, av, Pnts1.Value(av));
424 } //fin de traitement d un point
425 } //fin de tous les points
428 // modified by NIZHNY-MKK Thu Nov 2 15:07:53 2000.BEGIN
429 static Standard_Boolean TestPassedSolutionWithNegativeState(const TColStd_SequenceOfInteger& etat,
430 const TColStd_SequenceOfReal& Umult,
431 const TColStd_SequenceOfReal& Vmult,
432 const TColStd_SequenceOfReal& ustart,
433 const TColStd_SequenceOfReal& vstart,
434 const Standard_Real& prevUp,
435 const Standard_Real& prevVp,
436 const TColStd_SequenceOfInteger& nbMultiplicities,
437 const math_Vector& tolerance,
440 Standard_Integer& Irang) {
441 Standard_Boolean Arrive = Standard_False;
442 Standard_Real Dup, Dvp, Utest,Vtest;
443 Standard_Real tolu = tolerance(1);
444 Standard_Real tolv = tolerance(2);
445 Standard_Integer i, j, k, N;
446 for (i = 1; i <= etat.Length(); i++) {
449 // debug jag voir avec isg
453 Dup = prevUp - Utest;
454 Dvp = prevVp - Vtest;
455 if (Abs(Dup) >= tolu || Abs(Dvp) >= tolv) {
456 Standard_Real UV1mUtest = UV(1)-Utest;
457 Standard_Real UV2mVtest = UV(2)-Vtest;
458 if(( (Dup*UV1mUtest + Dvp*UV2mVtest) < 0) ||
459 ( Abs(UV1mUtest) < tolu
460 && Abs(UV2mVtest) < tolv)) {
462 Arrive = Standard_True;
466 else if (nbMultiplicities(i) > 0) {
468 for (k = 1; k < i; k++) {
469 N+=nbMultiplicities(k);
471 for (j = N + 1; j <= N + nbMultiplicities(i); j++) {
472 if (((prevUp-Umult(j))*(UV(1)-Umult(j)) +
473 (prevVp-Vmult(j))*(UV(2)-Vmult(j)) < 0) ||
474 (Abs(UV(1)-Umult(j)) < tolu &&
475 Abs(UV(2)-Vmult(j)) < tolv)) {
477 Arrive = Standard_True;
485 static math_Vector bidF(1,1);
486 static math_Matrix bidD(1,1,1,2);
488 Standard_Boolean bidB =
490 sp.Values(UV,bidF,bidD);
498 // modified by NIZHNY-MKK Thu Nov 2 15:07:58 2000.END