Skip to content

Commit

Permalink
ENH: Configure examples that utilize VTK
Browse files Browse the repository at this point in the history
Many of the examples that utilize VTK were not configured correctly or
needed to be updated to accomodate VTK 9.1.0.

This primarily included, finding the VTK package and only using the
components that specific example needed. If the VTK version is less than
8.9, then the VTK_USE_FILE is included. Finally, the VTK_LIBRARIES are
linked and if the VTK version is atleast 8.9, then the module is
inialized using VTK's vtk_module_autoinit().
  • Loading branch information
mseng10 committed Feb 23, 2021
1 parent f30851e commit f079817
Show file tree
Hide file tree
Showing 20 changed files with 298 additions and 45 deletions.
17 changes: 14 additions & 3 deletions src/Bridge/VtkGlue/ConvertvtkImageDataToAnitkImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@ find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

# Since we use vtkImageMagnitude
find_package(VTK REQUIRED COMPONENTS vtkImagingMath)
include(${VTK_USE_FILE})

find_package(VTK REQUIRED
COMPONENTS
ImagingMath
)
if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(ConvertvtkImageDataToAnitkImage Code.cxx)
target_link_libraries(ConvertvtkImageDataToAnitkImage
${ITK_LIBRARIES}
${VTK_LIBRARIES}
)

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS ConvertvtkImageDataToAnitkImage
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS ConvertvtkImageDataToAnitkImage
DESTINATION bin/ITKExamples/Bridge/VtkGlue
COMPONENT Runtime
Expand Down
19 changes: 17 additions & 2 deletions src/Bridge/VtkGlue/VTKImageToITKImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@ project(VTKImageToITKImage)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
find_package(VTK REQUIRED
COMPONENTS
vtkImagingColor
vtkIOImage
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(VTKImageToITKImage Code.cxx)
target_link_libraries(VTKImageToITKImage ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS VTKImageToITKImage
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS VTKImageToITKImage
DESTINATION bin/ITKExamples/Bridge/VtkGlue
COMPONENT Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,25 @@ project( VisualizeStaticDense2DLevelSetAsElevationMap )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
find_package( VTK REQUIRED
COMPONENTS
vtkInteractionImage
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if( VTK_VERSION VERSION_LESS "8.90.0" )
include( ${VTK_USE_FILE} )
endif()

add_executable( VisualizeStaticDense2DLevelSetAsElevationMap Code.cxx )
target_link_libraries( VisualizeStaticDense2DLevelSetAsElevationMap ${ITK_LIBRARIES} ${VTK_LIBRARIES})

add_executable( VisualizeStaticDense2DLevelSetAsElevationMap Code.cxx)
target_link_libraries( VisualizeStaticDense2DLevelSetAsElevationMap ${ITK_LIBRARIES} )
if( NOT VTK_VERSION VERSION_LESS "8.90.0" )
vtk_module_autoinit(
TARGETS VisualizeStaticDense2DLevelSetAsElevationMap
MODULES ${VTK_LIBRARIES}
)
endif()

install( TARGETS VisualizeStaticDense2DLevelSetAsElevationMap
DESTINATION bin/ITKExamples/Bridge/VtkGlue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ project( VisualizeStaticDense2DLevelSetZeroSet )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
find_package( VTK REQUIRED
COMPONENTS
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if( VTK_VERSION VERSION_LESS "8.90.0" )
include( ${VTK_USE_FILE} )
endif()

add_executable( VisualizeStaticDense2DLevelSetZeroSet Code.cxx )
target_link_libraries( VisualizeStaticDense2DLevelSetZeroSet ${ITK_LIBRARIES} ${VTK_LIBRARIES} )

add_executable( VisualizeStaticDense2DLevelSetZeroSet Code.cxx)
target_link_libraries( VisualizeStaticDense2DLevelSetZeroSet ${ITK_LIBRARIES} )
if( NOT VTK_VERSION VERSION_LESS "8.90.0" )
vtk_module_autoinit(
TARGETS VisualizeStaticDense2DLevelSetZeroSet
MODULES ${VTK_LIBRARIES}
)
endif()

install( TARGETS VisualizeStaticDense2DLevelSetZeroSet
DESTINATION bin/ITKExamples/Bridge/VtkGlue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ project( VisualizeStaticMalcolm2DLevelSetLayers )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
find_package( VTK REQUIRED
COMPONENTS
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if( VTK_VERSION VERSION_LESS "8.90.0" )
include( ${VTK_USE_FILE} )
endif()

add_executable( VisualizeStaticMalcolm2DLevelSetLayers Code.cxx )
target_link_libraries( VisualizeStaticMalcolm2DLevelSetLayers ${ITK_LIBRARIES} ${VTK_LIBRARIES} )

add_executable( VisualizeStaticMalcolm2DLevelSetLayers Code.cxx)
target_link_libraries( VisualizeStaticMalcolm2DLevelSetLayers ${ITK_LIBRARIES} )
if( NOT VTK_VERSION VERSION_LESS "8.90.0" )
vtk_module_autoinit(
TARGETS WatchRegistration
MODULES ${VTK_LIBRARIES}
)
endif()

install( TARGETS VisualizeStaticMalcolm2DLevelSetLayers
DESTINATION bin/ITKExamples/Bridge/VtkGlue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ project( VisualizeStaticShi2DLevelSetLayers )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
find_package( VTK REQUIRED
COMPONENTS
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if( VTK_VERSION VERSION_LESS "8.90.0" )
include( ${VTK_USE_FILE} )
endif()

add_executable( VisualizeStaticShi2DLevelSetLayers Code.cxx )
target_link_libraries( VisualizeStaticShi2DLevelSetLayers ${ITK_LIBRARIES} ${VTK_LIBRARIES} )

add_executable( VisualizeStaticShi2DLevelSetLayers Code.cxx)
target_link_libraries( VisualizeStaticShi2DLevelSetLayers ${ITK_LIBRARIES} )
if( NOT VTK_VERSION VERSION_LESS "8.90.0" )
vtk_module_autoinit(
TARGETS VisualizeStaticShi2DLevelSetLayers
MODULES ${VTK_LIBRARIES}
)
endif()

install( TARGETS VisualizeStaticShi2DLevelSetLayers
DESTINATION bin/ITKExamples/Bridge/VtkGlue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ project( VisualizeStaticWhitaker2DLevelSetLayers )
find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )

find_package( VTK REQUIRED )
include( ${VTK_USE_FILE} )
find_package( VTK REQUIRED
COMPONENTS
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if( VTK_VERSION VERSION_LESS "8.90.0" )
include( ${VTK_USE_FILE} )
endif()

add_executable( VisualizeStaticWhitaker2DLevelSetLayers Code.cxx )
target_link_libraries( VisualizeStaticWhitaker2DLevelSetLayers ${ITK_LIBRARIES} ${VTK_LIBRARIES} )

add_executable( VisualizeStaticWhitaker2DLevelSetLayers Code.cxx)
target_link_libraries( VisualizeStaticWhitaker2DLevelSetLayers ${ITK_LIBRARIES} )
if( NOT VTK_VERSION VERSION_LESS "8.90.0" )
vtk_module_autoinit(
TARGETS VisualizeStaticWhitaker2DLevelSetLayers
MODULES ${VTK_LIBRARIES}
)
endif()

install( TARGETS VisualizeStaticWhitaker2DLevelSetLayers
DESTINATION bin/ITKExamples/Bridge/VtkGlue
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(ENABLE_QUICKVIEW OFF)

if(Module_ITKVtkGlue OR ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
include_directories(${VTK_INCLUDE_DIRS})
set(ENABLE_QUICKVIEW ON)
add_definitions(-DENABLE_QUICKVIEW)
endif()
Expand Down
18 changes: 17 additions & 1 deletion src/Core/Common/FindMaxAndMinInImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ project(FindMaxAndMinInImage)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED
COMPONENTS
vtkInteractionImage
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(FindMaxAndMinInImage Code.cxx)
target_link_libraries(FindMaxAndMinInImage ${ITK_LIBRARIES})
target_link_libraries(FindMaxAndMinInImage ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS FindMaxAndMinInImage
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS FindMaxAndMinInImage
DESTINATION bin/ITKExamples/Core/Common
Expand Down
18 changes: 17 additions & 1 deletion src/Core/Common/InPlaceFilterOfImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ project(InPlaceFilterOfImage)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED
COMPONENTS
vtkInteractionImage
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(InPlaceFilterOfImage Code.cxx)
target_link_libraries(InPlaceFilterOfImage ${ITK_LIBRARIES})
target_link_libraries(InPlaceFilterOfImage ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS InPlaceFilterOfImage
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS InPlaceFilterOfImage
DESTINATION bin/ITKExamples/Core/Common
Expand Down
18 changes: 17 additions & 1 deletion src/Core/Common/IterateRegionWithNeighborhood/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ project(IterateRegionWithNeighborhood)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED
COMPONENTS
vtkInteractionImage
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)
if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(IterateRegionWithNeighborhood Code.cxx)
target_link_libraries(IterateRegionWithNeighborhood ${ITK_LIBRARIES})
target_link_libraries(IterateRegionWithNeighborhood ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS IterateRegionWithNeighborhood
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS IterateRegionWithNeighborhood
DESTINATION bin/ITKExamples/Core/Common
Expand Down
19 changes: 18 additions & 1 deletion src/Core/Common/IterateRegionWithWriteAccess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@ project(IterateRegionWithWriteAccess)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED
COMPONENTS
vtkInteractionImage
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)

if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(IterateRegionWithWriteAccess Code.cxx)
target_link_libraries(IterateRegionWithWriteAccess ${ITK_LIBRARIES})
target_link_libraries(IterateRegionWithWriteAccess ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS IterateRegionWithWriteAccess
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS IterateRegionWithWriteAccess
DESTINATION bin/ITKExamples/Core/Common
Expand Down
20 changes: 19 additions & 1 deletion src/Core/Common/OutOfBoundsPixelsReturnConstValue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@ project(OutOfBoundsPixelsReturnConstValue)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED
COMPONENTS
vtkInteractionImage
vtkInteractionStyle
vtkRenderingCore
vtkRenderingGL2PSOpenGL2
)

if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(OutOfBoundsPixelsReturnConstValue Code.cxx)
target_link_libraries(OutOfBoundsPixelsReturnConstValue ${ITK_LIBRARIES})
target_link_libraries(OutOfBoundsPixelsReturnConstValue ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS OutOfBoundsPixelsReturnConstValue
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS OutOfBoundsPixelsReturnConstValue
DESTINATION bin/ITKExamples/Core/Common
Expand Down
18 changes: 16 additions & 2 deletions src/Core/Mesh/ConvertMeshToUnstructeredGrid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,26 @@ project(ConvertMeshToUnstructeredGrid)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
find_package(VTK REQUIRED
COMPONENTS
vtkIOXML
vtkCommonDataModel
vtkInteractionImage
)
if(VTK_VERSION VERSION_LESS "8.90.0")
include(${VTK_USE_FILE})
endif()

add_executable(ConvertMeshToUnstructeredGrid Code.cxx)
target_link_libraries(ConvertMeshToUnstructeredGrid ${ITK_LIBRARIES} ${VTK_LIBRARIES})

if(NOT VTK_VERSION VERSION_LESS "8.90.0")
vtk_module_autoinit(
TARGETS WatchRegistration
MODULES ${VTK_LIBRARIES}
)
endif()

install(TARGETS ConvertMeshToUnstructeredGrid
DESTINATION bin/ITKExamples/Core/Mesh
COMPONENT Runtime
Expand Down
Loading

0 comments on commit f079817

Please sign in to comment.