0032601: Foundation Classes - Poly_Connect hangs on the given incorrect triangulation
authormsv <msv@opencascade.com>
Fri, 1 Oct 2021 19:23:36 +0000 (22:23 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 4 Oct 2021 16:53:12 +0000 (19:53 +0300)
src/Poly/Poly_Connect.cxx
src/Poly/Poly_Connect.hxx
tests/bugs/fclasses/bug32601 [new file with mode: 0644]

index 8c6c6bd7bf03ef9ad75402490c6eac37136da270..15e0b2b6ddb0ae4283dfbb336ff104fa54793e04 100644 (file)
@@ -223,6 +223,8 @@ void Poly_Connect::Initialize(const Standard_Integer N)
   mytr = myfirst;
   mysense = Standard_True;
   mymore = (myfirst != 0);
+  myPassedTr.Clear();
+  myPassedTr.Add (mytr);
   if (mymore)
   {
     Standard_Integer i, no[3];
@@ -247,15 +249,16 @@ void Poly_Connect::Next()
   if (mysense) {
     for (i = 0; i < 3; i++) {
       if (t[i] != 0) {
-       myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
-       for (j = 0; j < 3; j++) {
-         if ((n[j] == mynode) && (n[(j+1)%3] == myothernode)) {
-           mytr = t[i];
-           myothernode = n[(j+2)%3];
-           mymore = (mytr != myfirst);
-           return;
-         }
-       }
+        myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
+        for (j = 0; j < 3; j++) {
+          if ((n[j] == mynode) && (n[(j+1)%3] == myothernode)) {
+            mytr = t[i];
+            myothernode = n[(j+2)%3];
+            mymore = !myPassedTr.Contains (mytr);
+            myPassedTr.Add (mytr);
+            return;
+          }
+        }
       }
     }
     // sinon, depart vers la gauche.
@@ -270,15 +273,16 @@ void Poly_Connect::Next()
   if (!mysense) {
     for (i = 0; i < 3; i++) {
       if (t[i] != 0) {
-       myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
-       for (j = 0; j < 3; j++) {
-         if ((n[j] == mynode) && (n[(j+2)%3] == myothernode)) {
-           mytr = t[i];
-           myothernode = n[(j+1)%3];
-           mymore = Standard_True;
-           return;
-         }
-       }
+        myTriangulation->Triangle (t[i]).Get (n[0], n[1], n[2]);
+        for (j = 0; j < 3; j++) {
+          if ((n[j] == mynode) && (n[(j+2)%3] == myothernode)) {
+            mytr = t[i];
+            myothernode = n[(j+1)%3];
+            mymore = !myPassedTr.Contains (mytr);
+            myPassedTr.Add (mytr);
+            return;
+          }
+        }
       }
     }
   }
index 29fa2024a315441db80fb495eb380c61f426a5ea..e2ad454e9130b4dc764dd29cf260576a1cf4a775 100644 (file)
@@ -22,6 +22,7 @@
 #include <Standard_Handle.hxx>
 
 #include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Boolean.hxx>
 class Poly_Triangulation;
@@ -159,6 +160,7 @@ private:
   Standard_Integer myothernode;
   Standard_Boolean mysense;
   Standard_Boolean mymore;
+  TColStd_PackedMapOfInteger myPassedTr;
 
 };
 
diff --git a/tests/bugs/fclasses/bug32601 b/tests/bugs/fclasses/bug32601
new file mode 100644 (file)
index 0000000..4b738db
--- /dev/null
@@ -0,0 +1,13 @@
+puts "============"
+puts "0032601: Foundation Classes - Poly_Connect hangs on the given incorrect triangulation"
+puts "============"
+puts ""
+
+cpulimit 30
+
+restore [locate_data_file cone_bad_tri.brep] a
+vinit Viewer1/View1
+vdefaults -autotriang 0
+vdisplay a
+vfit
+vsetdispmode 1