From 954bcd5881573294e6109ecf2abb64397d3b7aa6 Mon Sep 17 00:00:00 2001 From: Alan <37482427+alemon-aquaveo@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:48:07 -0700 Subject: [PATCH 1/4] -update version number -bug fix for TrTinImpl::OptimizeTriangulation. It is now working. --- _package/xms/grid/__init__.py | 2 +- xmsgrid/triangulate/TrTin.cpp | 49 ++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/_package/xms/grid/__init__.py b/_package/xms/grid/__init__.py index 185f32c6..94ddc64e 100644 --- a/_package/xms/grid/__init__.py +++ b/_package/xms/grid/__init__.py @@ -3,4 +3,4 @@ from . import triangulate # NOQA: F401 from . import ugrid # NOQA: F401 -__version__ = '7.7.4' +__version__ = '7.7.5' diff --git a/xmsgrid/triangulate/TrTin.cpp b/xmsgrid/triangulate/TrTin.cpp index db44cce0..b7b0e871 100644 --- a/xmsgrid/triangulate/TrTin.cpp +++ b/xmsgrid/triangulate/TrTin.cpp @@ -535,7 +535,7 @@ bool TrTinImpl::CheckAndSwap(int a_triA, int a_triB, bool a_propagate, const Vec tri2id0 = trIncrementIndex(tri2id2); tri1id2 = LocalIndex(a_triA, GlobalIndex(a_triB, tri2id0)); - SwapEdge(a_triA, a_triB, false); + change = SwapEdge(a_triA, a_triB, false); int adjTri = AdjacentTriangle(a_triA, tri1id2); if (a_propagate || (!a_propagate && adjTri != XM_NONE && a_flags[adjTri])) { @@ -548,7 +548,7 @@ bool TrTinImpl::CheckAndSwap(int a_triA, int a_triB, bool a_propagate, const Vec } } - return false; + return change; } // TrTinImpl::CheckAndSwap //------------------------------------------------------------------------------ /// \brief Returns \a true if a_localPt of a_tri2 is inside a_tri1's @@ -582,8 +582,14 @@ bool TrTinImpl::CheckAndSwap(int a_triA, int a_triB, bool a_propagate, const Vec //------------------------------------------------------------------------------ bool TrTinImpl::PointIsInCircumcircle(int a_tri1, int a_tri2, int a_localPt) { + VecPt3d& pts = *m_pts; + VecInt& tris = *m_tris; + int t = a_tri1 * 3; - return (gmPtInCircumcircle((*m_pts)[GlobalIndex(a_tri2, a_localPt)], &(*m_pts)[t]) == PT_IN); + Pt3d tri1_pts[3] = {pts[tris[t]], pts[tris[t + 1]], pts[tris[t + 2]]}; + Pt3d tri2_pt = pts[GlobalIndex(a_tri2, a_localPt)]; + + return (gmPtInCircumcircle(tri2_pt, tri1_pts) == PT_IN); } // TrTinImpl::PointIsInCircumcircle //------------------------------------------------------------------------------ /// \brief Return index of common edge between triangle and neighbor. Edge @@ -1108,7 +1114,7 @@ bool TrTinImpl::OptimizeTriangulation() { bool modified = false; int nTri = NumTriangles(); - VecInt flags(nTri, false); + VecInt no_propagate_flags(nTri, false); bool meshaltered; int id; @@ -1116,33 +1122,32 @@ bool TrTinImpl::OptimizeTriangulation() do { + VecInt local_flags(nTri, true); meshaltered = false; for (int tri = 0; tri < nTri; ++tri) { - if (flags[tri]) + id = 0; + for (int i = 0; i <= 2; i++) { - id = 0; - for (int i = 0; i <= 2; i++) + // get neighboring element + adjtri = AdjacentTriangle(tri, id); + if (adjtri != XM_NONE && local_flags[adjtri]) { - // get neighboring element - adjtri = AdjacentTriangle(tri, id); - if (adjtri != XM_NONE && flags[adjtri]) + // swap if needed and propagate + if (CheckAndSwap(tri, adjtri, false, no_propagate_flags)) { - // swap if needed and propagate - if (CheckAndSwap(tri, adjtri, false, flags)) - { - meshaltered = true; - } + meshaltered = true; } - id = trIncrementIndex(id); } + id = trIncrementIndex(id); } + local_flags[tri] = false; // don't process this triangle again } if (meshaltered) modified = true; } while (meshaltered); - return true; + return modified; } // TrTinImpl::OptimizeTriangulation //------------------------------------------------------------------------------ /// \brief finds the index of adjacent triangle that points to the current @@ -1944,11 +1949,11 @@ void TrTinUnitTests::test1() // | | \ 3 | \ 7 | // | | \ | \ | // | | \ | \ | -// | | 2 \ | 6 \ | +// | | 1 \ | 5 \ | // | | \| \| // 10- 3------4------5 // | |\ |\ | -// | | \ 1 | \ 5 | +// | | \ 2 | \ 6 | // | | \ | \ | // | | \ | \ | // | | 0 \ | 4 \ | @@ -1983,8 +1988,10 @@ void TrTinUnitTests::testOptimizeTriangulation() // Optimize TS_ASSERT(tin->OptimizeTriangulation()); - VecInt trisAfter = {0, 1, 3, 1, 6, 3, 1, 4, 6, 4, 7, 6, 1, 2, 4, 2, 7, 4, 2, 5, 7, 5, 8, 7}; - TS_ASSERT_EQUALS_VEC(trisAfter, tin->Triangles()); + VecInt trisAfter = {0, 1, 3, 4, 6, 3, 1, 4, 3, 4, 7, 6, 1, 2, 4, 5, 7, 4, 2, 5, 4, 5, 8, 7}; + VecInt tris2 = tin->Triangles(); + TS_ASSERT_EQUALS_VEC(trisAfter, tris2); + TS_ASSERT(!tin->OptimizeTriangulation()); // Test GetBoundaryPoints tin->GetBoundaryPoints(boundaryPoints); From 728c6d5838a71757b68ca47e59d3becead1969e7 Mon Sep 17 00:00:00 2001 From: Alan <37482427+alemon-aquaveo@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:59:40 -0700 Subject: [PATCH 2/4] -github actions issues --- .github/workflows/XmsGrid-CI.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/XmsGrid-CI.yaml b/.github/workflows/XmsGrid-CI.yaml index f02fc57f..afcdfe64 100644 --- a/.github/workflows/XmsGrid-CI.yaml +++ b/.github/workflows/XmsGrid-CI.yaml @@ -202,7 +202,7 @@ jobs: - name: Install Python Dependencies run: | python -m pip install --upgrade pip - pip install conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 + pip install pyYAML==3.5.1 conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 python -m pip install -i https://public.aquapi.aquaveo.com/aquaveo/stable/+simple/ "xmsconan>=1.0.4,<2" # Login to Aquaveo Docker - name: Login to Aquaveo Docker @@ -328,7 +328,7 @@ jobs: - name: Install Python Dependencies run: | python -m pip install --upgrade pip - pip install conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 + pip install pyYAML==3.5.1 conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 python -m pip install -i https://public.aquapi.aquaveo.com/aquaveo/stable/+simple/ "xmsconan>=1.0.4,<2" # Setup Visual Studio - name: Setup Visual Studio From cf3a18082b05bc1fe4b7dbc0838c232fed666929 Mon Sep 17 00:00:00 2001 From: Alan <37482427+alemon-aquaveo@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:01:51 -0700 Subject: [PATCH 3/4] -fix python test --- _package/tests/unit_tests/triangulate_tests/tin_pyt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_package/tests/unit_tests/triangulate_tests/tin_pyt.py b/_package/tests/unit_tests/triangulate_tests/tin_pyt.py index e42fbcbb..6574e5ad 100644 --- a/_package/tests/unit_tests/triangulate_tests/tin_pyt.py +++ b/_package/tests/unit_tests/triangulate_tests/tin_pyt.py @@ -325,8 +325,10 @@ def test_optimize_triangulation(self): tris_adj = ((0,), (0, 1, 2, 4), (4, 5, 6), (0, 1), (2, 4, 5, 3), (6, 7), (1, 2, 3), (3, 5, 6, 7), (7,)) trtin.set_geometry(pts, tris, tris_adj) - trtin.optimize_triangulation() - np.testing.assert_array_equal(np.array(tris), trtin.triangles) + self.assertTrue(trtin.optimize_triangulation()) + tris_after = (0, 1, 3, 4, 6, 3, 1, 4, 3, 4, 7, 6, 1, 2, 4, 5, 7, 4, 2, 5, 4, 5, 8, 7) + np.testing.assert_array_equal(np.array(tris_after), trtin.triangles) + self.assertFalse(trtin.optimize_triangulation()) def test_build_tris_adj_to_pts(self): """Test building triangles adjacent to points.""" From ff7f366705ea297f95eb8f2dff81ca141967fcb9 Mon Sep 17 00:00:00 2001 From: Alan <37482427+alemon-aquaveo@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:02:43 -0700 Subject: [PATCH 4/4] -fix action --- .github/workflows/XmsGrid-CI.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/XmsGrid-CI.yaml b/.github/workflows/XmsGrid-CI.yaml index afcdfe64..dad26023 100644 --- a/.github/workflows/XmsGrid-CI.yaml +++ b/.github/workflows/XmsGrid-CI.yaml @@ -202,7 +202,7 @@ jobs: - name: Install Python Dependencies run: | python -m pip install --upgrade pip - pip install pyYAML==3.5.1 conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 + pip install pyYAML==5.3.1 conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 python -m pip install -i https://public.aquapi.aquaveo.com/aquaveo/stable/+simple/ "xmsconan>=1.0.4,<2" # Login to Aquaveo Docker - name: Login to Aquaveo Docker @@ -328,7 +328,7 @@ jobs: - name: Install Python Dependencies run: | python -m pip install --upgrade pip - pip install pyYAML==3.5.1 conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 + pip install pyYAML==5.3.1 conan==1.41.0 conan-package-tools==0.35.1 devpi-client wheel MarkupSafe==2.0.0 python -m pip install -i https://public.aquapi.aquaveo.com/aquaveo/stable/+simple/ "xmsconan>=1.0.4,<2" # Setup Visual Studio - name: Setup Visual Studio