Skip to content

Commit

Permalink
Upgrade to VTK 9.3.1 to fix #2308 (#2309)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
akenmorris authored Aug 14, 2024
1 parent c73a9e2 commit 3912cd7
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 37 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/build-linux-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/gha_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
65 changes: 40 additions & 25 deletions Support/vtk-9.1.patch → Support/vtk-9.3.1.patch
Original file line number Diff line number Diff line change
@@ -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<bool> IsParallel{ false };
};

+template <BackendType Backend>
+bool vtkSMPToolsImpl<Backend>::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;
Expand All @@ -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();
Expand All @@ -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();
15 changes: 12 additions & 3 deletions Testing/OptimizeTests/OptimizeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}

//---------------------------------------------------------------------------
Expand All @@ -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();
Expand All @@ -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);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -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?
Expand Down
7 changes: 3 additions & 4 deletions build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3912cd7

Please sign in to comment.