]> OCCT Git - occt.git/commitdiff
0032747: Modeling Algorithms - Exact HLR algorithm gives wrong result
authorjgv <jgv@opencascade.com>
Fri, 24 Dec 2021 04:12:49 +0000 (07:12 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 10 Jan 2022 16:42:11 +0000 (19:42 +0300)
Modify the method IntWalk_IWalking::TestArretCadre: correct the value of scalar product of two vectors according to the tolerances in U and V.

src/IntWalk/IntWalk_IWalking_2.gxx
tests/hlr/end [deleted file]
tests/hlr/exact_hlr/C13
tests/hlr/exact_hlr/C18
tests/hlr/exact_hlr/C3
tests/hlr/exact_hlr/bug32747 [new file with mode: 0644]
tests/hlr/exact_hlr/end [new file with mode: 0644]
tests/hlr/poly_hlr/end [new file with mode: 0644]

index a35a87531be125ad41158511e36c5df72973e680..2e5d7f0cdd2d319dec598d6144e47e70daf7d05e 100644 (file)
 #define No_Standard_OutOfRange
 #endif
 
+static void CutVectorByTolerances (gp_Vec2d&          theVector,
+                                   const math_Vector& theTolerance)
+{
+  if (Abs(theVector.X()) < theTolerance(1))
+    theVector.SetX (0.);
+  if (Abs(theVector.Y()) < theTolerance(2))
+    theVector.SetY (0.);
+}
 
 // _______________________________________________
 //
@@ -771,8 +779,13 @@ void IntWalk_IWalking::TestArretCadre
          Line->Value(j).ParametersOnS1(Uc,Vc);
        }
 
-       Scal = (Up-wd1[i].ustart) * (Uc-wd1[i].ustart) +
-              (Vp-wd1[i].vstart) * (Vc-wd1[i].vstart);
+        gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
+          aVec2 (Uc-wd1[i].ustart, Vc-wd1[i].vstart);
+        CutVectorByTolerances (aVec1, tolerance);
+        CutVectorByTolerances (aVec2, tolerance);
+
+        Scal = aVec1 * aVec2;
+        
         // if a stop point is found: stop the line on this point.
        if (Scal < 0) { 
           Line->Cut(j);  nbp= Line->NbPoints();
@@ -791,8 +804,14 @@ void IntWalk_IWalking::TestArretCadre
        }
        else if (nbMultiplicities[i] > 0) {
           for (Standard_Integer k = N+1; k <= N + nbMultiplicities[i]; k++) {
-           Scal = (Up-Umult(k)) * (Uc-Umult(k)) +
-                  (Vp-Vmult(k)) * (Vc-Vmult(k));
+
+            aVec1.SetCoord (Up-Umult(k), Vp-Vmult(k)),
+            aVec2.SetCoord (Uc-Umult(k), Vc-Vmult(k));
+            CutVectorByTolerances (aVec1, tolerance);
+            CutVectorByTolerances (aVec2, tolerance);
+
+            Scal = aVec1 * aVec2;
+            
            if (Scal < 0) { 
              Line->Cut(j);  nbp= Line->NbPoints();
              Irang=i;
@@ -847,11 +866,13 @@ void IntWalk_IWalking::TestArretCadre
       // now the last point of the line and the last calculated point are compated.
       // there will be no need to "Cut"
 
-      Scal = (Up-wd1[i].ustart) * (UV(1)-wd1[i].ustart) +
-       //      (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
-      // modified by NIZHNY-MKK  Fri Oct 27 12:29:41 2000
-       (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
-
+      gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
+        aVec2 (UV(1)-wd1[i].ustart, UV(2)-wd1[i].vstart);
+      CutVectorByTolerances (aVec1, tolerance);
+      CutVectorByTolerances (aVec2, tolerance);
+      
+      Scal = aVec1 * aVec2;
+      
       if (Scal < 0) { 
         Irang = i;
        UV(1) = wd1[Irang].ustart;
@@ -867,8 +888,14 @@ void IntWalk_IWalking::TestArretCadre
       }
       else if (nbMultiplicities[i] > 0) {
         for (Standard_Integer j = N+1; j <= N+nbMultiplicities[i]; j++) {
-         Scal = (Up-Umult(j)) * (UV(1)-Umult(j)) +
-                 (Vp-Vmult(j)) * (UV(2)-Vmult(j));
+
+          aVec1.SetCoord (Up-Umult(j), Vp-Vmult(j));
+          aVec2.SetCoord (UV(1)-Umult(j), UV(2)-Vmult(j));
+          CutVectorByTolerances (aVec1, tolerance);
+          CutVectorByTolerances (aVec2, tolerance);
+          
+          Scal = aVec1 * aVec2;
+          
          if (Scal < 0) { 
            Irang=i;
            UV(1) = wd1[Irang].ustart;
diff --git a/tests/hlr/end b/tests/hlr/end
deleted file mode 100644 (file)
index c285324..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-checkprops result -l ${length} -deps ${depsilon}
-
-checkview -screenshot -2d -path ${imagedir}/${test_image}.png
-
-# to end a test script
-puts "TEST COMPLETED"
index 6f702cdfd272f20e6d8658155bd20430efaac1d4..255ff26e64a2a8b4bef21449eebfa190dabbe7f2 100644 (file)
@@ -1,5 +1,3 @@
-puts "TODO OCC30286 ALL: Error : The length of result shape is 9589.21, expected 9547.11"
-
 set viewname "vright"
 set length 9547.11
 
index 1b73d4c3a4a06b765acc0b41061eeb4ef8b361fe..ca7c58f7aff1638447aeed1dd12e3522a6aa1962 100644 (file)
@@ -1,6 +1,3 @@
-puts "TODO OCC30286 Windows: Error : The length of result shape is 2416.66, expected 2418.08"
-puts "TODO OCC30286 Linux: Error : The length of result shape is 2414.48, expected 2418.08"
-
 set viewname "vright"
 set length 2418.08
 
index 5211d9ca174281c5dde167b75739fbf4ecd55704..8046b6722c9a7c48d8a08e55c1d04760542330d6 100644 (file)
@@ -1,7 +1,5 @@
-puts "TODO OCC30286 Linux: Error : The length of result shape is 3249.9, expected 3234.6"
-
 set viewname "vright"
-set length 3234.6
+set length 3237.63
 
 testreadstep [locate_data_file bug27341_570-DWLNL-40-08-L_131LANG_16VERSATZ_DIN.stp] a
 COMPUTE_HLR $viewname $algotype
diff --git a/tests/hlr/exact_hlr/bug32747 b/tests/hlr/exact_hlr/bug32747
new file mode 100644 (file)
index 0000000..ae97d80
--- /dev/null
@@ -0,0 +1,10 @@
+puts "================================================"
+puts "OCC32747: Exact HLR algorithm gives wrong result"
+puts "================================================"
+puts ""
+
+set viewname "vfront"
+set length 34.3597
+
+restore [locate_data_file bug32747.brep] a
+COMPUTE_HLR $viewname $algotype
diff --git a/tests/hlr/exact_hlr/end b/tests/hlr/exact_hlr/end
new file mode 100644 (file)
index 0000000..0928d55
--- /dev/null
@@ -0,0 +1,6 @@
+checkprops result -l ${length}
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
+
+# to end a test script
+puts "TEST COMPLETED"
diff --git a/tests/hlr/poly_hlr/end b/tests/hlr/poly_hlr/end
new file mode 100644 (file)
index 0000000..c285324
--- /dev/null
@@ -0,0 +1,6 @@
+checkprops result -l ${length} -deps ${depsilon}
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
+
+# to end a test script
+puts "TEST COMPLETED"