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 ");
40 bbGetInputInImage()->GetExtent( ext );
41 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 printf("EED PolyDataToImageData::Process 1 \n");
50 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
51 triangle1->SetInputData( clean1->GetOutput() );
53 printf("EED PolyDataToImageData::Process 2 \n");
54 // vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
55 if (dataToStencil!=NULL) dataToStencil->Delete();
56 dataToStencil = vtkPolyDataToImageStencil::New();
57 dataToStencil->SetInputData( triangle1->GetOutput() );
58 dataToStencil->SetOutputOrigin( org );
59 dataToStencil->SetOutputSpacing( spc );
60 dataToStencil->SetOutputWholeExtent( ext );
61 dataToStencil->Update();
62 printf("EED PolyDataToImageData::Process 3 \n");
63 // vtkExtractVOI *extract = vtkExtractVOI::New();
64 if (extract!=NULL) extract->Delete();
65 extract = vtkExtractVOI::New();
66 extract->SetVOI( ext );
67 extract->SetSampleRate(1, 1, 1);
68 extract->SetInputData( bbGetInputInImage() );
69 extract->ReleaseDataFlagOff();
71 printf("EED PolyDataToImageData::Process 4 \n");
72 // vtkImageStencil *stencil = vtkImageStencil::New();
73 if (stencil!=NULL) stencil->Delete();
74 stencil = vtkImageStencil::New();
75 stencil->SetInputData( extract->GetOutput() );
77 printf("EED PolyDataToImageData::Process 5 \n");
78 stencil->SetStencilData( dataToStencil->GetOutput() );
79 stencil->ReverseStencilOn();
80 stencil->SetBackgroundValue( bbGetInputBackgroundValue() );
82 printf("EED PolyDataToImageData::Process 6 \n");
83 bbSetOutputOut( stencil->GetOutput() );
85 printf("EED Warnning! PolyDataToImageData::Process > Missing Image or PolyData inputs\n");
86 bbSetOutputOut( NULL);
90 // 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)
92 void PolyDataToImageData::bbUserSetDefaultValues()
94 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
95 // Here we initialize the input 'In' to 0
96 bbSetInputInPolyData(NULL);
97 bbSetInputInImage(NULL);
98 bbSetInputBackgroundValue(255);
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::bbUserInitializeProcessing()
105 // THE INITIALIZATION METHOD BODY :
107 // but this is where you should allocate the internal/output pointers
110 dataToStencil = NULL;
115 // 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)
117 void PolyDataToImageData::bbUserFinalizeProcessing()
120 // THE FINALIZATION METHOD BODY :
122 // but this is where you should desallocate the internal/output pointers
127 // EO namespace bbcreaVtk