diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml index 7cef0fd3..25266307 100644 --- a/.github/workflows/build-test-package.yml +++ b/.github/workflows/build-test-package.yml @@ -12,7 +12,7 @@ on: jobs: cxx-build-workflow-itk5: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.6 + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v5.4.7 cxx-build-workflow-itk6: uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@v6.0b02 @@ -21,7 +21,7 @@ jobs: itk-git-tag: '5d31af3cfdf2071d14dfc331d169111487b80597' python-build-workflow-itk5: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.6 + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@v5.4.7 with: test-notebooks: false diff --git a/CMakeLists.txt b/CMakeLists.txt index a27deba3..a4a62d69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,64 +11,37 @@ endif() option(LSTK_USE_VTK "Build visualization helper tools." OFF) if(LSTK_USE_VTK) - if(NOT COMMAND vtk_module_config) - macro(vtk_module_config ns) - foreach(arg ${ARGN}) - if(${arg} MATCHES "^[Vv][Tt][Kk]") - string(REGEX REPLACE "^[Vv][Tt][Kk]" "" _arg ${arg}) - else() - set(_arg ${arg}) - endif() - set(${ns}_LIBRARIES ${${ns}_LIBRARIES} VTK::${_arg}) - endforeach() - endmacro() - - if(NOT VTK_RENDERING_BACKEND) - set(VTK_RENDERING_BACKEND OpenGL2) - endif() - endif() - - if(NOT VTK_RENDERING_BACKEND) - if(NOT COMMAND vtk_module_config) - set(VTK_RENDERING_BACKEND OpenGL2) - else() - set(VTK_RENDERING_BACKEND OpenGL) - endif() - endif() - - set(_target_freetypeopengl) - if(TARGET ${_target_prefix}RenderingFreeType${VTK_RENDERING_BACKEND}) - set(_target_freetypeopengl ${_target_prefix}RenderingFreeType${VTK_RENDERING_BACKEND}) + find_package( + VTK 9.0 REQUIRED + COMPONENTS + CommonCore + FiltersCore + FiltersGeneral + FiltersSources + ImagingCore + InteractionImage + InteractionStyle + InteractionWidgets + IOGeometry + IOImage + IOLegacy + RenderingCore + RenderingFreeType + RenderingOpenGL2 + RenderingVolume + RenderingVolumeOpenGL2 + vtksys + ) + # ITK 6 exports one interface library per module; ITK 5.4 provides only the list variable. + if(TARGET ITK::LesionSizingToolkitModule) + set(_lstk_libraries ITK::LesionSizingToolkitModule) + elseif(TARGET LesionSizingToolkitModule) + set(_lstk_libraries LesionSizingToolkitModule) + else() + set(_lstk_libraries ${LesionSizingToolkit_LIBRARIES}) endif() - - set(_required_vtk_libraries - ${_target_prefix}RenderingVolume - #${_target_prefix}Rendering${VTK_RENDERING_BACKEND} - ${_target_prefix}IOGeometry - ${_target_prefix}IOLegacy - ${_target_prefix}IOImage - ${_target_prefix}InteractionWidgets - ${_target_prefix}InteractionImage - ) - - vtk_module_config(ITK_VTK_LSTK - ${_required_vtk_libraries} - ) - - set(ITK_VTK_LSTK_LIBRARIES ${LesionSizingToolkit_LIBRARIES} ${_required_vtk_libraries}) - - # The VTK DICOMParser and vtkmetaio includes conflict with the ITK - # versions. Here we remove them from the include directories. - # - string(REGEX REPLACE "[^;]*MetaIO;" - "" ITK_VTK_LSTK_INCLUDE_DIRS "${ITK_VTK_LSTK_INCLUDE_DIRS}") - string(REGEX REPLACE "[^;]*vtkmetaio;" - "" ITK_VTK_LSTK_INCLUDE_DIRS "${ITK_VTK_LSTK_INCLUDE_DIRS}") - string(REGEX REPLACE "[^;]*DICOMParser;" - "" ITK_VTK_LSTK_INCLUDE_DIRS "${ITK_VTK_LSTK_INCLUDE_DIRS}") - - # Add preprocessor definitions needed to use VTK. - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${ITK_VTK_LSTK_VTK_DEFINITIONS}) + set(ITK_VTK_LSTK_LIBRARIES ${_lstk_libraries} ${ITK_LIBRARIES} ${VTK_LIBRARIES}) + include_directories("${LesionSizingToolkit_SOURCE_DIR}/include") add_subdirectory(Examples) add_subdirectory(Utilities) diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 52007a9f..aa80847e 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -6,4 +6,5 @@ add_executable( LesionSegmentation LesionSegmentation.cxx itkLesionSegmentationCommandLineProgressReporter.cxx ) target_link_libraries( LesionSegmentation ${ITK_VTK_LSTK_LIBRARIES} ) +vtk_module_autoinit( TARGETS LesionSegmentation MODULES ${VTK_LIBRARIES} ) diff --git a/Examples/LesionSegmentation.cxx b/Examples/LesionSegmentation.cxx index 0cf9796f..8923925c 100644 --- a/Examples/LesionSegmentation.cxx +++ b/Examples/LesionSegmentation.cxx @@ -151,7 +151,7 @@ GetImage(std::string dir, bool ignoreDirection) catch (itk::ExceptionObject & ex) { std::cout << ex << std::endl; - return NULL; + return nullptr; } @@ -172,10 +172,10 @@ GetImage(std::string dir, bool ignoreDirection) catch (itk::ExceptionObject & ex) { std::cout << ex << std::endl; - return NULL; + return nullptr; } - return NULL; + return nullptr; } // -------------------------------------------------------------------------- diff --git a/Examples/LesionSegmentationCLI.h b/Examples/LesionSegmentationCLI.h index 4d5e9984..2c17922d 100644 --- a/Examples/LesionSegmentationCLI.h +++ b/Examples/LesionSegmentationCLI.h @@ -125,8 +125,8 @@ class LesionSegmentationCLI : public MetaCommand seeds[0]; for (int i = 0; i < 3; i++) { - this->ROI[2 * i] = seeds[0].GetPosition()[i] - this->GetValueAsFloat("MaximumRadius"); - this->ROI[2 * i + 1] = seeds[0].GetPosition()[i] + this->GetValueAsFloat("MaximumRadius"); + this->ROI[2 * i] = seeds[0].GetPositionInObjectSpace()[i] - this->GetValueAsFloat("MaximumRadius"); + this->ROI[2 * i + 1] = seeds[0].GetPositionInObjectSpace()[i] + this->GetValueAsFloat("MaximumRadius"); } } return this->ROI; @@ -252,7 +252,7 @@ class LesionSegmentationCLI : public MetaCommand exit(-1); } - seeds[i].SetPosition(sx, sy, sz); + seeds[i].SetPositionInObjectSpace(sx, sy, sz); } return seeds; } diff --git a/Examples/itkLesionSegmentationCommandLineProgressReporter.h b/Examples/itkLesionSegmentationCommandLineProgressReporter.h index 9d8465a9..86956ca0 100644 --- a/Examples/itkLesionSegmentationCommandLineProgressReporter.h +++ b/Examples/itkLesionSegmentationCommandLineProgressReporter.h @@ -17,11 +17,11 @@ *=========================================================================*/ #ifndef itkLesionSegmentationCommandLineProgressReporter_h -# define itkLesionSegmentatioCommandLineProgressReporter_h +#define itkLesionSegmentationCommandLineProgressReporter_h -# include "itkLesionSegmentationImageFilter8.h" -# include "itkCommand.h" -# include +#include "itkLesionSegmentationImageFilter8.h" +#include "itkCommand.h" +#include namespace itk { @@ -45,10 +45,10 @@ class ITKCommon_EXPORT LesionSegmentationCommandLineProgressReporter : public Co // the instance invoking the event; eid is the event id (see // vtkCommand.h); and calldata is information sent when the callback // was invoked (e.g., progress value in the vtkCommand::ProgressEvent). - virtual void - Execute(const Object * caller, const EventObject & event); - virtual void - Execute(Object * caller, const EventObject & event); + void + Execute(const Object * caller, const EventObject & event) override; + void + Execute(Object * caller, const EventObject & event) override; void SetReportProgress(int i) diff --git a/Utilities/Visualization/CMakeLists.txt b/Utilities/Visualization/CMakeLists.txt index 6aa04644..3f604e6a 100644 --- a/Utilities/Visualization/CMakeLists.txt +++ b/Utilities/Visualization/CMakeLists.txt @@ -4,16 +4,20 @@ include_directories(${Visualization_SOURCE_DIR}) add_executable(ViewImageAndSegmentationSurface ViewImageAndSegmentationSurface.cxx ) target_link_libraries(ViewImageAndSegmentationSurface ${ITK_VTK_LSTK_LIBRARIES}) +vtk_module_autoinit(TARGETS ViewImageAndSegmentationSurface MODULES ${VTK_LIBRARIES}) add_executable(ViewImageSlicesAndSegmentationContours ViewImageSlicesAndSegmentationContours.cxx vtkContourVisualizationModule.cxx ) target_link_libraries(ViewImageSlicesAndSegmentationContours ${ITK_VTK_LSTK_LIBRARIES}) +vtk_module_autoinit(TARGETS ViewImageSlicesAndSegmentationContours MODULES ${VTK_LIBRARIES}) add_executable(LesionSurfaceExtraction LesionSurfaceExtraction.cxx ) target_link_libraries(LesionSurfaceExtraction ${ITK_VTK_LSTK_LIBRARIES}) +vtk_module_autoinit(TARGETS LesionSurfaceExtraction MODULES ${VTK_LIBRARIES}) add_executable(IsoSurfaceVolumeEstimation IsoSurfaceVolumeEstimation.cxx ) target_link_libraries(IsoSurfaceVolumeEstimation ${ITK_VTK_LSTK_LIBRARIES}) +vtk_module_autoinit(TARGETS IsoSurfaceVolumeEstimation MODULES ${VTK_LIBRARIES}) diff --git a/Utilities/Visualization/LesionSurfaceExtraction.cxx b/Utilities/Visualization/LesionSurfaceExtraction.cxx index 13abbc06..07d402b5 100644 --- a/Utilities/Visualization/LesionSurfaceExtraction.cxx +++ b/Utilities/Visualization/LesionSurfaceExtraction.cxx @@ -24,6 +24,8 @@ #include "vtksys/SystemTools.hxx" #include "vtkVersion.h" +#include + #define VTK_CREATE(type, name) vtkSmartPointer name = vtkSmartPointer::New() diff --git a/Utilities/Visualization/ViewImageSlicesAndSegmentationContours.cxx b/Utilities/Visualization/ViewImageSlicesAndSegmentationContours.cxx index b764e30a..70f0a600 100644 --- a/Utilities/Visualization/ViewImageSlicesAndSegmentationContours.cxx +++ b/Utilities/Visualization/ViewImageSlicesAndSegmentationContours.cxx @@ -88,11 +88,11 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - std::cout << "Number of objects in the group:" << group->GetNumberOfObjects(1) << std::endl; + std::cout << "Number of objects in the group:" << group->GetNumberOfChildren(1) << std::endl; - using ObjectListType = SpatialObjectReaderType::GroupType::ObjectListType; + using ObjectListType = SpatialObjectReaderType::GroupType::ChildrenListType; - ObjectListType * groupChildren = group->GetObjects(999999); + ObjectListType * groupChildren = group->GetChildren(999999); ObjectListType::const_iterator spatialObjectItr = groupChildren->begin(); @@ -119,7 +119,7 @@ main(int argc, char * argv[]) const LandmarkPointListType & points = landmarkSpatialObject->GetPoints(); // Grab the first point in the list of seed points - PointType point = points[0].GetPosition(); + PointType point = points[0].GetPositionInObjectSpace(); std::cout << "Seed point = " << point << std::endl; diff --git a/include/itkFeatureAggregator.h b/include/itkFeatureAggregator.h index edaef58a..29c1e026 100644 --- a/include/itkFeatureAggregator.h +++ b/include/itkFeatureAggregator.h @@ -102,8 +102,6 @@ class ITK_TEMPLATE_EXPORT FeatureAggregator : public FeatureGenerator; diff --git a/include/itkFeatureAggregator.hxx b/include/itkFeatureAggregator.hxx index 0437f848..e8967ca5 100644 --- a/include/itkFeatureAggregator.hxx +++ b/include/itkFeatureAggregator.hxx @@ -36,9 +36,6 @@ FeatureAggregator::FeatureAggregator() typename OutputImageSpatialObjectType::Pointer outputObject = OutputImageSpatialObjectType::New(); this->ProcessObject::SetNthOutput(0, outputObject.GetPointer()); - - this->m_ProgressAccumulator = ProgressAccumulator::New(); - this->m_ProgressAccumulator->SetMiniPipelineFilter(this); } @@ -143,6 +140,9 @@ template void FeatureAggregator::UpdateAllFeatureGenerators() { + ProgressAccumulator::Pointer progress = ProgressAccumulator::New(); + progress->SetMiniPipelineFilter(this); + auto gitr = this->m_FeatureGenerators.begin(); auto gend = this->m_FeatureGenerators.end(); @@ -150,7 +150,7 @@ FeatureAggregator::UpdateAllFeatureGenerators() { // Assuming that most of the time is spent in generating the features and // hardly negligible time is spent in consolidating the features - this->m_ProgressAccumulator->RegisterInternalFilter(*gitr, 1.0 / this->m_FeatureGenerators.size()); + progress->RegisterInternalFilter(*gitr, 1.0 / this->m_FeatureGenerators.size()); (*gitr)->Update(); ++gitr; diff --git a/include/itkLesionSegmentationMethod.h b/include/itkLesionSegmentationMethod.h index d6dfa7b5..5382d06b 100644 --- a/include/itkLesionSegmentationMethod.h +++ b/include/itkLesionSegmentationMethod.h @@ -125,12 +125,10 @@ class ITK_TEMPLATE_EXPORT LesionSegmentationMethod : public ProcessObject SegmentationModulePointer m_SegmentationModule; - ProgressAccumulator::Pointer m_ProgressAccumulator; - /** This method calls the Update() method of each one of the feature generators */ void - UpdateAllFeatureGenerators(); + UpdateAllFeatureGenerators(ProgressAccumulator * progress); /** This method compares the number of available features against the number * of expected features, and it will throw an exception if they do not match. @@ -143,7 +141,7 @@ class ITK_TEMPLATE_EXPORT LesionSegmentationMethod : public ProcessObject ConnectFeaturesToSegmentationModule(); void - ExecuteSegmentationModule(); + ExecuteSegmentationModule(ProgressAccumulator * progress); }; } // end namespace itk diff --git a/include/itkLesionSegmentationMethod.hxx b/include/itkLesionSegmentationMethod.hxx index 76c85611..f31f7500 100644 --- a/include/itkLesionSegmentationMethod.hxx +++ b/include/itkLesionSegmentationMethod.hxx @@ -42,9 +42,6 @@ LesionSegmentationMethod::LesionSegmentationMethod() typename OutputSpatialObjectType::Pointer outputObject = OutputSpatialObjectType::New(); this->ProcessObject::SetNthOutput(0, outputObject.GetPointer()); - - this->m_ProgressAccumulator = ProgressAccumulator::New(); - this->m_ProgressAccumulator->SetMiniPipelineFilter(this); } @@ -105,13 +102,16 @@ LesionSegmentationMethod::GenerateData() itkExceptionMacro("Segmentation Module has not been connected"); } - this->UpdateAllFeatureGenerators(); + ProgressAccumulator::Pointer progress = ProgressAccumulator::New(); + progress->SetMiniPipelineFilter(this); + + this->UpdateAllFeatureGenerators(progress); this->VerifyNumberOfAvailableFeaturesMatchedExpectations(); this->ConnectFeaturesToSegmentationModule(); - this->ExecuteSegmentationModule(); + this->ExecuteSegmentationModule(progress); } @@ -120,14 +120,14 @@ LesionSegmentationMethod::GenerateData() */ template void -LesionSegmentationMethod::UpdateAllFeatureGenerators() +LesionSegmentationMethod::UpdateAllFeatureGenerators(ProgressAccumulator * progress) { auto gitr = this->m_FeatureGenerators.begin(); auto gend = this->m_FeatureGenerators.end(); while (gitr != gend) { - this->m_ProgressAccumulator->RegisterInternalFilter(*gitr, 0.5 / this->m_FeatureGenerators.size()); + progress->RegisterInternalFilter(*gitr, 0.5 / this->m_FeatureGenerators.size()); (*gitr)->Update(); ++gitr; } @@ -164,9 +164,9 @@ LesionSegmentationMethod::ConnectFeaturesToSegmentationModule() template void -LesionSegmentationMethod::ExecuteSegmentationModule() +LesionSegmentationMethod::ExecuteSegmentationModule(ProgressAccumulator * progress) { - this->m_ProgressAccumulator->RegisterInternalFilter(this->m_SegmentationModule, 0.5); + progress->RegisterInternalFilter(this->m_SegmentationModule, 0.5); this->m_SegmentationModule->SetInput(this->m_InitialSegmentation); this->m_SegmentationModule->Update(); }