From c9c5d629768c5e7be1c12df81a94bffa7f1461fe Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Thu, 20 Jul 2017 12:05:33 +0200 Subject: [PATCH] #3106 crea Bug New Normal - branch vtk7itk4 compilation with vtk7 --- cmake/CREAMacro_FindAndUseVTK.cmake | 58 ++++++++++++++++++++--------- src/creaVtk.txx | 13 ++++++- src/creaVtkBasicSlicer.cxx | 23 ++++++++++++ 3 files changed, 75 insertions(+), 19 deletions(-) diff --git a/cmake/CREAMacro_FindAndUseVTK.cmake b/cmake/CREAMacro_FindAndUseVTK.cmake index ed93912..9ac483f 100644 --- a/cmake/CREAMacro_FindAndUseVTK.cmake +++ b/cmake/CREAMacro_FindAndUseVTK.cmake @@ -57,24 +57,48 @@ MACRO(CREA_FIND_AND_USE_VTK) CREA_DEFINE( USE_VTK ) CREA_DEFINE( _USE_VTK_ ) - SET(VTK_LIBRARIES - vtkCommon # Mandatory - vtkFiltering # vtkImageData - vtkRendering # vtkProp3D - vtkWidgets # vtkImagePlaneWidget - vtkIO # vtkMetaImageReader/Writer - vtkImaging # filters such as vtkImageAnisotropicDiffusion3D - vtkGraphics # vtkContourFilter, sources - vtkVolumeRendering # Mappers - vtkGenericFiltering - vtkHybrid -# vtkInfovis -# vtkViews + +##EED 2017-01-01 Migration VTK7 +IF("${VTK_MAJOR_VERSION}" LESS 6) + SET(VTK_LIBRARIES + vtkCommon # Mandatory + vtkFiltering # vtkImageData + vtkRendering # vtkProp3D + vtkWidgets # vtkImagePlaneWidget + vtkIO # vtkMetaImageReader/Writer + vtkImaging # filters such as vtkImageAnisotropicDiffusion3D + vtkGraphics # vtkContourFilter, sources + vtkVolumeRendering # Mappers + vtkGenericFiltering + vtkHybrid +# vtkInfovis +# vtkViews ) - IF(NOT USE_ITK) - SET(VTK_LIBRARIES ${VTK_LIBRARIES} vtkIO) - ENDIF(NOT USE_ITK) - MARK_AS_ADVANCED(VTK_DIR) + IF(NOT USE_ITK) + SET(VTK_LIBRARIES ${VTK_LIBRARIES} vtkIO) + ENDIF(NOT USE_ITK) + +ENDIF("${VTK_MAJOR_VERSION}" LESS 6) + + +##EED 2017-01-01 Migration VTK7 +IF("${VTK_MAJOR_VERSION}" GREATER 5) + SET(VTK_LIBRARIES + vtkCommonCore + vtkCommonExecutionModel + vtkIOImage + vtkRenderingCore + vtkInteractionStyle + vtkImagingCore + vtkRenderingFreeType + vtkRenderingOpenGL2 + vtkIOLegacy + vtkInteractionImage + ) +ENDIF("${VTK_MAJOR_VERSION}" GREATER 5) + + + MARK_AS_ADVANCED(VTK_DIR) ELSE(VTK_FOUND) message(FATAL_ERROR "VTK_DIR not found") ENDIF(VTK_FOUND) diff --git a/src/creaVtk.txx b/src/creaVtk.txx index b748e67..91c250b 100644 --- a/src/creaVtk.txx +++ b/src/creaVtk.txx @@ -59,13 +59,22 @@ namespace crea // Shouldn't we pass NumberOfScalarComponents to deal with RGB, RGBA images as well? // JPR - image->SetNumberOfScalarComponents(1); int vtktype = vtkTypeTraits::VTKTypeID(); - image->SetScalarType(vtktype); image->SetDimensions(nx, ny ,nz); image->SetSpacing(1, 1, 1); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) + image->SetNumberOfScalarComponents(1); + image->SetScalarType(vtktype); image->AllocateScalars(); +#endif +#if (VTK_MAJOR_VERSION >= 6) + image->AllocateScalars(vtktype,1); +#endif + + vtkDataArray* array = 0; switch (vtktype) { diff --git a/src/creaVtkBasicSlicer.cxx b/src/creaVtkBasicSlicer.cxx index c027da1..9a96116 100644 --- a/src/creaVtkBasicSlicer.cxx +++ b/src/creaVtkBasicSlicer.cxx @@ -62,7 +62,14 @@ namespace crea // An outline is shown for context. vtkOutlineFilter* outline = vtkOutlineFilter::New(); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) outline->SetInput(I); +#endif +#if (VTK_MAJOR_VERSION >= 6) + outline->SetInputData(I); +#endif vtkPolyDataMapper* outlineMapper = vtkPolyDataMapper::New(); outlineMapper->SetInputConnection(outline->GetOutputPort()); @@ -79,7 +86,15 @@ namespace crea // The 3 image plane widgets are used to probe the dataset. vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New(); planeWidgetX->DisplayTextOn(); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) planeWidgetX->SetInput(I); +#endif +#if (VTK_MAJOR_VERSION >= 6) + planeWidgetX->SetInputData(I); +#endif + planeWidgetX->SetPlaneOrientationToXAxes(); planeWidgetX->SetSlicePosition((xMax+xMin)/2.); planeWidgetX->SetPicker(picker); @@ -89,7 +104,15 @@ namespace crea vtkImagePlaneWidget* planeWidgetY = vtkImagePlaneWidget::New(); planeWidgetY->DisplayTextOn(); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) planeWidgetY->SetInput(I); +#endif +#if (VTK_MAJOR_VERSION >= 6) + planeWidgetY->SetInputData(I); +#endif + planeWidgetY->SetPlaneOrientationToYAxes(); planeWidgetY->SetSlicePosition((yMax+yMin)/2.); planeWidgetY->SetPicker(picker); -- 2.47.1