From 2995826ee50f882a609e7350780ffc7bea0e7db2 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 4 Aug 2017 16:58:22 +0200 Subject: [PATCH] #3112 creaContours Bug New Normal - branch vtk7itk4 compilation with vtk7 --- .../wxContourMainFrame.cxx | 104 +++++++++++++++++- .../KernelManagerContour.cxx | 8 ++ .../itkVTKImageToImageFilter.txx | 5 + 3 files changed, 115 insertions(+), 2 deletions(-) diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 3d4413b..39e3ac1 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -1682,33 +1682,63 @@ printf("EED wxContourMainFrame::SegmentationOneSliceITK Skypping this code. No vtkMarchingContourFilter* cntVTK = vtkMarchingContourFilter::New( ); - cntVTK->SetInput( idata ); - cntVTK->SetNumberOfContours( 1 ); cntVTK->SetValue( 0, 255 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + cntVTK->SetInput( idata ); cntVTK->Update( ); cntVTK->UpdateInformation(); +#else + cntVTK->SetInputData( idata ); +#endif vtkCleanPolyData* cpd = vtkCleanPolyData::New( ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cpd->SetInput( cntVTK->GetOutput( ) ); cpd->Update( ); cpd->UpdateInformation(); +#else + cpd->SetInputData( cntVTK->GetOutput( ) ); +#endif + vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( ); conn->SetExtractionModeToLargestRegion( ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 conn->SetInput( cpd->GetOutput( ) ); conn->Update( ); conn->UpdateInformation(); +#else + conn->SetInputData( cpd->GetOutput( ) ); +#endif + vtkStripper* vtkstripper = vtkStripper::New( ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 vtkstripper->SetInput( conn->GetOutput() ); vtkstripper->Update(); vtkstripper->UpdateInformation(); +#else + vtkstripper->SetInputData( conn->GetOutput() ); + cntVTK->Update(); +#endif vtkPolyData* polyDataResult = cntVTK->GetOutput(); //std::cout<<"Points "<GetNumberOfPoints()<Update( ); polyDataResult->UpdateInformation(); +#else + // .. +#endif //EED /* @@ -1969,19 +1999,41 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue // y = y*spc[1]; // z = z*spc[3]; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imageReslice->SetInput( imagedata ); +#else + imageReslice->SetInputData( imagedata ); +#endif imageReslice->SetInformationInput(imagedata); imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); imageReslice->SetResliceAxesOrigin(0,0,z); imageReslice->SetOutputDimensionality(2); imageReslice->SetInterpolationModeToLinear(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // .. +#else + imageReslice->Update(); +#endif + imagedata = imageReslice->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imagedata->Update(); imagedata->UpdateInformation(); +#else + // .. +#endif vtkContourFilter* cntVTK = vtkContourFilter::New( ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cntVTK->SetInput( imagedata ); +#else + cntVTK->SetInputData( imagedata ); +#endif cntVTK->SetNumberOfContours( 1 ); //cntVTK->SetValue( 0, vmin ); @@ -1992,7 +2044,12 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue cntVTK->UpdateInformation(); vtkCleanPolyData* cpd = vtkCleanPolyData::New( ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cpd->SetInput( cntVTK->GetOutput( ) ); +#else + cpd->SetInputData( cntVTK->GetOutput( ) ); +#endif cpd->ConvertLinesToPointsOff( ); cpd->Update( ); cpd->UpdateInformation(); @@ -2001,27 +2058,47 @@ void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue conn->SetExtractionModeToClosestPointRegion( ); //conn->SetMaxRecursionDepth( 3000 ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 conn->SetInput( cpd->GetOutput( ) ); +#else + conn->SetInputData( cpd->GetOutput( ) ); +#endif conn->SetClosestPoint( x, y, 0 ); conn->Update( ); conn->UpdateInformation(); vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 cpd2->SetInput( conn->GetOutput( ) ); +#else + cpd2->SetInputData( conn->GetOutput( ) ); +#endif cpd2->Update(); cpd2->UpdateInformation(); vtkStripper* vtkstripper = vtkStripper::New( ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 vtkstripper->SetInput( cpd2->GetOutput() ); +#else + vtkstripper->SetInputData( cpd2->GetOutput() ); +#endif vtkstripper->Update(); vtkstripper->UpdateInformation(); vtkPolyData* polyDataResult = vtkstripper->GetOutput(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 polyDataResult->Update( ); polyDataResult->UpdateInformation(); +#else + //... +#endif /* EED ofstream myfile; @@ -3065,10 +3142,21 @@ void wxContourMainFrame::SaveImageResult(std::string directory,std::string namef // Image Value vtkImageChangeInformation *valueChInfo = vtkImageChangeInformation::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 valueChInfo->SetInput(value); +#else + valueChInfo->SetInputData(value); +#endif valueChInfo->SetSpacingScale(spc); vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 writerValueImage->SetInput( valueChInfo->GetOutput() ); +#else + writerValueImage->SetInputData( valueChInfo->GetOutput() ); +#endif writerValueImage->SetFileName( (const char *)filename.mb_str() ); writerValueImage->SetFileDimensionality( 3 ); writerValueImage->SetCompression(false); @@ -3083,10 +3171,22 @@ void wxContourMainFrame::SaveImageResult(std::string directory,std::string namef vtkImageChangeInformation *maskChInfo = vtkImageChangeInformation::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 maskChInfo->SetInput(mask); +#else + maskChInfo->SetInputData(mask); +#endif maskChInfo->SetSpacingScale(spc); vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 writerMaskImage->SetInput( maskChInfo->GetOutput() ); +#else + writerMaskImage->SetInputData( maskChInfo->GetOutput() ); +#endif + writerMaskImage->SetFileName( (const char *)filename.mb_str() ); writerMaskImage->SetFileDimensionality( 3 ); writerMaskImage->SetCompression(false); diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx index 3f4a144..633d438 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx @@ -112,8 +112,16 @@ void KernelManagerContour::setVectImages(std::vector vectimg) for(int i = 0; i < (int)(vectimg.size()); i++){ vtkImageData* img = vectimg[i]; vtkImageChangeInformation* change = vtkImageChangeInformation::New(); + + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 change->SetInformationInput(img); change->SetInputConnection(img->GetProducerPort()); +#else + change->SetInputData(img); +#endif + img->GetSpacing(spc); change->SetOutputSpacing(1,1,1); diff --git a/lib/kernel_ManagerContour_NDimensions/itkVTKImageToImageFilter.txx b/lib/kernel_ManagerContour_NDimensions/itkVTKImageToImageFilter.txx index 585878b..edfb3f4 100644 --- a/lib/kernel_ManagerContour_NDimensions/itkVTKImageToImageFilter.txx +++ b/lib/kernel_ManagerContour_NDimensions/itkVTKImageToImageFilter.txx @@ -103,7 +103,12 @@ void VTKImageToImageFilter ::SetInput( vtkImageData * inputImage ) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 m_Exporter->SetInput( inputImage ); +#else + m_Exporter->SetInputData( inputImage ); +#endif } -- 2.45.1