2222#define No_Standard_OutOfRange
2323#endif
2424
25+ static void CutVectorByTolerances (gp_Vec2d& theVector,
26+ const math_Vector& theTolerance)
27+ {
28+ if (Abs(theVector.X()) < theTolerance(1))
29+ theVector.SetX (0.);
30+ if (Abs(theVector.Y()) < theTolerance(2))
31+ theVector.SetY (0.);
32+ }
2533
2634// _______________________________________________
2735//
@@ -771,8 +779,13 @@ void IntWalk_IWalking::TestArretCadre
771779 Line->Value(j).ParametersOnS1(Uc,Vc);
772780 }
773781
774- Scal = (Up-wd1[i].ustart) * (Uc-wd1[i].ustart) +
775- (Vp-wd1[i].vstart) * (Vc-wd1[i].vstart);
782+ gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
783+ aVec2 (Uc-wd1[i].ustart, Vc-wd1[i].vstart);
784+ CutVectorByTolerances (aVec1, tolerance);
785+ CutVectorByTolerances (aVec2, tolerance);
786+
787+ Scal = aVec1 * aVec2;
788+
776789 // if a stop point is found: stop the line on this point.
777790 if (Scal < 0) {
778791 Line->Cut(j); nbp= Line->NbPoints();
@@ -791,8 +804,14 @@ void IntWalk_IWalking::TestArretCadre
791804 }
792805 else if (nbMultiplicities[i] > 0) {
793806 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));
807+
808+ aVec1.SetCoord (Up-Umult(k), Vp-Vmult(k)),
809+ aVec2.SetCoord (Uc-Umult(k), Vc-Vmult(k));
810+ CutVectorByTolerances (aVec1, tolerance);
811+ CutVectorByTolerances (aVec2, tolerance);
812+
813+ Scal = aVec1 * aVec2;
814+
796815 if (Scal < 0) {
797816 Line->Cut(j); nbp= Line->NbPoints();
798817 Irang=i;
@@ -847,11 +866,13 @@ void IntWalk_IWalking::TestArretCadre
847866 // now the last point of the line and the last calculated point are compated.
848867 // there will be no need to "Cut"
849868
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);
854-
869+ gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
870+ aVec2 (UV(1)-wd1[i].ustart, UV(2)-wd1[i].vstart);
871+ CutVectorByTolerances (aVec1, tolerance);
872+ CutVectorByTolerances (aVec2, tolerance);
873+
874+ Scal = aVec1 * aVec2;
875+
855876 if (Scal < 0) {
856877 Irang = i;
857878 UV(1) = wd1[Irang].ustart;
@@ -867,8 +888,14 @@ void IntWalk_IWalking::TestArretCadre
867888 }
868889 else if (nbMultiplicities[i] > 0) {
869890 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));
891+
892+ aVec1.SetCoord (Up-Umult(j), Vp-Vmult(j));
893+ aVec2.SetCoord (UV(1)-Umult(j), UV(2)-Vmult(j));
894+ CutVectorByTolerances (aVec1, tolerance);
895+ CutVectorByTolerances (aVec2, tolerance);
896+
897+ Scal = aVec1 * aVec2;
898+
872899 if (Scal < 0) {
873900 Irang=i;
874901 UV(1) = wd1[Irang].ustart;
0 commit comments