]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageResampleBox.cxx
9350844d189e6e922e28e3982285fb363024d996
[creaRigidRegistration.git] / PackRecalage / src / bbPackRecalageResampleBox.cxx
1 #include "bbPackRecalageResampleBox.h"
2 #include "bbPackRecalagePackage.h"
3 namespace bbPackRecalage
4 {
5
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage, ResampleBox)
7 BBTK_BLACK_BOX_IMPLEMENTATION(ResampleBox, bbtk::AtomicBlackBox);
8 void ResampleBox::Process()
9 {
10     if(bbGetInputIn() != NULL && bbGetInputFactor() != 0)
11         {
12                 double factor = bbGetInputFactor();
13                 resample->SetInput(bbGetInputIn());
14                 resample->SetAxisMagnificationFactor(0, factor);
15                 resample->SetAxisMagnificationFactor(1, factor);
16                 resample->SetAxisMagnificationFactor(2, factor);
17                 resample->Update();
18                 vtkImageData *image = resample->GetOutput();
19                 std::cout << "NTU: new spacing!" << image->GetExtent()[1] << " " << image->GetExtent()[3] << " " << image->GetExtent()[5] << " " << image->GetSpacing()[0] << " " << image->GetSpacing()[1] << " " << image->GetSpacing()[2] << std::endl;
20                 bbSetOutputOut(resample->GetOutput());
21         }
22         else
23         {
24                 bbSetOutputOut(NULL);
25         }
26 }
27
28 void ResampleBox::bbUserSetDefaultValues()
29 {
30     bbSetInputIn(NULL);
31         bbSetInputFactor(0);
32         bbSetOutputOut(NULL);
33 }
34
35 void ResampleBox::bbUserInitializeProcessing()
36 {
37         resample = vtkImageResample::New();
38 }
39
40 void ResampleBox::bbUserFinalizeProcessing()
41 {
42         resample->Delete(); 
43 }
44
45 }
46 // EO namespace bbPackRecalage
47
48