]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageReSlicerBox.cxx
0786a1d299d217f80efdd181ec18a9978b6343a4
[creaRigidRegistration.git] / PackRecalage / src / bbPackRecalageReSlicerBox.cxx
1 #include "bbPackRecalageReSlicerBox.h"
2 #include "bbPackRecalagePackage.h"
3
4 namespace bbPackRecalage
5 {
6
7 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ReSlicerBox)
8 BBTK_BLACK_BOX_IMPLEMENTATION(ReSlicerBox,bbtk::AtomicBlackBox);
9 void ReSlicerBox::Process()
10 {
11         if(!bbGetInputOrigin().empty()  && bbGetInputTransform() != NULL)
12         {
13                 //image = vtkImageChangeInformation::New();
14                 image->SetInput( bbGetInputIn() );
15                 image->SetOutputSpacing( 1,1,1 );
16
17                 if(bbGetInputCentered())
18                 {
19                         image->CenterImageOn();
20                 }
21
22                 //slicer =vtkImageReslice::New();
23                 slicer->SetInput( image->GetOutput() );
24                 slicer->SetInformationInput( image->GetOutput() );
25                 slicer->SetResliceTransform(bbGetInputTransform());
26                 slicer->SetOutputOrigin( -(bbGetInputOrigin()[0]) , -(bbGetInputOrigin()[1]) , -(bbGetInputOrigin()[2]) );
27                 if(bbGetInputInterpolate())
28                 {
29                         slicer->InterpolateOn();
30                 }               
31                 slicer->Update();
32
33                 //imageResult = vtkImageChangeInformation::New();
34                 imageResult->SetInput( slicer->GetOutput() );
35                 double spc[3];
36                 bbGetInputIn()->GetSpacing(spc);
37                 imageResult->SetOutputSpacing( spc ); 
38                 imageResult->SetOutputOrigin( 0,0,0 ); 
39         
40                 bbSetOutputOut( imageResult->GetOutput() );
41         }
42         else
43         {
44                 bbSetOutputOut( NULL );
45         }  
46 }
47 void ReSlicerBox::bbUserSetDefaultValues()
48
49         std::vector<int> empty;
50         bbSetInputOrigin(empty); 
51     bbSetInputIn(NULL); 
52     bbSetInputTransform(NULL);
53     bbSetOutputOut(NULL);
54         bbSetInputCentered(false);
55         bbSetInputInterpolate(false);
56   
57 }
58 void ReSlicerBox::bbUserInitializeProcessing()
59 {
60  
61 //  THE INITIALIZATION METHOD BODY : 
62 //    Here does nothing  
63 //    but this is where you should allocate the internal/output pointers  
64 //    if any  
65         image = vtkImageChangeInformation::New();
66     slicer =vtkImageReslice::New();
67         imageResult = vtkImageChangeInformation::New();
68 }
69 void ReSlicerBox::bbUserFinalizeProcessing()
70
71         image->Delete();
72         slicer->Delete();
73     imageResult->Delete();
74 }
75 }
76 // EO namespace bbPackRecalage