From 3912cd76dd1e89c3e3e68509ab472ab7996f6fd1 Mon Sep 17 00:00:00 2001 From: Alan Morris Date: Wed, 14 Aug 2024 09:33:16 -0600 Subject: [PATCH] Upgrade to VTK 9.3.1 to fix #2308 (#2309) * Upgrade to VTK 9.3.1 to fix #2308 * Apply build fix for static windows https://github.com/Kitware/VTK/pull/67/files to our vtk patch * Add pip cache purge * Remove .o files after build --- .github/workflows/build-linux-debug.yml | 11 +++- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-windows.yml | 2 +- .github/workflows/gha_conda.sh | 2 + CMakeLists.txt | 2 +- Support/{vtk-9.1.patch => vtk-9.3.1.patch} | 65 +++++++++++++--------- Testing/OptimizeTests/OptimizeTests.cpp | 15 ++++- build_dependencies.sh | 7 +-- python_requirements.txt | 2 +- 9 files changed, 71 insertions(+), 37 deletions(-) rename Support/{vtk-9.1.patch => vtk-9.3.1.patch} (52%) diff --git a/.github/workflows/build-linux-debug.yml b/.github/workflows/build-linux-debug.yml index 03240242c1..5ad3990aea 100644 --- a/.github/workflows/build-linux-debug.yml +++ b/.github/workflows/build-linux-debug.yml @@ -73,7 +73,7 @@ jobs: - name: cmake shell: bash -l {0} - run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS=-g -DITK_DIR=$HOME/install/lib/cmake/ITK-5.3 -DVTK_DIR=$HOME/install/lib/cmake/vtk-9.1 -DXLNT_DIR=$HOME/install -DLIBIGL_DIR=$HOME/install -DOpenVDB_DIR=$HOME/install/lib/cmake/OpenVDB -DGEOMETRYCENTRAL_DIR=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBuild_Studio=ON -DJKQTCommonSharedLib_DIR=$HOME/install/lib/cmake/JKQTCommonSharedLib -DJKQTMathTextSharedLib_DIR=$HOME/install/lib/cmake/JKQTMathTextSharedLib -DJKQTPlotterSharedLib_DIR=$HOME/install/lib/cmake/JKQTPlotterSharedLib -DACVD_DIR=$HOME/install -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DUSE_ORIGIN_RPATH=ON .. + run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS=-g -DITK_DIR=$HOME/install/lib/cmake/ITK-5.3 -DVTK_DIR=$HOME/install/lib/cmake/vtk-9.3 -DXLNT_DIR=$HOME/install -DLIBIGL_DIR=$HOME/install -DOpenVDB_DIR=$HOME/install/lib/cmake/OpenVDB -DGEOMETRYCENTRAL_DIR=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBuild_Studio=ON -DJKQTCommonSharedLib_DIR=$HOME/install/lib/cmake/JKQTCommonSharedLib -DJKQTMathTextSharedLib_DIR=$HOME/install/lib/cmake/JKQTMathTextSharedLib -DJKQTPlotterSharedLib_DIR=$HOME/install/lib/cmake/JKQTPlotterSharedLib -DACVD_DIR=$HOME/install -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DUSE_ORIGIN_RPATH=ON .. - name: Check space6 run: df -h @@ -89,6 +89,15 @@ jobs: shell: bash -l {0} run: conda activate shapeworks && cd build && make install + - name: Check space8 + run: df -h + + - name: Clean intermediate files + run: find . -name "*.o" -type f -delete + + - name: Check space9 + run: df -h + - name: Download test data shell: bash -l {0} run: .github/workflows/download_test_data.sh diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 45b76d266b..0901a7ec89 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -72,7 +72,7 @@ jobs: - name: cmake shell: bash -l {0} - run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS=-g -DITK_DIR=$HOME/install/lib/cmake/ITK-5.3 -DVTK_DIR=$HOME/install/lib/cmake/vtk-9.1 -DXLNT_DIR=$HOME/install -DLIBIGL_DIR=$HOME/install -DOpenVDB_DIR=$HOME/install/lib/cmake/OpenVDB -DGEOMETRYCENTRAL_DIR=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBuild_Studio=ON -DJKQTCommonSharedLib_DIR=$HOME/install/lib/cmake/JKQTCommonSharedLib -DJKQTMathTextSharedLib_DIR=$HOME/install/lib/cmake/JKQTMathTextSharedLib -DJKQTPlotterSharedLib_DIR=$HOME/install/lib/cmake/JKQTPlotterSharedLib -DACVD_DIR=$HOME/install -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DUSE_ORIGIN_RPATH=ON -DGA_MEASUREMENT_ID=$GA_MEASUREMENT_ID -DGA_API_SECRET=$GA_API_SECRET .. + run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_CXX_FLAGS=-g -DITK_DIR=$HOME/install/lib/cmake/ITK-5.3 -DVTK_DIR=$HOME/install/lib/cmake/vtk-9.3 -DXLNT_DIR=$HOME/install -DLIBIGL_DIR=$HOME/install -DOpenVDB_DIR=$HOME/install/lib/cmake/OpenVDB -DGEOMETRYCENTRAL_DIR=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBuild_Studio=ON -DJKQTCommonSharedLib_DIR=$HOME/install/lib/cmake/JKQTCommonSharedLib -DJKQTMathTextSharedLib_DIR=$HOME/install/lib/cmake/JKQTMathTextSharedLib -DJKQTPlotterSharedLib_DIR=$HOME/install/lib/cmake/JKQTPlotterSharedLib -DACVD_DIR=$HOME/install -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DUSE_ORIGIN_RPATH=ON -DGA_MEASUREMENT_ID=$GA_MEASUREMENT_ID -DGA_API_SECRET=$GA_API_SECRET .. - name: Check space5 run: df -h diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 0e43bd0030..2f68b20dfa 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -109,7 +109,7 @@ jobs: # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: conda activate shapeworks && cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="-FS" -DCMAKE_C_FLAGS="-FS" -DCMAKE_CXX_FLAGS_RELEASE="-FS /Zm500 /Zi /GL /MD /O2 /Ob3 /DNDEBUG /EHsc" -DCMAKE_C_FLAGS_RELEASE="-FS /Zi /GL /MD /O2 /Ob3 /DNDEBUG /EHsc" -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="-LTCG /DEBUG" -DCMAKE_EXE_LINKER_FLAGS_RELEASE="-LTCG /DEBUG" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DITK_DIR="C:\deps\lib\cmake\ITK-5.3" -DVTK_DIR="C:\deps\lib\cmake\vtk-9.1" -DXLNT_DIR="C:\deps" -DLIBIGL_DIR="C:\deps" -DJKQTCommonSharedLib_DIR="C:/deps/lib/cmake/JKQTCommonSharedLib" -DJKQTMathTextSharedLib_DIR="C:/deps/lib/cmake/JKQTMathTextSharedLib" -DJKQTPlotterSharedLib_DIR="C:/deps/lib/cmake/JKQTPlotterSharedLib" -DOpenVDB_DIR="C:\deps\lib\cmake\OpenVDB" -DGEOMETRYCENTRAL_DIR="C:\deps" -DACVD_DIR="C:\deps" -DBuild_Studio=ON -DGA_MEASUREMENT_ID=$GA_MEASUREMENT_ID -DGA_API_SECRET=$GA_API_SECRET + run: conda activate shapeworks && cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="-FS" -DCMAKE_C_FLAGS="-FS" -DCMAKE_CXX_FLAGS_RELEASE="-FS /Zm500 /Zi /GL /MD /O2 /Ob3 /DNDEBUG /EHsc" -DCMAKE_C_FLAGS_RELEASE="-FS /Zi /GL /MD /O2 /Ob3 /DNDEBUG /EHsc" -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="-LTCG /DEBUG" -DCMAKE_EXE_LINKER_FLAGS_RELEASE="-LTCG /DEBUG" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DITK_DIR="C:\deps\lib\cmake\ITK-5.3" -DVTK_DIR="C:\deps\lib\cmake\vtk-9.3" -DXLNT_DIR="C:\deps" -DLIBIGL_DIR="C:\deps" -DJKQTCommonSharedLib_DIR="C:/deps/lib/cmake/JKQTCommonSharedLib" -DJKQTMathTextSharedLib_DIR="C:/deps/lib/cmake/JKQTMathTextSharedLib" -DJKQTPlotterSharedLib_DIR="C:/deps/lib/cmake/JKQTPlotterSharedLib" -DOpenVDB_DIR="C:\deps\lib\cmake\OpenVDB" -DGEOMETRYCENTRAL_DIR="C:\deps" -DACVD_DIR="C:\deps" -DBuild_Studio=ON -DGA_MEASUREMENT_ID=$GA_MEASUREMENT_ID -DGA_API_SECRET=$GA_API_SECRET - name: Build working-directory: "C:/build" diff --git a/.github/workflows/gha_conda.sh b/.github/workflows/gha_conda.sh index a867c0e7cd..846941378c 100755 --- a/.github/workflows/gha_conda.sh +++ b/.github/workflows/gha_conda.sh @@ -15,6 +15,8 @@ else # run install source ./install_shapeworks.sh --developer conda clean -p -t -y + pip cache info + pip cache purge fi conda init bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 573605fe82..d2ace495c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ project(ShapeWorks) ### vtk -find_package(VTK 9.1.0) +find_package(VTK 9.3.1) if (NOT VTK_FOUND) message(FATAL_ERROR "VTK is required, but could not be found! Make sure path to VTKConfig.cmake is included in CMAKE_PREFIX_PATH") endif() diff --git a/Support/vtk-9.1.patch b/Support/vtk-9.3.1.patch similarity index 52% rename from Support/vtk-9.1.patch rename to Support/vtk-9.3.1.patch index a0b424eb61..ab2ef70ae4 100644 --- a/Support/vtk-9.1.patch +++ b/Support/vtk-9.3.1.patch @@ -1,8 +1,44 @@ +diff --git a/Common/Core/SMP/Common/vtkSMPToolsImpl.h b/Common/Core/SMP/Common/vtkSMPToolsImpl.h +index f3d72b76de..8ed35c982d 100644 +--- a/Common/Core/SMP/Common/vtkSMPToolsImpl.h ++++ b/Common/Core/SMP/Common/vtkSMPToolsImpl.h +@@ -52,6 +52,9 @@ public: + //-------------------------------------------------------------------------------- + int GetEstimatedNumberOfThreads(); + ++ //-------------------------------------------------------------------------------- ++ int GetEstimatedDefaultNumberOfThreads(); ++ + //-------------------------------------------------------------------------------- + void SetNestedParallelism(bool isNested) { this->NestedActivated = isNested; } + +@@ -59,7 +62,7 @@ public: + bool GetNestedParallelism() { return this->NestedActivated; } + + //-------------------------------------------------------------------------------- +- bool IsParallelScope() { return this->IsParallel; } ++ bool IsParallelScope(); + + //-------------------------------------------------------------------------------- + bool GetSingleThread(); +@@ -115,6 +118,12 @@ private: + std::atomic IsParallel{ false }; + }; + ++template ++bool vtkSMPToolsImpl::IsParallelScope() ++{ ++ return this->IsParallel; ++} ++ + using ExecuteFunctorPtrType = void (*)(void*, vtkIdType, vtkIdType, vtkIdType); + + VTK_ABI_NAMESPACE_END diff --git a/Common/Core/vtkRandomPool.cxx b/Common/Core/vtkRandomPool.cxx -index 46f9aff201..273ca74c50 100644 +index c2bcf67d18..69ca63654a 100644 --- a/Common/Core/vtkRandomPool.cxx +++ b/Common/Core/vtkRandomPool.cxx -@@ -338,6 +338,9 @@ const double* vtkRandomPool::GeneratePool() +@@ -332,6 +332,9 @@ const double* vtkRandomPool::GeneratePool() if (actualThreads < numThreads) // readjust work load { numThreads = actualThreads; @@ -13,10 +49,10 @@ index 46f9aff201..273ca74c50 100644 // Now distribute work diff --git a/Filters/Modeling/vtkSelectEnclosedPoints.cxx b/Filters/Modeling/vtkSelectEnclosedPoints.cxx -index 0dcae6df7a..2986c1e7fd 100644 +index 7d5122297e..7a60c4b62e 100644 --- a/Filters/Modeling/vtkSelectEnclosedPoints.cxx +++ b/Filters/Modeling/vtkSelectEnclosedPoints.cxx -@@ -88,7 +88,10 @@ struct SelectInOutCheck +@@ -79,7 +79,10 @@ struct SelectInOutCheck // Precompute a sufficiently large enough random sequence this->Sequence = vtkRandomPool::New(); @@ -37,24 +73,3 @@ index 0dcae6df7a..2986c1e7fd 100644 int vtkSelectEnclosedPoints::IsInsideSurface(double x[3], vtkPolyData* surface, double bds[6], double length, double tolerance, vtkAbstractCellLocator* locator, vtkIdList* cellIds, -diff --git a/Rendering/OpenGL2/vtkCocoaRenderWindow.mm b/Rendering/OpenGL2/vtkCocoaRenderWindow.mm -index 0d63d49783..82e6b7c57f 100644 ---- a/Rendering/OpenGL2/vtkCocoaRenderWindow.mm -+++ b/Rendering/OpenGL2/vtkCocoaRenderWindow.mm -@@ -228,6 +228,16 @@ vtkCocoaRenderWindow::vtkCocoaRenderWindow() - //---------------------------------------------------------------------------- - vtkCocoaRenderWindow::~vtkCocoaRenderWindow() - { -+ // If we created a vtkCocoaGLView, clear its reference back to us. -+ if (this->GetViewCreated()) -+ { -+ NSView* glView = (NSView*)this->GetWindowId(); -+ if ([glView isKindOfClass:[vtkCocoaGLView class]]) -+ { -+ [(vtkCocoaGLView*)glView setVTKRenderWindow:nullptr]; -+ } -+ } -+ - if (this->CursorHidden) - { - this->ShowCursor(); diff --git a/Testing/OptimizeTests/OptimizeTests.cpp b/Testing/OptimizeTests/OptimizeTests.cpp index 8af75ea026..bdbbb50f93 100644 --- a/Testing/OptimizeTests/OptimizeTests.cpp +++ b/Testing/OptimizeTests/OptimizeTests.cpp @@ -19,6 +19,13 @@ using namespace shapeworks; static void prep_temp(std::string data, std::string name) { TestUtils::Instance().prep_temp(std::string(TEST_DATA_DIR) + "/optimize/shared", "shared"); TestUtils::Instance().prep_temp(std::string(TEST_DATA_DIR) + data, name); + +#ifdef _WIN32 + _putenv_s("VTK_SMP_BACKEND_IN_USE", "Sequential"); +#else + setenv("VTK_SMP_BACKEND_IN_USE", "Sequential", true); +#endif + } //--------------------------------------------------------------------------- @@ -412,7 +419,7 @@ TEST(OptimizeTests, procrustes_no_scale_test) { std::cerr << "Eigenvalue " << i << " : " << values[i] << "\n"; } ASSERT_GT(values[values.size() - 1], 150.0); - ASSERT_LT(values[values.size() - 1], 200.0); + ASSERT_LT(values[values.size() - 1], 215.0); } //--------------------------------------------------------------------------- @@ -433,6 +440,8 @@ TEST(OptimizeTests, procrustes_both_enabled_test) { bool success = app.Run(); ASSERT_TRUE(success); + project->save(); + // compute stats ParticleShapeStatistics stats(project); stats.compute_modes(); @@ -444,7 +453,7 @@ TEST(OptimizeTests, procrustes_both_enabled_test) { std::cerr << "Eigenvalue " << i << " : " << values[i] << "\n"; } // should be tiny with all of procrustes enabled - ASSERT_LT(values[values.size() - 1], 1.0); + ASSERT_LT(values[values.size() - 1], 3.0); } //--------------------------------------------------------------------------- @@ -476,7 +485,7 @@ TEST(OptimizeTests, procrustes_scale_only_test) { std::cerr << "Eigenvalue " << i << " : " << values[i] << "\n"; } ASSERT_GT(values[values.size() - 1], 275.0); - ASSERT_LT(values[values.size() - 1], 345.0); + ASSERT_LT(values[values.size() - 1], 380.0); } // TODO Move this to mesh tests? diff --git a/build_dependencies.sh b/build_dependencies.sh index caa23ec0b3..37ff388e5b 100755 --- a/build_dependencies.sh +++ b/build_dependencies.sh @@ -20,8 +20,8 @@ BUILD_STUDIO=0 BUILD_SHAPEWORKS=1 BUILD_TYPE="Release" BUILD_LOG="build_dependencies.log" -VTK_VER="v9.1.0" -VTK_VER_STR="9.1" +VTK_VER="v9.3.1" +VTK_VER_STR="9.3" ITK_VER="v5.3.0" ITK_VER_STR="5.3" QT_MIN_VER="5.15.4" @@ -134,8 +134,7 @@ build_vtk() cd vtk git checkout -f tags/${VTK_VER} - patch -p1 < ${SCRIPT_DIR}/Support/vtk-9.1.patch - cat Rendering/OpenGL2/vtkCocoaRenderWindow.mm + patch -p1 < ${SCRIPT_DIR}/Support/vtk-9.3.1.patch if [[ $BUILD_CLEAN = 1 ]]; then rm -rf build; fi mkdir -p build && cd build diff --git a/python_requirements.txt b/python_requirements.txt index 279cc44945..890d4191d2 100644 --- a/python_requirements.txt +++ b/python_requirements.txt @@ -181,7 +181,7 @@ tzdata==2023.3 uri-template==1.3.0 urllib3==1.26.19 verspec==0.1.0 -vtk==9.1.0 +vtk==9.3.1 watchdog==3.0.0 wcwidth==0.2.6 webcolors==1.13