X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkImagePlanes.cxx;h=92476f5e19b8a01a00719c3c671d8a3063169404;hb=333b90638d58e788efffee2c61da9e152016e292;hp=746492a6d566cd691a9823989f6f67a89dc4d343;hpb=4e639a77332569de9321dc84c7788811828d4711;p=bbtk.git diff --git a/packages/vtk/src/bbvtkImagePlanes.cxx b/packages/vtk/src/bbvtkImagePlanes.cxx index 746492a..92476f5 100644 --- a/packages/vtk/src/bbvtkImagePlanes.cxx +++ b/packages/vtk/src/bbvtkImagePlanes.cxx @@ -1,33 +1,38 @@ -/*========================================================================= +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= Program: bbtk Module: $RCSfile: bbvtkImagePlanes.cxx,v $ Language: C++ - Date: $Date: 2012/07/04 08:38:21 $ - Version: $Revision: 1.36 $ + Date: $Date: 2012/11/16 08:51:58 $ + Version: $Revision: 1.38 $ =========================================================================*/ -/* --------------------------------------------------------------------- - -* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) -* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux -* -* This software is governed by the CeCILL-B license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL-B -* license as circulated by CEA, CNRS and INRIA at the following URL -* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -* or in the file LICENSE.txt. -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited -* liability. -* -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL-B license and that you accept its terms. -* ------------------------------------------------------------------------ */ - /** * \file * \brief @@ -65,7 +70,10 @@ #include "bbstdRelay.h" #include "vtkObjectFactory.h" +#include "vtkImageFlip.h" +#include "vtkImageReslice.h" +#include "vtkImageChangeInformation.h" namespace bbstd { @@ -136,7 +144,7 @@ namespace bbvtk }; //================================================================ - //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.36 $"); + //vtkCxxRevisionMacro(ImagePlanes::VtkCallbackType, "$Revision: 1.38 $"); //================================================================ @@ -196,12 +204,39 @@ namespace bbvtk vtkImagePlaneWidget* planeWidget3Pts = GetPlaneWidget('3', 0, 1, 1, picker); planeWidget3Pts->SetLookupTable(planeWidgetX->GetLookupTable()); + // EED MPR view orientation correction.. + vtkImageFlip *flipYFilter = vtkImageFlip::New(); + flipYFilter->SetFilteredAxis(1); // flip y axis + flipYFilter->SetInput( planeWidgetX->GetResliceOutput() ); + flipYFilter->Update(); + + vtkImageChangeInformation *image = vtkImageChangeInformation::New(); + image->SetInput( planeWidgetY->GetResliceOutput() ); + image->SetOutputSpacing( 1,1,1 ); + image->CenterImageOn(); + image->Update(); + _imageTransform = vtkTransform::New(); + vtkImageReslice *slicer =vtkImageReslice::New(); + slicer->SetInput( image->GetOutput() ); + slicer->SetInformationInput( image->GetOutput() ); + slicer->SetResliceTransform( _imageTransform ); + slicer->SetOutputOrigin(0 , 0 , 0 ); + slicer->SetInterpolationModeToNearestNeighbor(); + slicer->Update(); + vtkImageChangeInformation *imageResult = vtkImageChangeInformation::New(); + imageResult->SetInput( slicer->GetOutput() ); + double spc[3]; + planeWidgetY->GetResliceOutput()->GetSpacing(spc); + imageResult->SetOutputSpacing( spc[1], spc[0], spc[2] ); + imageResult->SetOutputOrigin( 0,0,0 ); + + bbSetOutputPlaneX(planeWidgetX); bbSetOutputPlaneY(planeWidgetY); bbSetOutputPlaneZ(planeWidgetZ); bbSetOutputPlane3Pts(planeWidget3Pts); - bbSetOutputImageX(planeWidgetX->GetResliceOutput()); - bbSetOutputImageY(planeWidgetY->GetResliceOutput()); + bbSetOutputImageX( flipYFilter->GetOutput() ); // EED MPR view orientation correction.. + bbSetOutputImageY( imageResult->GetOutput() ); // EED MPR view orientation correction.. bbSetOutputImageZ(planeWidgetZ->GetResliceOutput()); bbSetInputInteractor(0); //bbSetOutputImage3Pts(planeWidget3Pts->GetResliceOutput()); @@ -244,16 +279,28 @@ namespace bbvtk //--------------------------------------------------------------------- void ImagePlanes::Process() { + if (bbGetInputIn()!=0) { - int xMin, xMax, yMin, yMax, zMin, zMax; - bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax); - + int dim[3]; + int ext[6]; + bbGetOutputPlaneX()->GetResliceOutput()->GetWholeExtent(ext); + dim[0] = ext[1]-ext[0]+1; + dim[1] = ext[3]-ext[2]+1; + dim[2] = ext[5]-ext[4]+1; + _imageTransform->Identity(); + _imageTransform->PostMultiply(); + _imageTransform->Translate( (int)(-(dim[0]/2)) , (int)(-(dim[1]/2)) ,0); + _imageTransform->RotateZ(90); + + if ( image != bbGetInputIn()){//bbGetInputStatus("In") != bbtk::UPTODATE ){ // Input image has changed : reinitialize planes image = bbGetInputIn(); // Initial values : center of the volume (in real world, not in pixels!) + int xMin, xMax, yMin, yMax, zMin, zMax; + bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax); double xSpacing, ySpacing, zSpacing; bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing); @@ -277,24 +324,33 @@ namespace bbvtk { bbGetOutputPlaneZ()->SetWindowLevel(bbGetInputWindowLevel()[0], bbGetInputWindowLevel()[1]); - } - else - { + } else { double *range = image->GetScalarRange(); bbGetOutputPlaneZ()->SetWindowLevel(range[1]-range[0], 0.5*(range[1]+range[0])); - } + } // windowlevel updateInteractor(); - } + + dim[0] = xMax-xMin+1; + dim[1] = yMax-yMin+1; + dim[2] = zMax-zMin+1; + _imageTransform->Identity(); + _imageTransform->PostMultiply(); + _imageTransform->Translate( (int)(-(dim[0]/2)*(1/xSpacing)) , (int)(-(dim[2]/2)*(1/zSpacing)) ,0); + _imageTransform->RotateZ(90); + + } // image + // UPDATE DES SORTIES bbGetOutputPlaneX()->SetResliceInterpolate( bbGetInputInterpolation() ); bbGetOutputPlaneY()->SetResliceInterpolate( bbGetInputInterpolation() ); bbGetOutputPlaneZ()->SetResliceInterpolate( bbGetInputInterpolation() ); + bbGetOutputPlaneX()->GetResliceOutput()->Update(); bbGetOutputPlaneY()->GetResliceOutput()->Update(); bbGetOutputPlaneZ()->GetResliceOutput()->Update(); - + std::vector pointsx = bbGetInputPointsX(); std::vector pointsy = bbGetInputPointsY(); std::vector pointsz = bbGetInputPointsZ();