]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageReSlicerBox.cxx
c30ee0f49a5635017baebd9ccb075312f709a5f4
[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  
12         if(!bbGetInputOrigin().empty())
13         {
14                 image = vtkImageChangeInformation::New();
15                 image->SetInput( bbGetInputIn() );
16                 image->SetOutputSpacing( 1,1,1 );
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( bbGetInputIn() );
45         }
46           
47 }
48 void ReSlicerBox::bbUserSetDefaultValues()
49
50         std::vector<int> empty;
51         bbSetInputOrigin(empty); 
52     bbSetInputIn(NULL); 
53     bbSetInputTransform(vtkTransform::New());
54     bbSetOutputOut(NULL);
55         bbSetInputCentered(false);
56         bbSetInputInterpolate(false);
57   
58 }
59 void ReSlicerBox::bbUserInitializeProcessing()
60 {
61  
62 //  THE INITIALIZATION METHOD BODY : 
63 //    Here does nothing  
64 //    but this is where you should allocate the internal/output pointers  
65 //    if any  
66         image = vtkImageChangeInformation::New();
67     slicer =vtkImageReslice::New();
68         imageResult = vtkImageChangeInformation::New();
69 }
70 void ReSlicerBox::bbUserFinalizeProcessing()
71 {
72  
73 //  THE FINALIZATION METHOD BODY : 
74 //    Here does nothing  
75 //    but this is where you should desallocate the internal/output pointers  
76 //    if any 
77         image->Delete();
78         slicer->Delete();
79     imageResult->Delete();
80 }
81 }
82 // EO namespace bbPackRecalage