1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 //-- IntWalk_IWalking_2.gxx
17 #include <Bnd_Range.hxx>
18 #include <TColStd_MapOfInteger.hxx>
21 #define No_Standard_RangeError
22 #define No_Standard_OutOfRange
26 // _______________________________________________
28 // Location of point (u, v) in the natural domain of a surface AND update
29 // of couple (u, v) for the calculation of the next point.
31 Standard_Boolean IntWalk_IWalking::Cadrage
32 (math_Vector& BornInf,
36 // Standard_Real& StepV,
37 const Standard_Integer StepSign) const
40 // BorInf(1) <= UVap(1) <= BornSup(1) et BorInf(2) <= UVap(2) <= BornSup(2)
41 // 1) check if the process point is out of the natural domain of the surface.
42 // 2) if yes the approximated point is located on border taking the best direction
43 // the step and a limit blocating one of the parameters during the recent call of
44 // FunctionSetRoot are modified;
45 // 3) couple (u, v) is recomputed by approximation for the calculation of the next point.
46 // 4) return Standard_True if location, Standard_False if no location.
48 Standard_Real Duvx = previousd2d.X();
49 Standard_Real Duvy = previousd2d.Y();
52 previousPoint.ParametersOnS2(UVap(1),UVap(2));
55 previousPoint.ParametersOnS1(UVap(1),UVap(2));
58 Standard_Real U1 = UVap(1) + Step * Duvx * StepSign;
59 Standard_Real V1 = UVap(2) + Step * Duvy * StepSign;
62 Standard_Boolean infu = (U1 <= BornInf(1)+Precision::PConfusion());
63 Standard_Boolean supu = (U1 >= BornSup(1)-Precision::PConfusion());
64 Standard_Boolean infv = (V1 <= BornInf(2)+Precision::PConfusion());
65 Standard_Boolean supv = (V1 >= BornSup(2)-Precision::PConfusion());
67 Standard_Real theStepU,theStepV;
69 if (!infu && !supu && !infv && !supv) {
72 return Standard_False;
75 if ((infu || supu) && (infv || supv)) {
76 if (infu) { // jag 940616
78 theStepU = Abs((BornInf(1) - UVap(1)) / Duvx); // iso U =BornInf(1)
86 theStepU = Abs((BornSup(1) - UVap(1)) / Duvx); // iso U =BornSup(1)
92 if (infv) { // jag 940616
94 theStepV = Abs((BornInf(2) - UVap(2)) / Duvy); // iso V =BornInf(2)
102 theStepV = Abs((BornSup(2) - UVap(2)) / Duvy); // iso V =BornSup(2)
110 if (theStepU <= theStepV) {
113 UVap(1) = BornInf(1);
114 BornSup(1) = BornInf(1);
117 UVap(1) = BornSup(1);
118 BornInf(1) = BornSup(1);
120 UVap(2) += Step*Duvy*StepSign;
125 UVap(2) = BornInf(2);
126 BornSup(2) = BornInf(2);
129 UVap(2) = BornSup(2);
130 BornInf(2) = BornSup(2);
132 UVap(1) += Step*Duvx*StepSign;
134 return Standard_True;
137 else if (infu) { // jag 940616
139 Standard_Real aStep = Abs((BornInf(1) - UVap(1)) / Duvx); // iso U =BornInf(1)
140 if(aStep<Step) Step=aStep;
142 BornSup(1) = BornInf(1); // limit the parameter
143 UVap(1) = BornInf(1);
144 UVap(2) += Step*Duvy*StepSign;
145 return Standard_True;
147 else if (supu) { // jag 940616
149 Standard_Real aStep = Abs((BornSup(1) - UVap(1)) / Duvx); // iso U =BornSup(1)
150 if(aStep<Step) Step=aStep;
152 BornInf(1) = BornSup(1); // limit the parameter
153 UVap(1) = BornSup(1);
154 UVap(2) += Step*Duvy*StepSign;
155 return Standard_True;
157 else if (infv) { // jag 940616
159 Standard_Real aStep = Abs((BornInf(2) - UVap(2)) / Duvy); // iso V =BornInf(2)
160 if(aStep<Step) Step=aStep;
162 BornSup(2) = BornInf(2);
163 UVap(1) += Step*Duvx*StepSign;
164 UVap(2) = BornInf(2);
165 return Standard_True;
167 else if (supv) { // jag 940616
169 Standard_Real aStep = Abs((BornSup(2) - UVap(2)) / Duvy); // iso V =BornSup(2)
170 if(aStep<Step) Step=aStep;
172 BornInf(2) = BornSup(2);
173 UVap(1) += Step*Duvx*StepSign;
174 UVap(2) = BornSup(2);
175 return Standard_True;
177 return Standard_True;
181 Standard_Boolean IntWalk_IWalking::TestArretPassage
182 (const TColStd_SequenceOfReal& Umult,
183 const TColStd_SequenceOfReal& Vmult,
186 Standard_Integer& Irang)
188 // Umult et Vmult : table of stop (or crossing) points on border,
189 // here only the crossing points are taken into account.
190 // UV : the current point.
191 // Irang : at exit : give index of the stop point in uvstart1 or 0.
192 // consider that there is no risk of crossing only if there is one crossing point.
195 // test of stop for an OPEN intersection line
196 // 1) crossing test on all interior points
197 // 2) stop test on all start points
198 // if a stop is detected, the index of the stop point (Irang) is returned
199 // in the iterator of start points and the associated parameters in UV space.
201 Standard_Real Up, Vp, Du, Dv, Dup, Dvp, Utest,Vtest;
202 Standard_Integer j, N, ind;
203 Standard_Real tolu = tolerance(1);
204 Standard_Real tolv = tolerance(2);
205 Standard_Real tolu2 = 10.*tolerance(1);
206 Standard_Real tolv2 = 10.*tolerance(2);
208 Standard_Boolean Arrive = Standard_False;
210 // crossing test on point that can start a loop; mark
211 // as processed if passes through an open line
214 previousPoint.ParametersOnS2(Up,Vp);
217 previousPoint.ParametersOnS1(Up,Vp);
220 for (size_t i = 1; i < wd2.size(); i++) {
221 if (wd2[i].etat > 0) {
222 // debug jag 05.04.94
224 // if ((Up-wd2[i].ustart)*(UV(1)-wd2[i].ustart) +
225 // (Vp-wd2[i].vstart)*(UV(2)-wd2[i].vstart) <= 0)
226 Utest = wd2[i].ustart;
227 Vtest = wd2[i].vstart;
234 //-- lbr le 30 oct 97
238 if ((Abs(Du) < tolu2 && Abs(Dv) < tolv2) ||
239 (Abs(Dup) < tolu2 && Abs(Dvp) < tolv2)) {
241 wd2[i].etat = -wd2[i].etat;
244 Standard_Real DDu = (UV(1)-Up);
245 Standard_Real DDv = (UV(2)-Vp);
246 Standard_Real DDD = DDu*DDu+DDv*DDv;
247 Standard_Real DD1 = Du*Du+Dv*Dv;
249 Standard_Real DD2 = Dup*Dup+Dvp*Dvp;
250 if(DD2<=DDD && ((Du*Dup) + (Dv*Dvp*tolu/tolv) <= 0.)) {
251 wd2[i].etat = -wd2[i].etat;
258 // stop test on point given at input and not yet processed
260 // Modified by Sergey KHROMOV - Tue Nov 20 10:55:01 2001 Begin
261 // Check of all path points in the following order:
262 // * First check all not treated points;
263 // * After that check of already treated ones.
266 //// Modified by jgv, 28.07.2010 for OCC21914 ////
267 // There are several path points between (Up,Vp) and UV
268 // So several path points satisfy the condition
269 // Dup*UV1mUtest + Dvp*UV2mVtest) < 0
270 // We choose from them the path point with
271 // minimum distance to (Up,Vp)
272 TColStd_SequenceOfInteger i_candidates;
273 TColStd_SequenceOfReal SqDist_candidates;
275 for (l = 1; l <= 2 && !Arrive; l++) {
276 Standard_Boolean isToCheck;
278 for (size_t i = 1; i < wd1.size(); i++) {
280 isToCheck = (wd1[i].etat > 0);
282 isToCheck = (wd1[i].etat < 0);
285 // Modified by Sergey KHROMOV - Tue Nov 20 11:03:16 2001 End
287 // debug jag voir avec isg
289 Utest = wd1[i].ustart;
290 Vtest = wd1[i].vstart;
293 if (Abs(Dup) >= tolu || Abs(Dvp) >= tolv) {
294 Standard_Real UV1mUtest = UV(1)-Utest;
295 Standard_Real UV2mVtest = UV(2)-Vtest;
296 if(( (Dup*UV1mUtest + Dvp*UV2mVtest) < 0) ||
297 ( Abs(UV1mUtest) < tolu
298 && Abs(UV2mVtest) < tolv)) {
299 i_candidates.Append((Standard_Integer)i);
300 SqDist_candidates.Append(Dup*Dup + Dvp*Dvp);
303 Arrive = Standard_True;
308 else if (nbMultiplicities[i] > 0 && i_candidates.IsEmpty()) {
310 for (size_t k = 1; k < i; k++) {
311 N+=nbMultiplicities[k];
313 for (j = N + 1; j <= N + nbMultiplicities[i]; j++) {
314 if (((Up-Umult(j))*(UV(1)-Umult(j)) +
315 (Vp-Vmult(j))*(UV(2)-Vmult(j)) < 0) ||
316 (Abs(UV(1)-Umult(j)) < tolu &&
317 Abs(UV(2)-Vmult(j)) < tolv)) {
318 Irang=(Standard_Integer)i;
319 Arrive = Standard_True;
327 Standard_Real abidF[1], abidD[1][2];
328 math_Vector bidF(abidF,1,1);
329 math_Matrix bidD(abidD,1,1,1,2);
330 sp.Values(UV,bidF,bidD);
335 } //end of for (i = 1; i < wd1.size(); i++)
336 if (!i_candidates.IsEmpty())
338 Standard_Real MinSqDist = RealLast();
339 for (ind = 1; ind <= i_candidates.Length(); ind++)
340 if (SqDist_candidates(ind) < MinSqDist)
342 MinSqDist = SqDist_candidates(ind);
343 Irang = i_candidates(ind);
345 Arrive = Standard_True;
346 UV(1) = wd1[Irang].ustart;
347 UV(2) = wd1[Irang].vstart;
349 } //end of for (l = 1; l <= 2 && !Arrive; l++)
353 Standard_Boolean IntWalk_IWalking::TestArretPassage
354 (const TColStd_SequenceOfReal& Umult,
355 const TColStd_SequenceOfReal& Vmult,
356 const math_Vector& UV,
357 const Standard_Integer Index,
358 Standard_Integer& Irang)
360 // Umult, Vmult : table of stop (or crossing) points on border, here
361 // only crossing points are taken into account.
362 // UV : the current point.
363 // Index : index of the start point in uvstart2 of the current line
364 // (this is an interior point).
365 // Irang : at output : gives the index of the point passing in uvstart1 or 0.
366 // consider that there is risk to cross only one crossing point.
368 // test of stop for a CLOSED intersection line.
369 // 1) test of crossing on all interior points.
370 // 2) test of crossing on all crossing points.
372 Standard_Real Up, Vp, Scal;
373 Standard_Boolean Arrive = Standard_False;
374 Standard_Integer N, k, i;
375 Standard_Real Utest,Vtest;
376 Standard_Real tolu = tolerance(1);
377 Standard_Real tolv = tolerance(2);
380 // tests of stop and of crossing on all interior points.
383 previousPoint.ParametersOnS2(Up,Vp);
386 previousPoint.ParametersOnS1(Up,Vp);
389 Standard_Real UV1=UV(1);
390 Standard_Real UV2=UV(2);
393 //Normalizing factor. If it is less than 1.0 then the range will be expanded.
394 //This is no good for computation. Therefore, it is limited.
395 const Standard_Real deltau = mySRangeU.IsVoid() ? UM - Um : Max(mySRangeU.Delta(), 1.0);
396 const Standard_Real deltav = mySRangeV.IsVoid() ? VM - Vm : Max(mySRangeV.Delta(), 1.0);
398 Up/=deltau; UV1/=deltau;
399 Vp/=deltav; UV2/=deltav;
404 Standard_Real tolu2=tolu+tolu;
405 Standard_Real tolv2=tolv+tolv;
408 Standard_Real dPreviousCurrent = (Up-UV1)*(Up-UV1)+(Vp-UV2)*(Vp-UV2);
409 for (k = 1; k < (int)wd2.size(); k++) {
410 if (wd2[k].etat > 0) {
411 Utest = wd2[k].ustart;
412 Vtest = wd2[k].vstart;
417 Standard_Real UV1mUtest=UV1-Utest;
418 Standard_Real UV2mVtest=UV2-Vtest;
419 if( (UV1mUtest<tolu2 && UV1mUtest>-tolu2)
420 && (UV2mVtest<tolv2 && UV2mVtest>-tolv2)) {
422 //-- cout<<"* etat2 : ("<<k<<")"<<endl;
423 wd2[k].etat=-wd2[k].etat; //-- mark the point as a crossing point
425 else { //-- Index == k
426 //-- cout<<"* Arrive"<<endl;
427 Arrive=Standard_True;
431 Standard_Real UpmUtest = (Up-Utest);
432 Standard_Real VpmVtest = (Vp-Vtest);
433 Standard_Real dPreviousStart = (UpmUtest)*(UpmUtest)+(VpmVtest)*(VpmVtest);
434 Standard_Real dCurrentStart = UV1mUtest * UV1mUtest + UV2mVtest * UV2mVtest;
436 Scal=(UpmUtest)*(UV1mUtest)+(VpmVtest)*(UV2mVtest);
437 if( (Abs(UpmUtest)<tolu && Abs(VpmVtest)<tolv)) {
439 //-- cout<<"** etat2 : ("<<k<<")"<<endl;
440 wd2[k].etat = -wd2[k].etat;
443 else if(Scal<0 && (dPreviousStart+dCurrentStart < dPreviousCurrent)) {
444 if (Index == k ) { // on a boucle.
445 Arrive = Standard_True;
446 //-- cout<<"** Arrive : k="<<k<<endl;
449 //-- cout<<"*** etat2 : ("<<k<<")"<<endl;
450 wd2[k].etat = -wd2[k].etat; // mark the point as a crossing point
454 if(dPreviousStart < dPreviousCurrent*0.25) {
455 wd2[k].etat = -wd2[k].etat; // mark the point as a crossing point
456 //-- cout<<"**** etat2 : ("<<k<<")"<<endl;
459 if(dCurrentStart < dPreviousCurrent*0.25) {
460 //-- cout<<"***** etat2 : ("<<k<<")"<<endl;
461 wd2[k].etat = -wd2[k].etat; // mark the point as a crossing point
464 Standard_Real UMidUtest = 0.5*(UV1+Up)-Utest;
465 Standard_Real VMidVtest = 0.5*(UV2+Vp)-Vtest;
466 Standard_Real dMiddleStart = UMidUtest* UMidUtest+VMidVtest*VMidVtest;
468 if(dMiddleStart < dPreviousCurrent*0.5) {
469 //-- cout<<"*********** etat2 : ("<<k<<")"<<endl;
470 wd2[k].etat = -wd2[k].etat; // mark the point as a crossing point
479 // crossing test on crossing points.
482 for (i = 1; i < (int)wd1.size(); i++) {
483 if (wd1[i].etat > 0 && wd1[i].etat < 11) { //test of crossing points
484 Utest = wd1[i].ustart;
485 Vtest = wd1[i].vstart;
489 if (((Up-Utest) * (UV1-Utest) + (Vp-Vtest) * (UV2-Vtest) < 0) ||
490 (Abs(UV1-Utest) < tolu && Abs(UV2-Vtest) < tolv))
492 else if (nbMultiplicities[i] > 0) {
494 for (k = 1; k < i; k++) N = N + nbMultiplicities[k];
495 for (Standard_Integer j = N + 1; j <= N + nbMultiplicities[i]; j++) {
496 Standard_Real Umultj = Umult(j)/deltau;
497 Standard_Real Vmultj = Vmult(j)/deltav;
498 if (((Up-Umultj)*(UV1-Umultj) +
499 (Vp-Vmultj)*(UV2-Vmultj) < 0) ||
500 (Abs(UV1-Umultj) < tolu &&
501 Abs(UV2-Vmultj) < tolv)) {
513 Standard_Boolean IntWalk_IWalking::TestArretAjout
516 Standard_Integer& Irang,
517 IntSurf_PntOn2S& Psol)
519 // test of stop on added points
520 // these are the points on the natural biorder that were not given at input
521 // return : Psol, the added point.
522 // Irang, index in the iterator of added points.
523 // UV, parameter of the added point.
526 Standard_Boolean Arrive = Standard_False;
531 previousPoint.ParametersOnS2(Up,Vp);
534 previousPoint.ParametersOnS1(Up,Vp);
537 Standard_Integer nbAjout = seqAjout.Length();
538 for (Standard_Integer i = 1; i <= nbAjout; i++) {
539 Irang = seqAjout.Value(i);
541 // add test Abs(Irang) <= lines.Length() for the case when
542 // a closed line is opened by adding a 1 point on this same
543 // line. Anyway there is a huge problem as 2 points will be
544 // added on this line...
546 if (Abs(Irang) <= lines.Length()) {
548 const Handle(IntWalk_TheIWLine)& Line = lines.Value(Abs(Irang));
550 Psol = Line->Value(Line->NbPoints());
552 Psol = Line->Value(1);
554 Psol.ParametersOnS2(U1, V1);
557 Psol.ParametersOnS1(U1, V1);
559 if (((Up-U1) * (UV(1)-U1) +
560 (Vp-V1) * (UV(2)-V1)) < 0 ||
561 (Abs(UV(1)-U1) < tolerance(1) &&
562 Abs(UV(2)-V1) < tolerance(2))) {
563 //jag 940615 Irang= -Abs(Irang);
564 Arrive = Standard_True;
567 Standard_Real abidF[1], abidD[1][2];
568 math_Vector bidF(abidF,1,1);
569 math_Matrix bidD(abidD,1,1,1,2);
570 sp.Values(UV,bidF,bidD);
578 void IntWalk_IWalking::FillPntsInHoles(TheIWFunction& sp,
579 TColStd_SequenceOfInteger& CopySeqAlone,
580 IntSurf_SequenceOfInteriorPoint& PntsInHoles)
582 math_Vector BornInf(1,2), BornSup(1,2);
587 PointLineLine.Clear();
588 TColStd_SequenceOfInteger SeqToRemove;
589 TColStd_MapOfInteger BadSolutions;
591 for (Standard_Integer i = 1; i < CopySeqAlone.Length(); i++)
593 Standard_Integer Irang1 = CopySeqAlone(i);
596 Standard_Boolean ToRemove = Standard_False;
597 IntSurf_PntOn2S PointAlone1, PointAlone2;
598 const Handle(IntWalk_TheIWLine)& Line1 = lines.Value(Abs(Irang1));
600 PointAlone1 = Line1->Value(Line1->NbPoints());
602 PointAlone1 = Line1->Value(1);
603 gp_Pnt2d P2d1 = PointAlone1.ValueOnSurface(reversed), P2d2;
604 Standard_Real MinSqDist = RealLast();
605 Standard_Integer MinRang = 0, MinIndex = 0;
606 for (Standard_Integer j = i+1; j <= CopySeqAlone.Length(); j++)
608 Standard_Integer Irang2 = CopySeqAlone(j);
610 BadSolutions.Contains(Irang2))
612 const Handle(IntWalk_TheIWLine)& Line2 = lines.Value(Abs(Irang2));
614 PointAlone2 = Line2->Value(Line2->NbPoints());
616 PointAlone2 = Line2->Value(1);
617 P2d2 = PointAlone2.ValueOnSurface(reversed);
618 Standard_Real aSqDist = P2d1.SquareDistance(P2d2);
619 if (aSqDist < MinSqDist)
626 //processing points from Irang1 and MinRang
629 SeqToRemove.Append(Irang1);
630 BadSolutions.Clear();
634 if (Abs(Irang1) == Abs(MinRang) &&
635 lines.Value(Abs(Irang1))->NbPoints() == 2)
637 SeqToRemove.Append(Irang1);
638 SeqToRemove.Append(MinRang);
640 CopySeqAlone(MinIndex) = 0;
641 BadSolutions.Clear();
645 const Handle(IntWalk_TheIWLine)& Line2 = lines.Value(Abs(MinRang));
647 PointAlone2 = Line2->Value(Line2->NbPoints());
649 PointAlone2 = Line2->Value(1);
650 gp_Pnt Pnt1 = PointAlone1.Value();
651 gp_Pnt Pnt2 = PointAlone2.Value();
652 P2d2 = PointAlone2.ValueOnSurface(reversed);
653 Standard_Real MinSqDist3d = Pnt1.SquareDistance(Pnt2);
654 if (MinSqDist3d <= epsilon ||
655 (Abs(P2d1.X() - P2d2.X()) <= tolerance(1) &&
656 Abs(P2d1.Y() - P2d2.Y()) <= tolerance(2))) //close points
657 ToRemove = Standard_True;
660 math_Vector UVap(1,2), UV(1,2);
661 UVap(1) = (P2d1.X() + P2d2.X())/2;
662 UVap(2) = (P2d1.Y() + P2d2.Y())/2;
663 math_FunctionSetRoot Rsnld(sp, tolerance);
664 Rsnld.Perform(sp, UVap, BornInf, BornSup);
665 if (Rsnld.IsDone() &&
666 Abs(sp.Root()) <= sp.Tolerance() &&
670 gp_Pnt2d Pmid(UV(1),UV(2));
671 gp_Vec2d P1P2(P2d1, P2d2);
672 gp_Vec2d P1Pmid(P2d1, Pmid);
673 gp_Vec2d P2Pmid(P2d2, Pmid);
674 Standard_Real ScalProd1 = P1P2 * P1Pmid;
675 Standard_Real ScalProd2 = P1P2 * P2Pmid;
676 Standard_Boolean IsPmidValid = (ScalProd1 > 0. && ScalProd2 < 0); //Pmid is in the middle
679 for (Standard_Integer iline = 1; iline <= lines.Length(); iline++)
680 if (IsPointOnLine(Pmid,iline))
682 IsPmidValid = Standard_False;
688 IntSurf_InteriorPoint aPoint(sp.Point(), UV(1), UV(2),
691 PntsInHoles.Append(aPoint);
692 TColStd_ListOfInteger LineLine;
693 LineLine.Append(Irang1);
694 LineLine.Append(MinRang);
695 PointLineLine.Bind(PntsInHoles.Length(), LineLine);
699 BadSolutions.Add(MinRang);
706 BadSolutions.Add(MinRang);
712 CopySeqAlone(MinIndex) = 0;
715 SeqToRemove.Append(Irang1);
716 SeqToRemove.Append(MinRang);
718 BadSolutions.Clear();
721 for (Standard_Integer i = 1; i <= SeqToRemove.Length(); i++)
722 for (Standard_Integer j = 1; j <= seqAlone.Length(); j++)
723 if (seqAlone(j) == SeqToRemove(i))
730 void IntWalk_IWalking::TestArretCadre
731 (const TColStd_SequenceOfReal& Umult,
732 const TColStd_SequenceOfReal& Vmult,
733 const Handle(IntWalk_TheIWLine)& Line,
736 Standard_Integer& Irang)
738 // test of stop when located on border.
739 // tried all tests of stop and arrived.
740 // test of stop on all given departure points already marked and on the entire current line.
741 // This line can be shortened if the stop point is found.
742 // Abs(Irang) = index in the iterator of departure points or 0
743 // if Irang <0 , it is necessary to add this point on the line (no Line->Cut)
744 // UV = parameter of the departure point
746 Standard_Real Scal, Up, Vp, Uc, Vc;
748 Standard_Boolean Found = Standard_False;
752 for (Standard_Integer i = 1; i < (int)wd1.size(); i++) {
753 if (wd1[i].etat < 0) {
754 N=0; // range in UVMult.
755 if (nbMultiplicities[i] > 0) {
756 for (Standard_Integer k = 1; k < i; k++)
757 N+=nbMultiplicities[k];
760 Line->Value(1).ParametersOnS2(Up,Vp);
763 Line->Value(1).ParametersOnS1(Up,Vp);
765 Standard_Integer nbp= Line->NbPoints();
766 for (Standard_Integer j = 2; j <= nbp; j++) {
768 Line->Value(j).ParametersOnS2(Uc,Vc);
771 Line->Value(j).ParametersOnS1(Uc,Vc);
774 Scal = (Up-wd1[i].ustart) * (Uc-wd1[i].ustart) +
775 (Vp-wd1[i].vstart) * (Vc-wd1[i].vstart);
776 // if a stop point is found: stop the line on this point.
778 Line->Cut(j); nbp= Line->NbPoints();
780 UV(1) = wd1[Irang].ustart;
781 UV(2) = wd1[Irang].vstart;
782 Found = Standard_True;
784 else if (Abs(Uc-wd1[i].ustart) < tolerance(1) &&
785 Abs(Vc-wd1[i].vstart) < tolerance(2) ) {
786 Line->Cut(j); nbp= Line->NbPoints();
788 UV(1) = wd1[Irang].ustart;
789 UV(2) = wd1[Irang].vstart;
790 Found = Standard_True;
792 else if (nbMultiplicities[i] > 0) {
793 for (Standard_Integer k = N+1; k <= N + nbMultiplicities[i]; k++) {
794 Scal = (Up-Umult(k)) * (Uc-Umult(k)) +
795 (Vp-Vmult(k)) * (Vc-Vmult(k));
797 Line->Cut(j); nbp= Line->NbPoints();
799 UV(1) = wd1[Irang].ustart;
800 UV(2) = wd1[Irang].vstart;
801 Found = Standard_True;
804 else if (Abs(Uc-Umult(k)) < tolerance(1) &&
805 Abs(Vc-Vmult(k)) < tolerance(2)) {
806 Line->Cut(j); nbp= Line->NbPoints();
808 UV(1) = wd1[Irang].ustart;
809 UV(2) = wd1[Irang].vstart;
810 Found = Standard_True;
816 Standard_Real abidF[1], abidD[1][2];
817 math_Vector bidF(abidF,1,1);
818 math_Matrix bidD(abidD,1,1,1,2);
819 sp.Values(UV,bidF,bidD);
820 Standard_Integer NBP = Line->NbPoints();
821 Standard_Integer Indextg;
822 Line->TangentVector(Indextg);
824 if(j>3 && j<=NBP+1) {
825 gp_Vec Dir3d = sp.Direction3d();
826 gp_Vec Dir3d1 = gp_Vec(Line->Value(j-2).Value(),Line->Value(j-1).Value());
827 Standard_Real dot = Dir3d.Dot(Dir3d1);
828 if(dot<0.0) { // Normally this Function should not be used often !!!
830 //-- cout<<" IntWalk_IWalking_2.gxx REVERSE "<<endl;
832 Line->SetTangentVector(previousd3d,j-1);
836 std::cout<<" IntWalk_IWalking_2.gxx : bizarrerie 30 10 97 "<<std::endl;
847 // now the last point of the line and the last calculated point are compated.
848 // there will be no need to "Cut"
850 Scal = (Up-wd1[i].ustart) * (UV(1)-wd1[i].ustart) +
851 // (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
852 // modified by NIZHNY-MKK Fri Oct 27 12:29:41 2000
853 (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
857 UV(1) = wd1[Irang].ustart;
858 UV(2) = wd1[Irang].vstart;
859 Found = Standard_True;
861 else if (Abs(UV(1)-wd1[i].ustart) < tolerance(1) &&
862 Abs(UV(2)-wd1[i].vstart) < tolerance(2)) {
864 UV(1) = wd1[Irang].ustart;
865 UV(2) = wd1[Irang].vstart;
866 Found = Standard_True;
868 else if (nbMultiplicities[i] > 0) {
869 for (Standard_Integer j = N+1; j <= N+nbMultiplicities[i]; j++) {
870 Scal = (Up-Umult(j)) * (UV(1)-Umult(j)) +
871 (Vp-Vmult(j)) * (UV(2)-Vmult(j));
874 UV(1) = wd1[Irang].ustart;
875 UV(2) = wd1[Irang].vstart;
876 Found = Standard_True;
879 else if (Abs(UV(1)-Umult(j)) < tolerance(1) &&
880 Abs(UV(2)-Vmult(j)) < tolerance(2)) {
882 UV(1) = wd1[Irang].ustart;
883 UV(2) = wd1[Irang].vstart;
884 Found = Standard_True;
890 Irang = -Irang; // jag 941017
891 Standard_Real abidF[1], abidD[1][2];
892 math_Vector bidF(abidF,1,1);
893 math_Matrix bidD(abidD,1,1,1,2);
894 sp.Values(UV,bidF,bidD);