2 // 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)
4 #include "bbcreaVtkPolyDataToImageData.h"
5 #include "bbcreaVtkPackage.h"
7 #include "vtkPolyDataToImageStencil.h"
8 #include "vtkImageStencil.h"
10 #include "vtkCleanPolyData.h"
11 #include "vtkTriangleFilter.h"
13 #include "vtkExtractVOI.h"
14 #include "vtkExtractVOI.h"
21 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PolyDataToImageData)
22 BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToImageData,bbtk::AtomicBlackBox);
24 // 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)
26 void PolyDataToImageData::Process()
29 // THE MAIN PROCESSING METHOD BODY
30 // Here we simply set the input 'In' value to the output 'Out'
31 // And print out the output value
32 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
33 // void bbSet{Input|Output}NAME(const TYPE&)
34 // const TYPE& bbGet{Input|Output}NAME() const
36 // * NAME is the name of the input/output
37 // (the one provided in the attribute 'name' of the tag 'input')
38 // * TYPE is the C++ type of the input/output
39 // (the one provided in the attribute 'type' of the tag 'input')
41 // bbSetOutputOut( bbGetInputIn() );
42 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
44 if ((bbGetInputInPolyData()!=NULL) && (bbGetInputInImage()!=NULL))
47 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
48 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
49 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
50 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
51 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
52 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
53 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
54 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
55 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
56 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
57 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
58 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
59 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
60 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
61 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
62 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
65 bbGetInputInImage()->GetExtent( ext );
67 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
68 clean1->SetInputData( bbGetInputInPolyData() );
70 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
71 triangle1->SetInputData( clean1->GetOutput() );
74 vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
75 dataToStencil->SetInputData( triangle1->GetOutput() );
76 dataToStencil->SetOutputWholeExtent( ext );
77 dataToStencil->Update();
79 vtkExtractVOI *extract = vtkExtractVOI::New();
80 extract->SetVOI( ext );
81 extract->SetSampleRate(1, 1, 1);
82 extract->SetInputData( bbGetInputInImage() );
83 extract->ReleaseDataFlagOff();
86 vtkImageStencil *stencil = vtkImageStencil::New();
87 stencil->SetInputData( extract->GetOutput() );
89 stencil->SetStencilData( dataToStencil->GetOutput() );
90 stencil->ReverseStencilOn();
91 stencil->SetBackgroundValue(128);
94 bbSetOutputOut( stencil->GetOutput() );
96 printf("EED Warnning! PolyDataToImageData::Process > Missing Image or PolyData inputs\n");
101 // 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)
103 void PolyDataToImageData::bbUserSetDefaultValues()
106 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
107 // Here we initialize the input 'In' to 0
108 bbSetInputInPolyData(NULL);
109 bbSetInputInImage(NULL);
113 // 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)
115 void PolyDataToImageData::bbUserInitializeProcessing()
118 // THE INITIALIZATION METHOD BODY :
120 // but this is where you should allocate the internal/output pointers
126 // 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)
128 void PolyDataToImageData::bbUserFinalizeProcessing()
131 // THE FINALIZATION METHOD BODY :
133 // but this is where you should desallocate the internal/output pointers
138 // EO namespace bbcreaVtk