]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkImageContinuousErode3D.cxx
#3279 creaVtk Bug New Normal - ImageContinuousErode3D box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkImageContinuousErode3D.cxx
1
2 #include "bbcreaVtkImageContinuousErode3D.h"
3 #include "bbcreaVtkPackage.h"
4
5 #include "vtkImageContinuousErode3D.h"
6
7
8 namespace bbcreaVtk
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageContinuousErode3D)
12 BBTK_BLACK_BOX_IMPLEMENTATION(ImageContinuousErode3D,bbtk::AtomicBlackBox);
13
14 void ImageContinuousErode3D::Process()
15 {
16 printf("EED ImageContinuousErode3D::Process Repetitions=%d\n", bbGetInputRepetitions() );
17 printf("EED ImageContinuousErode3D::Process XYZ=%f %f %f\n", bbGetInputX(), bbGetInputY(), bbGetInputZ() );
18
19                 vtkImageData* result = erodeFilterRecursive(bbGetInputImage(), bbGetInputRepetitions(), bbGetInputX(),bbGetInputY(),bbGetInputZ());
20                 bbSetOutputOut(result);
21 }
22
23 vtkImageData* ImageContinuousErode3D::erodeFilterRecursive(vtkImageData* image, int repetitions, double x, double y, double z)
24 {
25                 vtkImageContinuousErode3D *erodeFilter = vtkImageContinuousErode3D ::New();
26 //EED 2017-01-01 Migration VTK7
27 #if VTK_MAJOR_VERSION <= 5
28     erodeFilter->SetInput (image);
29 #else
30     erodeFilter->SetInputData(image);
31 #endif
32     erodeFilter->SetKernelSize(x, y, z);
33                 erodeFilter->Modified();                
34                 erodeFilter->Update();
35                 vtkImageData* resultRec;
36                 if(repetitions == 0)
37                 {
38                         resultRec = erodeFilter->GetOutput();
39                         return resultRec;
40                 }else{
41                         erodeFilterRecursive(erodeFilter->GetOutput(), (repetitions-1), x, y, z);
42                 } // if repetitions
43 }
44
45 void ImageContinuousErode3D::bbUserSetDefaultValues()
46 {
47         bbSetInputX(3); 
48         bbSetInputY(3); 
49         bbSetInputY(3); 
50         bbSetInputRepetitions(0); 
51 }
52 //===== 
53 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
54 //===== 
55 void ImageContinuousErode3D::bbUserInitializeProcessing()
56 {
57 }
58 //===== 
59 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
60 //===== 
61 void ImageContinuousErode3D::bbUserFinalizeProcessing()
62 {
63
64 }
65 }
66 // EO namespace bbcreaVtk
67
68