From ba3bf1e05af2b03d6b013606b9d885d8fb0b2cb4 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 26 Jul 2017 15:50:43 +0200 Subject: [PATCH] #3109 creaMaracasVisu Bug New Normal - branch vtk7itk4 compilation with vtk7 --- .../wxWindows/widgets/vtkClosePolyData.cxx | 79 +++++++++++++++++-- .../wxWindows/widgets/vtkClosePolyData.h | 11 ++- .../wxWindows/widgets/vtkMPR3DDataViewer.cxx | 68 +++++++++++++++- .../wxWindows/widgets/vtkPlane2DView.cxx | 46 ++++++++++- 4 files changed, 192 insertions(+), 12 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx index 397295f..1ed82f0 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx @@ -42,7 +42,6 @@ =========================================================================*/ #include "vtkClosePolyData.h" -#include "vtkObjectFactory.h" #include "vtkPolyData.h" #include "vtkFeatureEdges.h" #include "vtkStripper.h" @@ -54,9 +53,12 @@ //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 -vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $"); + vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $"); #else - //... + #include "vtkDataObject.h" + #include "vtkInformation.h" + #include "vtkDemandDrivenPipeline.h" + #include "vtkInformationVector.h" #endif vtkStandardNewMacro(vtkClosePolyData); @@ -111,7 +113,7 @@ vtkClosePolyData::~vtkClosePolyData() append->AddInput( input ); append->AddInput( triangle->GetOutput()); triangle->Delete(); - + vtkInformation vtkCleanPolyData *clean = vtkCleanPolyData::New(); clean->SetInput( append->GetOutput()); append->Delete(); @@ -124,12 +126,79 @@ vtkClosePolyData::~vtkClosePolyData() } #else +/* int vtkClosePolyData::ProcessRequest( vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { -printf("EED Warning ERROR ! vtkClosePolyData::ProcessRequest not implemented VTK7 migration") +printf("EED Warning ERROR ! vtkClosePolyData::ProcessRequest not implemented VTK7 migration"); + // generate the data + if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) + { + // specify that the output (only one for this filter) will be double + vtkInformation* outInfo = outputVector->GetInformationObject(0); + outInfo->Set(vtkDataObject::SCALAR_TYPE(),VTK_DOUBLE); + return 1; + } + return this->Superclass::ProcessRequest(request,inputVector,outputVector); } +*/ + +int vtkClosePolyData::RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) +{ + + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and output + vtkPolyData *input = vtkPolyData::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData *output = vtkPolyData::SafeDownCast( outInfo->Get(vtkDataObject::DATA_OBJECT())); + + //#closing the polydata see : close.py for details + vtkFeatureEdges *boundary = vtkFeatureEdges::New(); + boundary->SetInputData( input ); + boundary->BoundaryEdgesOn (); + boundary->FeatureEdgesOff (); + boundary->NonManifoldEdgesOff (); + boundary->ManifoldEdgesOff (); + //boundary->ColoringOff (); + + vtkStripper *stripper = vtkStripper::New(); + stripper->SetInputData( boundary->GetOutput() ); + stripper->Update(); //important + boundary->Delete(); + + vtkPolyData *pd = vtkPolyData::New(); + pd->SetPoints ( stripper->GetOutput()->GetPoints() ); + pd->SetPolys ( stripper->GetOutput()->GetLines() ); + stripper->Delete(); + + //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New(); + vtkTriangleFilter *triangle = vtkTriangleFilter::New(); + triangle->SetInputData( pd ); + pd->Delete(); + + vtkAppendPolyData *append = vtkAppendPolyData::New(); + append->AddInputData( input ); + append->AddInputData( triangle->GetOutput()); + triangle->Delete(); + + vtkCleanPolyData *clean = vtkCleanPolyData::New(); + clean->SetInputData( append->GetOutput()); + append->Delete(); + + // When all optimizations are complete, this squeeze will be unecessary. + // (But it does not seem to cost much.) + clean->Update(); //important before ShallowCopy + output->ShallowCopy( clean->GetOutput() ); + clean->Delete(); + + return 1; +} + + + #endif diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.h index 059efc1..a11f8b8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.h @@ -55,6 +55,8 @@ #ifndef __vtkClosePolyData_h #define __vtkClosePolyData_h +#include "vtkObjectFactory.h" + //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 #include "vtkPolyDataToPolyDataFilter.h" @@ -77,7 +79,7 @@ public: #if VTK_MAJOR_VERSION <= 5 vtkTypeRevisionMacro(vtkClosePolyData,vtkPolyDataToPolyDataFilter); #else - vtkTypeMacro(vtkClosePolyData,vtkPolyDataToPolyDataFilter); + vtkTypeMacro(vtkClosePolyData,vtkPolyDataAlgorithm); #endif void PrintSelf(ostream& os, vtkIndent indent); @@ -91,9 +93,14 @@ protected: // Usual data generation method void Execute(); #else +/* int ProcessRequest( vtkInformation *request, vtkInformationVector **inputVector, - vtkInformationVector *outputVector); + vtkInformationVector *outputVector); +*/ +int RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector); + + #endif diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx index 242c9bd..e43df9a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx @@ -142,9 +142,16 @@ std::vector* vtkMPR3DDataViewer::GetctFunVectorBlue() //------------------------------------------------------------------- void vtkMPR3DDataViewer::SetImage() { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() ); _axialColors->SetInput( _vtkmprbasedata->GetImageData() ); _coronalColors->SetInput( _vtkmprbasedata->GetImageData() ); +#else + _saggitalColors->SetInputData( _vtkmprbasedata->GetImageData() ); + _axialColors->SetInputData( _vtkmprbasedata->GetImageData() ); + _coronalColors->SetInputData( _vtkmprbasedata->GetImageData() ); +#endif } //------------------------------------------------------------------- @@ -181,7 +188,12 @@ void vtkMPR3DDataViewer::Configure() if(_vtkmprbasedata->GetImageData()) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _vtkmprbasedata->GetImageData()->Update(); +#else + // .. +#endif _vtkmprbasedata->GetImageData()->Modified(); _vtkmprbasedata->GetImageData()->GetScalarRange(range); delta = range[1]-range[0]; @@ -269,7 +281,12 @@ void vtkMPR3DDataViewer::Configure() _saggitalColors = vtkImageMapToColors::New(); } _saggitalColors->RemoveAllInputs(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() ); +#else + _saggitalColors->SetInputData( _vtkmprbasedata->GetImageData() ); +#endif // _saggitalColors->SetLookupTable(_bwLut); @@ -279,7 +296,12 @@ void vtkMPR3DDataViewer::Configure() if(_saggital==NULL) { _saggital = vtkImageActor::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _saggital->SetInput(_saggitalColors->GetOutput()); +#else + _saggital->SetInputData(_saggitalColors->GetOutput()); +#endif } //_saggitalColors->Update(); @@ -295,14 +317,28 @@ void vtkMPR3DDataViewer::Configure() } _axialColors->RemoveAllInputs(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _axialColors->SetInput( _vtkmprbasedata->GetImageData() ); +#else + _axialColors->SetInputData( _vtkmprbasedata->GetImageData() ); +#endif + // _axialColors->SetLookupTable(_hueLut); _axialColors->SetLookupTable(_ctfun); if(_axial==NULL) { _axial = vtkImageActor::New(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _axial->SetInput(_axialColors->GetOutput()); +#else + _axial->SetInputData(_axialColors->GetOutput()); +#endif + } //_axialColors->Update(); @@ -315,15 +351,29 @@ void vtkMPR3DDataViewer::Configure() _coronalColors = vtkImageMapToColors::New(); } _coronalColors->RemoveAllInputs(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _coronalColors->SetInput( _vtkmprbasedata->GetImageData() ); +#else + _coronalColors->SetInputData( _vtkmprbasedata->GetImageData() ); +#endif + // _coronalColors->SetLookupTable(_satLut); _coronalColors->SetLookupTable(_ctfun); if(_coronal==NULL) { _coronal = vtkImageActor::New(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _coronal->SetInput(_coronalColors->GetOutput()); - } +#else + _coronal->SetInputData(_coronalColors->GetOutput()); +#endif + + } // if _coronal @@ -332,17 +382,29 @@ void vtkMPR3DDataViewer::Configure() if(_outlineData==NULL) { _outlineData = vtkOutlineFilter::New(); - } + } // if _outlineData _outlineData->RemoveAllInputs(); if(_vtkmprbasedata->GetImageData()) { +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _outlineData->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() ); - } +#else + _outlineData->SetInputData((vtkDataSet *) _vtkmprbasedata->GetImageData() ); +#endif + } // if _image if(_mapOutline==NULL) { _mapOutline = vtkPolyDataMapper::New(); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _mapOutline->SetInput(_outlineData->GetOutput()); +#else + _mapOutline->SetInputData(_outlineData->GetOutput()); +#endif + } _mapOutline->Update(); //_mapOutline->RemoveAllInputs(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx index 1016dd4..1f5ceee 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx @@ -226,17 +226,37 @@ void vtkPlane2DView::Extract_One_PlaneVTK() { vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData(); SetPSource(_sizeIma); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) ); _3Dslices -> SetSource( imagedata ); +#else + _3Dslices -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) ); + _3Dslices -> SetSourceData( imagedata ); +#endif + _3Dslices -> Update( ); _stPoints -> GetPointData( )->SetScalars( _3Dslices->GetOutput()->GetPointData()->GetScalars() ); _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 ); + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _stPoints -> SetScalarType( imagedata->GetScalarType() ); _stPoints -> SetScalarTypeToShort(); _stPoints -> Update(); // _change -> SetInput( _stPoints ); // _change -> Update(); //important _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints ); + +#else + _stPoints -> SetScalarType( imagedata->GetScalarType() ); + _stPoints -> SetScalarTypeToShort(); + _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _stPoints ); + +#endif + + // _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() ); // vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor(); } @@ -276,8 +296,14 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) for ( iWidth=0 ; iWidth SetInput( ( vtkDataSet* )_pSource->GetOutput( ) ); slice -> SetSource( imagedata ); +#else + slice -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) ); + slice -> SetSourceData( imagedata ); +#endif slice -> Update( ); slicesLST.push_back( slice ); _pSource->Push( sp ); @@ -287,11 +313,17 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) _imageResult = vtkImageData::New(); _imageResult -> SetDimensions(_sizeIma,_sizeIma,1); _imageResult -> SetSpacing(1,1,1); - _imageResult -> SetScalarType( imagedata->GetScalarType() ); _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + _imageResult -> SetScalarType( imagedata->GetScalarType() ); _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0); _imageResult -> AllocateScalars(); _imageResult -> Update(); +#else + _imageResult -> AllocateScalars(imagedata->GetScalarType(),1); +#endif + } unsigned short *pTemp; unsigned short *pResult; @@ -324,7 +356,12 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) slicesLST[iWidth]->Delete(); } _imageResult->Modified(); - _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult ); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( _imageResult ); +#else + _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _imageResult ); +#endif } //------------------------------------------------------------------- @@ -404,7 +441,12 @@ void vtkPlane2DView::HorizontalLine() lines->Delete(); //do not delete lines ?? _lineActor = vtkActor::New(); _lineMapper = vtkPolyDataMapper::New(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 _lineMapper->SetInput(_pd); +#else + _lineMapper->SetInputData(_pd); +#endif _lineMapper->ImmediateModeRenderingOn(); _lineActor->SetMapper(_lineMapper); _lineActor->GetProperty()->BackfaceCullingOn(); -- 2.45.1