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"
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PolyDataToImageData)
12 BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataToImageData,bbtk::AtomicBlackBox);
14 // 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)
16 void PolyDataToImageData::Process()
19 // THE MAIN PROCESSING METHOD BODY
20 // Here we simply set the input 'In' value to the output 'Out'
21 // And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 // void bbSet{Input|Output}NAME(const TYPE&)
24 // const TYPE& bbGet{Input|Output}NAME() const
26 // * NAME is the name of the input/output
27 // (the one provided in the attribute 'name' of the tag 'input')
28 // * TYPE is the C++ type of the input/output
29 // (the one provided in the attribute 'type' of the tag 'input')
31 // bbSetOutputOut( bbGetInputIn() );
32 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
34 if ((bbGetInputInPolyData()!=NULL) && (bbGetInputInImage()!=NULL) )
36 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
38 bbGetInputInImage()->GetExtent( ext );
40 bbGetInputInImage()->GetSpacing( spc );
42 bbGetInputInImage()->GetOrigin( org );
44 // vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
45 if (clean1!=NULL) clean1->Delete();
46 clean1 = vtkCleanPolyData::New();
47 clean1->SetInputData( bbGetInputInPolyData() );
49 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
50 triangle1->SetInputData( clean1->GetOutput() );
52 // vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
53 if (dataToStencil!=NULL) dataToStencil->Delete();
54 dataToStencil = vtkPolyDataToImageStencil::New();
55 dataToStencil->SetInputData( triangle1->GetOutput() );
56 dataToStencil->SetOutputOrigin( org );
57 dataToStencil->SetOutputSpacing( spc );
58 dataToStencil->SetOutputWholeExtent( ext );
59 dataToStencil->Update();
60 // vtkExtractVOI *extract = vtkExtractVOI::New();
61 if (extract!=NULL) extract->Delete();
62 extract = vtkExtractVOI::New();
63 extract->SetVOI( ext );
64 extract->SetSampleRate(1, 1, 1);
65 extract->SetInputData( bbGetInputInImage() );
66 extract->ReleaseDataFlagOff();
68 // vtkImageStencil *stencil = vtkImageStencil::New();
69 if (stencil!=NULL) stencil->Delete();
70 stencil = vtkImageStencil::New();
71 stencil->SetInputData( extract->GetOutput() );
73 stencil->SetStencilData( dataToStencil->GetOutput() );
74 stencil->ReverseStencilOn();
75 stencil->SetBackgroundValue( bbGetInputBackgroundValue() );
77 bbSetOutputOut( stencil->GetOutput() );
79 printf("EED Warnning! PolyDataToImageData::Process > Missing Image or PolyData inputs\n");
80 bbSetOutputOut( NULL);
84 // 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)
86 void PolyDataToImageData::bbUserSetDefaultValues()
88 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
89 // Here we initialize the input 'In' to 0
90 bbSetInputInPolyData(NULL);
91 bbSetInputInImage(NULL);
92 bbSetInputBackgroundValue(255);
95 // 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)
97 void PolyDataToImageData::bbUserInitializeProcessing()
99 // THE INITIALIZATION METHOD BODY :
101 // but this is where you should allocate the internal/output pointers
104 dataToStencil = NULL;
109 // 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)
111 void PolyDataToImageData::bbUserFinalizeProcessing()
114 // THE FINALIZATION METHOD BODY :
116 // but this is where you should desallocate the internal/output pointers
121 // EO namespace bbcreaVtk