From d43c8fa374c578decfdcf355ec6dca7cb7216de8 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 7 Aug 2017 16:33:12 +0200 Subject: [PATCH] #3113 crea Rigid Registration Bug New Normal - branch vtk7itk4 compilation with vtk7 --- .../src/bbPackRecalageReSlicerBox.cxx | 15 +++++ .../src/bbPackRecalageResampleBox.cxx | 6 ++ lib/CheckBoard.cpp | 64 +++++++++++++++++- lib/Convolution.cxx | 15 +++++ lib/MyGridOnImageGenerator.cpp | 5 ++ lib/Substraction.cxx | 8 ++- lib/Surface.cxx | 10 +++ lib/Transparency.cxx | 67 ++++++++++++++++++- 8 files changed, 186 insertions(+), 4 deletions(-) diff --git a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx index 984f454..c501128 100644 --- a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx +++ b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx @@ -81,7 +81,12 @@ void ReSlicerBox::Process() if(!bbGetInputOrigin().empty() && bbGetInputTransform() != NULL) { //image = vtkImageChangeInformation::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 image->SetInput( bbGetInputIn() ); +#else + image->SetInputData( bbGetInputIn() ); +#endif image->SetOutputSpacing( 1,1,1 ); if(bbGetInputCentered()) @@ -97,7 +102,12 @@ void ReSlicerBox::Process() GetBackInfo(backInfoA,bbGetInputTransform()->GetMatrix(),bbGetInputOrigin() ); //slicer =vtkImageReslice::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 slicer->SetInput( image->GetOutput() ); +#else + slicer->SetInputData( image->GetOutput() ); +#endif slicer->SetInformationInput( image->GetOutput() ); slicer->SetResliceTransform(bbGetInputTransform()); slicer->SetOutputOrigin( -(bbGetInputOrigin()[0]) , -(bbGetInputOrigin()[1]) , -(bbGetInputOrigin()[2]) ); @@ -109,7 +119,12 @@ void ReSlicerBox::Process() slicer->Update(); //imageResult = vtkImageChangeInformation::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imageResult->SetInput( slicer->GetOutput() ); +#else + imageResult->SetInputData( slicer->GetOutput() ); +#endif double spc[3]; bbGetInputIn()->GetSpacing(spc); imageResult->SetOutputSpacing( spc ); diff --git a/PackRecalage/src/bbPackRecalageResampleBox.cxx b/PackRecalage/src/bbPackRecalageResampleBox.cxx index d4d4f78..2dd3126 100644 --- a/PackRecalage/src/bbPackRecalageResampleBox.cxx +++ b/PackRecalage/src/bbPackRecalageResampleBox.cxx @@ -36,7 +36,13 @@ void ResampleBox::Process() if(bbGetInputIn() != NULL && bbGetInputFactor() != 0) { double factor = bbGetInputFactor(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 resample->SetInput(bbGetInputIn()); +#else + resample->SetInputData(bbGetInputIn()); +#endif + resample->SetAxisMagnificationFactor(0, factor); resample->SetAxisMagnificationFactor(1, factor); resample->SetAxisMagnificationFactor(2, factor); diff --git a/lib/CheckBoard.cpp b/lib/CheckBoard.cpp index f47c94c..08fa729 100644 --- a/lib/CheckBoard.cpp +++ b/lib/CheckBoard.cpp @@ -104,31 +104,64 @@ void CheckBoard::calculateImage() result = vtkImageData::New(); if(numPixelsImg1SetInput(image1); +#else + resample->SetInputData(image1); +#endif factorX = (double)extImg2[1]/extImg1[1]; factorY = (double)extImg2[3]/extImg1[3]; resample->SetAxisMagnificationFactor(0,factorX); resample->SetAxisMagnificationFactor(1,factorY); resample->SetInformationInput(image2); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + resample->Update(); +#else + // .. +#endif initialize(dimImg2, spcImg2); result = resample->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 result->Update(); +#else + // .. +#endif + createImage(result,image2,dimImg2[0],dimImg2[1]); } //if else if (numPixelsImg1>numPixelsImg2) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 resample->SetInput(image2); +#else + resample->SetInputData(image2); +#endif factorX = (double)extImg1[1]/extImg2[1]; factorY = (double)extImg1[3]/extImg2[3]; resample->SetAxisMagnificationFactor(0,factorX); resample->SetAxisMagnificationFactor(1,factorY); resample->SetInformationInput(image1); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // .. +#else + resample->Update(); +#endif initialize(dimImg1, spcImg1); result = resample->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 result->Update(); +#else + // .. +#endif createImage(image1,result,dimImg1[0],dimImg1[1]); } // else if @@ -136,17 +169,33 @@ void CheckBoard::calculateImage() { //If both images have the same number of pixels, the resultant image will have the //properties of the first image. +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 resample->SetInput(image2); +#else + resample->SetInputData(image2); +#endif factorX = (double)extImg1[1]/extImg2[1]; factorY = (double)extImg1[3]/extImg2[3]; resample->SetAxisMagnificationFactor(0,factorX); resample->SetAxisMagnificationFactor(1,factorY); resample->SetInformationInput(image1); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // .. +#else + resample->Update(); +#endif initialize(dimImg1, spcImg1); result = resample->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 result->Update(); +#else + //... +#endif createImage(image1,result,dimImg1[0],dimImg1[1]); @@ -165,11 +214,18 @@ void CheckBoard::initialize(int dimensions[], double spacing[]) newImage->Delete(); } newImage = vtkImageData::New(); - newImage->SetScalarType(type); newImage->SetSpacing(spacing); newImage->SetDimensions(dimensions); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + newImage->SetScalarType(type); newImage->AllocateScalars(); newImage->Update(); +#else + newImage->AllocateScalars(type,1); +#endif + } //------------------------------------------------------------ @@ -279,7 +335,13 @@ void CheckBoard::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX, } //std::cout << "The image has been checkboardized!" << std::endl; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 newImage->Update(); +#else + newImage->Modified(); +#endif + // newImage->Modified(); } /**Template used for the different image types diff --git a/lib/Convolution.cxx b/lib/Convolution.cxx index adddb96..796a059 100644 --- a/lib/Convolution.cxx +++ b/lib/Convolution.cxx @@ -55,7 +55,12 @@ vtkImageData *Convolution::getImage() void Convolution::setImage(vtkImageData *image) { _image = image; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _convolve->SetInput(_image); +#else + _convolve->SetInputData(_image); +#endif } void Convolution::setFactor(double factor) @@ -75,13 +80,23 @@ void Convolution::Run() double kernel[] = {0.0,1.0,0.0,1.0,-_factor,1.0,0.0,1.0,0.0}; _convolve->SetKernel3x3(kernel); _convolve->Update(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _cast->SetInput(_convolve->GetOutput()); +#else + _cast->SetInputData(_convolve->GetOutput()); +#endif //_cast->SetOutputScalarTypeToDouble(); _cast->Update(); } else { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _cast->SetInput(_image); +#else + _cast->SetInputData(_image); +#endif _cast->SetOutputScalarType(_image->GetScalarType()); _cast->Update(); } diff --git a/lib/MyGridOnImageGenerator.cpp b/lib/MyGridOnImageGenerator.cpp index 91e5ff4..b997d0e 100755 --- a/lib/MyGridOnImageGenerator.cpp +++ b/lib/MyGridOnImageGenerator.cpp @@ -91,7 +91,12 @@ vtkImageData* MyGridOnImageGenerator::getGridOnImage( ) vtkImageData* gridImage = vtkImageData::New(); gridImage->ShallowCopy(image); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 gridImage->Update(); +#else + gridImage->Modified(); +#endif //Get image spacing, size and mix and max values gridImage->GetSpacing(spc); diff --git a/lib/Substraction.cxx b/lib/Substraction.cxx index b6f5069..734a06c 100644 --- a/lib/Substraction.cxx +++ b/lib/Substraction.cxx @@ -120,11 +120,17 @@ void Substraction::substractImage(vtkImageData* imageData1, vtkImageData* imageD void Substraction::initialize(int dimensions[], double spacing[]) { //setting image data of the imageResult - imageResult->SetScalarType(imageType); imageResult->SetSpacing(spacing); imageResult->SetDimensions(dimensions); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + imageResult->SetScalarType(imageType); imageResult->AllocateScalars(); imageResult->Update(); +#else + imageResult->AllocateScalars(imageType,1); +#endif + } /* diff --git a/lib/Surface.cxx b/lib/Surface.cxx index 0933cfd..5f4f710 100644 --- a/lib/Surface.cxx +++ b/lib/Surface.cxx @@ -206,10 +206,20 @@ void Surface::surface(vtkImageData* imageData) vtkPolyData* surfaceData = vtkPolyData::New(); surfaceData->SetPolys(surfaceCells); surfaceData->SetPoints(surfacePoints); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 surfaceData->Update(); +#else + // .. +#endif vtkPolyDataMapper* surfaceMapper = vtkPolyDataMapper::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 surfaceMapper->SetInput(surfaceData); +#else + surfaceMapper->SetInputData(surfaceData); +#endif surfaceMapper->Update(); surfaceResult->SetMapper(surfaceMapper); diff --git a/lib/Transparency.cxx b/lib/Transparency.cxx index 15d46fe..8749685 100644 --- a/lib/Transparency.cxx +++ b/lib/Transparency.cxx @@ -88,7 +88,12 @@ void Transparency::calculateImage() vtkImageData *result; if(numPixelsImg1SetInput(_image1); +#else + resample->SetInputData(_image1); +#endif factorX = (double)extImg2[1]/extImg1[1]; factorY = (double)extImg2[3]/extImg1[3]; resample->SetAxisMagnificationFactor(0,factorX); @@ -96,14 +101,31 @@ void Transparency::calculateImage() resample->SetInformationInput(_image2); initialize(dimImg2, spcImg2); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + //.. +#else + resample->Update(); +#endif + result = resample->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 result->Update(); +#else + //... +#endif createImage(result,_image2,dimImg2[0],dimImg2[1]); } //if else if (numPixelsImg1>numPixelsImg2) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 resample->SetInput(_image2); +#else + resample->SetInputData(_image2); +#endif factorX = (double)extImg1[1]/extImg2[1]; factorY = (double)extImg1[3]/extImg2[3]; resample->SetAxisMagnificationFactor(0,factorX); @@ -111,9 +133,21 @@ void Transparency::calculateImage() resample->SetInformationInput(_image1); initialize(dimImg1, spcImg1); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // ... +#else + resample->Update(); +#endif result = resample->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 result->Update(); +#else + result->Modified(); +#endif createImage(_image1,result,dimImg1[0],dimImg1[1]); } // else if @@ -121,17 +155,33 @@ void Transparency::calculateImage() { //If both images have the same number of pixels, the resultant image will have the //properties of the first image. +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 resample->SetInput(_image2); +#else + resample->SetInputData(_image2); +#endif factorX = (double)extImg1[1]/extImg2[1]; factorY = (double)extImg1[3]/extImg2[3]; resample->SetAxisMagnificationFactor(0,factorX); resample->SetAxisMagnificationFactor(1,factorY); resample->SetInformationInput(_image1); - initialize(dimImg1, spcImg1); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // ... +#else + resample->Update(); +#endif result = resample->GetOutput(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 result->Update(); +#else + result->Modified(); +#endif createImage(_image1,result,dimImg1[0],dimImg1[1]); @@ -146,11 +196,17 @@ void Transparency::initialize(int dimensions[], double spacing[]) { // Setting the new image _newImage = vtkImageData::New(); - _newImage->SetScalarType(_type); _newImage->SetSpacing(spacing); _newImage->SetDimensions(dimensions); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + _newImage->SetScalarType(_type); _newImage->AllocateScalars(); _newImage->Update(); +#else + _newImage->AllocateScalars(_type,1); +#endif + } @@ -258,7 +314,14 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _newImage->Update(); +#else + _newImage->Modified(); +#endif + + } template -- 2.45.0