X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkImagePlanes.cxx;h=9f6bc7d20c36e4fce83d2c320fcfe4eaca8c1fdb;hb=fc44a74636803d2efca46c6e66562a839e9d52f1;hp=92476f5e19b8a01a00719c3c671d8a3063169404;hpb=cfad95b6e08e6e53846ffcda7fbc5932065f2c47;p=bbtk.git diff --git a/packages/vtk/src/bbvtkImagePlanes.cxx b/packages/vtk/src/bbvtkImagePlanes.cxx index 92476f5..9f6bc7d 100644 --- a/packages/vtk/src/bbvtkImagePlanes.cxx +++ b/packages/vtk/src/bbvtkImagePlanes.cxx @@ -153,13 +153,13 @@ namespace bbvtk void ImagePlanes::bbUserSetDefaultValues() { - bbSetOutputPlaneX(0); - bbSetOutputPlaneY(0); - bbSetOutputPlaneZ(0); - bbSetOutputImageX(0); - bbSetOutputImageY(0); - bbSetOutputImageZ(0); - bbSetInputIn(0); + bbSetOutputPlaneX(NULL); + bbSetOutputPlaneY(NULL); + bbSetOutputPlaneZ(NULL); + bbSetOutputImageX(NULL); + bbSetOutputImageY(NULL); + bbSetOutputImageZ(NULL); + bbSetInputIn(NULL); std::vector vect; vect.push_back(0); vect.push_back(0); @@ -207,24 +207,56 @@ namespace bbvtk // EED MPR view orientation correction.. vtkImageFlip *flipYFilter = vtkImageFlip::New(); flipYFilter->SetFilteredAxis(1); // flip y axis + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) flipYFilter->SetInput( planeWidgetX->GetResliceOutput() ); +#endif +#if (VTK_MAJOR_VERSION >= 6) + flipYFilter->SetInputData( planeWidgetX->GetResliceOutput() ); +#endif + flipYFilter->Update(); vtkImageChangeInformation *image = vtkImageChangeInformation::New(); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) image->SetInput( planeWidgetY->GetResliceOutput() ); +#endif +#if (VTK_MAJOR_VERSION >= 6) + image->SetInputData( planeWidgetY->GetResliceOutput() ); +#endif + image->SetOutputSpacing( 1,1,1 ); image->CenterImageOn(); image->Update(); _imageTransform = vtkTransform::New(); vtkImageReslice *slicer =vtkImageReslice::New(); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) slicer->SetInput( image->GetOutput() ); +#endif +#if (VTK_MAJOR_VERSION >= 6) + slicer->SetInputData( image->GetOutput() ); +#endif + slicer->SetInformationInput( image->GetOutput() ); slicer->SetResliceTransform( _imageTransform ); slicer->SetOutputOrigin(0 , 0 , 0 ); slicer->SetInterpolationModeToNearestNeighbor(); slicer->Update(); vtkImageChangeInformation *imageResult = vtkImageChangeInformation::New(); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) imageResult->SetInput( slicer->GetOutput() ); +#endif +#if (VTK_MAJOR_VERSION >= 6) + imageResult->SetInputData( slicer->GetOutput() ); +#endif + double spc[3]; planeWidgetY->GetResliceOutput()->GetSpacing(spc); imageResult->SetOutputSpacing( spc[1], spc[0], spc[2] ); @@ -242,8 +274,10 @@ namespace bbvtk //bbSetOutputImage3Pts(planeWidget3Pts->GetResliceOutput()); if(picker != 0) + { picker->UnRegister(NULL); - + } + mVtkCallback = VtkCallbackType::New(); mVtkCallback->SetBlackBox(this); planeWidgetX->AddObserver(vtkCommand::InteractionEvent,mVtkCallback); @@ -284,7 +318,14 @@ namespace bbvtk { int dim[3]; int ext[6]; +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) bbGetOutputPlaneX()->GetResliceOutput()->GetWholeExtent(ext); +#endif +#if (VTK_MAJOR_VERSION >= 6) + bbGetOutputPlaneX()->GetResliceOutput()->GetExtent(ext); +#endif + dim[0] = ext[1]-ext[0]+1; dim[1] = ext[3]-ext[2]+1; dim[2] = ext[5]-ext[4]+1; @@ -304,7 +345,14 @@ namespace bbvtk double xSpacing, ySpacing, zSpacing; bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing); +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) bbGetOutputPlaneX()->SetInput(bbGetInputIn()); +#endif +#if (VTK_MAJOR_VERSION >= 6) + bbGetOutputPlaneX()->SetInputData(bbGetInputIn()); +#endif + bbGetOutputPlaneX()->SetPlaneOrientationToXAxes(); bbGetOutputPlaneX()->SetSlicePosition((xMax+xMin)/2.*xSpacing); @@ -312,11 +360,25 @@ namespace bbvtk // bbGetOutputPlaneX()->SetPoint1( 0*xSpacing, 146*ySpacing, 186*zSpacing); // bbGetOutputPlaneX()->SetPoint2( 126*xSpacing, 146*ySpacing, 0*zSpacing); +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) bbGetOutputPlaneY()->SetInput(bbGetInputIn()); +#endif +#if (VTK_MAJOR_VERSION >= 6) + bbGetOutputPlaneY()->SetInputData(bbGetInputIn()); +#endif + bbGetOutputPlaneY()->SetPlaneOrientationToYAxes(); bbGetOutputPlaneY()->SetSlicePosition((yMax+yMin)/2.*ySpacing); +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) bbGetOutputPlaneZ()->SetInput(bbGetInputIn()); +#endif +#if (VTK_MAJOR_VERSION >= 6) + bbGetOutputPlaneZ()->SetInputData(bbGetInputIn()); +#endif + bbGetOutputPlaneZ()->SetPlaneOrientationToZAxes(); bbGetOutputPlaneZ()->SetSlicePosition((zMax+zMin)/2.*zSpacing); @@ -347,9 +409,15 @@ namespace bbvtk bbGetOutputPlaneZ()->SetResliceInterpolate( bbGetInputInterpolation() ); +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) bbGetOutputPlaneX()->GetResliceOutput()->Update(); bbGetOutputPlaneY()->GetResliceOutput()->Update(); bbGetOutputPlaneZ()->GetResliceOutput()->Update(); +#endif +#if (VTK_MAJOR_VERSION >= 6) + // ... +#endif std::vector pointsx = bbGetInputPointsX(); std::vector pointsy = bbGetInputPointsY(); @@ -362,27 +430,27 @@ namespace bbvtk //Get the corresponding three points out of the vectors double origin[3]; - origin[0] = pointsx[0]; - origin[1] = pointsy[0]; - origin[2] = pointsz[0]; + origin[0] = pointsx[0]; + origin[1] = pointsy[0]; + origin[2] = pointsz[0]; double point1[3]; - point1[0] = pointsx[1]; - point1[1] = pointsy[1]; - point1[2] = pointsz[1]; + point1[0] = pointsx[1]; + point1[1] = pointsy[1]; + point1[2] = pointsz[1]; double point2[3]; - point2[0]= pointsx[2]; - point2[1]= pointsy[2]; - point2[2]= pointsz[2]; + point2[0] = pointsx[2]; + point2[1] = pointsy[2]; + point2[2] = pointsz[2]; //With the three points we create the corresponding X, Y and Z vectors all orthogonal to each other - double* vect1= getNormal(makeVector(origin, point1)); - double* vect2= getNormal(makeVector(origin, point2)); - double* crossp = getCrossProduct(vect1, vect2); + double* vect1 = getNormal(makeVector(origin, point1)); + double* vect2 = getNormal(makeVector(origin, point2)); + double* crossp = getCrossProduct(vect1, vect2); - double *newx = getCrossProduct(vect2, crossp); + double *newx = getCrossProduct(vect2, crossp); - int ext[6],factor=0; + int ext[6],factor = 0; bbGetInputIn()->GetExtent(ext); factor = ext[0]SetInput(bbGetInputIn()); +#endif +#if (VTK_MAJOR_VERSION >= 6) + plane3pts->SetInputData(bbGetInputIn()); +#endif + double xSpacing, ySpacing, zSpacing; bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing); plane3pts->SetOrigin(pointsx[0]*xSpacing,pointsy[0]*ySpacing,pointsz[0]*zSpacing); @@ -400,24 +476,52 @@ namespace bbvtk plane3pts->SetPoint2((origin[0]+vect2[0]*factor)*xSpacing, (origin[1]+vect2[1]*factor)*ySpacing, (origin[2]+vect2[2]*factor)*zSpacing); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) plane3pts->GetResliceOutput()->Update(); +#endif +#if (VTK_MAJOR_VERSION >= 6) + // .. +#endif + //To get the slice of image out of the selected volume - if (_imageReslicer==NULL){ + if (_imageReslicer==NULL) + { _imageReslicer = vtkImageReslice::New(); _imageReslicer->SetOutputDimensionality(2); _transform = vtkTransform::New(); _matrix = vtkMatrix4x4::New(); - } + } // if _imageReslicer->SetInterpolationMode( bbGetInputInterpolation() ); + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) _imageReslicer->SetInput( bbGetInputIn() ); +#endif +#if (VTK_MAJOR_VERSION >= 6) + _imageReslicer->SetInputData( bbGetInputIn() ); +#endif + + _imageReslicer->SetInformationInput(bbGetInputIn()); //fill out the information with the created vectors and using the spacing of the image _imageReslicer->SetResliceAxesDirectionCosines(newx[0]*xSpacing,newx[1]*xSpacing,newx[2]*xSpacing, vect2[0]*ySpacing,vect2[1]*ySpacing,vect2[2]*ySpacing, crossp[0]*zSpacing,crossp[1]*zSpacing,crossp[2]*zSpacing); _imageReslicer->SetResliceAxesOrigin(origin[0]*xSpacing,origin[1]*ySpacing,origin[2]*zSpacing); + + +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) _imageReslicer->GetOutput()->Update(); _imageReslicer->GetOutput()->UpdateInformation(); +#endif +#if (VTK_MAJOR_VERSION >= 6) + _imageReslicer->Update(); +#endif + + bbSetOutputImage3Pts(_imageReslicer->GetOutput()); @@ -444,23 +548,24 @@ namespace bbvtk } // bbGetInputIn } - void ImagePlanes::updateInteractor(){ - - vtkRenderWindowInteractor* interactor = bbGetInputInteractor(); - - if(interactor){ - bbGetOutputPlaneX()->SetInteractor(interactor); - bbGetOutputPlaneX()->EnabledOn(); - bbGetOutputPlaneY()->SetInteractor(interactor); - bbGetOutputPlaneY()->EnabledOn(); - bbGetOutputPlaneZ()->SetInteractor(interactor); - bbGetOutputPlaneZ()->EnabledOn(); - bbGetOutputPlane3Pts()->SetInteractor(interactor); - bbGetOutputPlane3Pts()->EnabledOn(); - } - } + void ImagePlanes::updateInteractor() + { + vtkRenderWindowInteractor* interactor = bbGetInputInteractor(); + if(interactor) + { + bbGetOutputPlaneX()->SetInteractor(interactor); + bbGetOutputPlaneX()->EnabledOn(); + bbGetOutputPlaneY()->SetInteractor(interactor); + bbGetOutputPlaneY()->EnabledOn(); + bbGetOutputPlaneZ()->SetInteractor(interactor); + bbGetOutputPlaneZ()->EnabledOn(); + bbGetOutputPlane3Pts()->SetInteractor(interactor); + bbGetOutputPlane3Pts()->EnabledOn(); + } // if + } + //----------------------------------------------------------------- - void vtkImageDataPointerRelay::bbUserSetDefaultValues() + void vtkImageDataPointerRelay::bbUserSetDefaultValues() { }