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 );
39 // vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
40 if (clean1!=NULL) clean1->Delete();
41 clean1 = vtkCleanPolyData::New();
42 clean1->SetInputData( bbGetInputInPolyData() );
44 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
45 triangle1->SetInputData( clean1->GetOutput() );
47 // vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
48 if (dataToStencil!=NULL) dataToStencil->Delete();
49 dataToStencil = vtkPolyDataToImageStencil::New();
50 dataToStencil->SetInputData( triangle1->GetOutput() );
51 dataToStencil->SetOutputWholeExtent( ext );
52 dataToStencil->Update();
53 // vtkExtractVOI *extract = vtkExtractVOI::New();
54 if (extract!=NULL) extract->Delete();
55 extract = vtkExtractVOI::New();
56 extract->SetVOI( ext );
57 extract->SetSampleRate(1, 1, 1);
58 extract->SetInputData( bbGetInputInImage() );
59 extract->ReleaseDataFlagOff();
61 // vtkImageStencil *stencil = vtkImageStencil::New();
62 if (stencil!=NULL) stencil->Delete();
63 stencil = vtkImageStencil::New();
64 stencil->SetInputData( extract->GetOutput() );
66 stencil->SetStencilData( dataToStencil->GetOutput() );
67 stencil->ReverseStencilOn();
68 stencil->SetBackgroundValue( bbGetInputBackgroundValue() );
70 bbSetOutputOut( stencil->GetOutput() );
72 printf("EED Warnning! PolyDataToImageData::Process > Missing Image or PolyData inputs\n");
73 bbSetOutputOut( NULL);
77 // 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)
79 void PolyDataToImageData::bbUserSetDefaultValues()
81 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
82 // Here we initialize the input 'In' to 0
83 bbSetInputInPolyData(NULL);
84 bbSetInputInImage(NULL);
85 bbSetInputBackgroundValue(255);
88 // 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)
90 void PolyDataToImageData::bbUserInitializeProcessing()
92 // THE INITIALIZATION METHOD BODY :
94 // but this is where you should allocate the internal/output pointers
102 // 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)
104 void PolyDataToImageData::bbUserFinalizeProcessing()
107 // THE FINALIZATION METHOD BODY :
109 // but this is where you should desallocate the internal/output pointers
114 // EO namespace bbcreaVtk