]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageReSlicerBox.cxx
Feature #1766 Add licence terms for all files.
[creaRigidRegistration.git] / PackRecalage / src / bbPackRecalageReSlicerBox.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
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.
14 #
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
19 #  liability. 
20 #
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 # ------------------------------------------------------------------------   
24 */
25
26
27 #include "bbPackRecalageReSlicerBox.h"
28 #include "bbPackRecalagePackage.h"
29
30 namespace bbPackRecalage
31 {
32
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ReSlicerBox)
34 BBTK_BLACK_BOX_IMPLEMENTATION(ReSlicerBox,bbtk::AtomicBlackBox);
35 void ReSlicerBox::Process()
36 {
37         if(!bbGetInputOrigin().empty()  && bbGetInputTransform() != NULL)
38         {
39                 //image = vtkImageChangeInformation::New();
40                 image->SetInput( bbGetInputIn() );
41                 image->SetOutputSpacing( 1,1,1 );
42
43                 if(bbGetInputCentered())
44                 {
45                         image->CenterImageOn();
46                 }
47
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]) );
53                 if(bbGetInputInterpolate())
54                 {
55                         slicer->InterpolateOn();
56                 }               
57                 slicer->Update();
58
59                 //imageResult = vtkImageChangeInformation::New();
60                 imageResult->SetInput( slicer->GetOutput() );
61                 double spc[3];
62                 bbGetInputIn()->GetSpacing(spc);
63                 imageResult->SetOutputSpacing( spc ); 
64                 imageResult->SetOutputOrigin( 0,0,0 ); 
65         
66                 bbSetOutputOut( imageResult->GetOutput() );
67         }
68         else
69         {
70                 bbSetOutputOut( NULL );
71         }  
72 }
73 void ReSlicerBox::bbUserSetDefaultValues()
74
75         std::vector<int> empty;
76         bbSetInputOrigin(empty); 
77     bbSetInputIn(NULL); 
78     bbSetInputTransform(NULL);
79     bbSetOutputOut(NULL);
80         bbSetInputCentered(false);
81         bbSetInputInterpolate(false);
82   
83 }
84 void ReSlicerBox::bbUserInitializeProcessing()
85 {
86  
87 //  THE INITIALIZATION METHOD BODY : 
88 //    Here does nothing  
89 //    but this is where you should allocate the internal/output pointers  
90 //    if any  
91         image = vtkImageChangeInformation::New();
92     slicer =vtkImageReslice::New();
93         imageResult = vtkImageChangeInformation::New();
94 }
95 void ReSlicerBox::bbUserFinalizeProcessing()
96
97         image->Delete();
98         slicer->Delete();
99     imageResult->Delete();
100 }
101 }
102 // EO namespace bbPackRecalage