From 41fc11b0561b4f851bb9f35d50b0f3015461d6e8 Mon Sep 17 00:00:00 2001 From: msv Date: Fri, 1 Oct 2021 22:23:36 +0300 Subject: [PATCH] 0032601: Foundation Classes - Poly_Connect hangs on the given incorrect triangulation --- src/Poly/Poly_Connect.cxx | 40 ++++++++++++++++++++---------------- src/Poly/Poly_Connect.hxx | 2 ++ tests/bugs/fclasses/bug32601 | 13 ++++++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 tests/bugs/fclasses/bug32601 diff --git a/src/Poly/Poly_Connect.cxx b/src/Poly/Poly_Connect.cxx index 8c6c6bd7bf..15e0b2b6dd 100644 --- a/src/Poly/Poly_Connect.cxx +++ b/src/Poly/Poly_Connect.cxx @@ -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; + } + } } } } diff --git a/src/Poly/Poly_Connect.hxx b/src/Poly/Poly_Connect.hxx index 29fa2024a3..e2ad454e91 100644 --- a/src/Poly/Poly_Connect.hxx +++ b/src/Poly/Poly_Connect.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include 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 index 0000000000..4b738db18b --- /dev/null +++ b/tests/bugs/fclasses/bug32601 @@ -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