2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
27 #include "bbPackRecalageReSlicerBox.h"
28 #include "bbPackRecalagePackage.h"
30 namespace bbPackRecalage
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ReSlicerBox)
34 BBTK_BLACK_BOX_IMPLEMENTATION(ReSlicerBox,bbtk::AtomicBlackBox);
35 void ReSlicerBox::Process()
37 if(!bbGetInputOrigin().empty() && bbGetInputTransform() != NULL)
39 //image = vtkImageChangeInformation::New();
40 image->SetInput( bbGetInputIn() );
41 image->SetOutputSpacing( 1,1,1 );
43 if(bbGetInputCentered())
45 image->CenterImageOn();
48 //slicer =vtkImageReslice::New();
49 slicer->SetInput( image->GetOutput() );
50 slicer->SetInformationInput( image->GetOutput() );
51 slicer->SetResliceTransform(bbGetInputTransform());
52 slicer->SetOutputOrigin( -(bbGetInputOrigin()[0]) , -(bbGetInputOrigin()[1]) , -(bbGetInputOrigin()[2]) );
55 if(bbGetInputInterpolate())
57 slicer->InterpolateOn();
61 //imageResult = vtkImageChangeInformation::New();
62 imageResult->SetInput( slicer->GetOutput() );
64 bbGetInputIn()->GetSpacing(spc);
65 imageResult->SetOutputSpacing( spc );
66 imageResult->SetOutputOrigin( 0,0,0 );
68 bbSetOutputOut( imageResult->GetOutput() );
70 if (bbGetInputTransform()!=NULL)
72 bbGetInputTransform()->Update();
73 vtkMatrix4x4 *m = bbGetInputTransform()->GetMatrix();
76 printf("EED ReSlicerBox::Process Translation %d %d %d \n",-(bbGetInputOrigin()[0]),-(bbGetInputOrigin()[1]),-(bbGetInputOrigin()[2]));
77 printf("EED ReSlicerBox::Process Matrix %f %f %f %f\n", m->GetElement(0,0),m->GetElement(0,1),m->GetElement(0,2),m->GetElement(0,3));
78 printf("EED ReSlicerBox::Process Matrix %f %f %f %f\n", m->GetElement(1,0),m->GetElement(1,1),m->GetElement(1,2),m->GetElement(1,3));
79 printf("EED ReSlicerBox::Process Matrix %f %f %f %f\n", m->GetElement(2,0),m->GetElement(2,1),m->GetElement(2,2),m->GetElement(2,3));
80 printf("EED ReSlicerBox::Process Matrix %f %f %f %f\n", m->GetElement(3,0),m->GetElement(3,1),m->GetElement(3,2),m->GetElement(3,3));
86 bbSetOutputOut( NULL );
91 void ReSlicerBox::bbUserSetDefaultValues()
93 std::vector<int> empty;
94 bbSetInputOrigin(empty);
96 bbSetInputTransform(NULL);
98 bbSetInputCentered(false);
99 bbSetInputInterpolate(false);
104 void ReSlicerBox::bbUserInitializeProcessing()
107 // THE INITIALIZATION METHOD BODY :
109 // but this is where you should allocate the internal/output pointers
111 image = vtkImageChangeInformation::New();
112 slicer =vtkImageReslice::New();
113 imageResult = vtkImageChangeInformation::New();
116 void ReSlicerBox::bbUserFinalizeProcessing()
120 imageResult->Delete();
124 // EO namespace bbPackRecalage