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) )
37 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
38 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
39 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
40 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
41 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
42 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
43 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
44 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
45 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
46 printf("EED Warnning!! PolyDataToImageData::Process Clean this code .................;\n ");
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 ");
55 bbGetInputInImage()->GetExtent( ext );
57 // vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
58 if (clean1!=NULL) clean1->Delete();
59 clean1 = vtkCleanPolyData::New();
60 clean1->SetInputData( bbGetInputInPolyData() );
62 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
63 triangle1->SetInputData( clean1->GetOutput() );
66 // vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New();
67 if (dataToStencil!=NULL) dataToStencil->Delete();
68 dataToStencil = vtkPolyDataToImageStencil::New();
69 dataToStencil->SetInputData( triangle1->GetOutput() );
70 dataToStencil->SetOutputWholeExtent( ext );
71 dataToStencil->Update();
73 // vtkExtractVOI *extract = vtkExtractVOI::New();
74 if (extract!=NULL) extract->Delete();
75 extract = vtkExtractVOI::New();
76 extract->SetVOI( ext );
77 extract->SetSampleRate(1, 1, 1);
78 extract->SetInputData( bbGetInputInImage() );
79 extract->ReleaseDataFlagOff();
82 // vtkImageStencil *stencil = vtkImageStencil::New();
83 if (stencil!=NULL) stencil->Delete();
84 stencil = vtkImageStencil::New();
85 stencil->SetInputData( extract->GetOutput() );
87 stencil->SetStencilData( dataToStencil->GetOutput() );
88 stencil->ReverseStencilOn();
89 stencil->SetBackgroundValue( bbGetInputBackgroundValue() );
92 bbSetOutputOut( stencil->GetOutput() );
94 printf("EED Warnning! PolyDataToImageData::Process > Missing Image or PolyData inputs\n");
99 // 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)
101 void PolyDataToImageData::bbUserSetDefaultValues()
104 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
105 // Here we initialize the input 'In' to 0
106 bbSetInputInPolyData(NULL);
107 bbSetInputInImage(NULL);
108 bbSetInputBackgroundValue(255);
112 // 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)
114 void PolyDataToImageData::bbUserInitializeProcessing()
117 // THE INITIALIZATION METHOD BODY :
119 // but this is where you should allocate the internal/output pointers
122 dataToStencil = NULL;
128 // 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)
130 void PolyDataToImageData::bbUserFinalizeProcessing()
133 // THE FINALIZATION METHOD BODY :
135 // but this is where you should desallocate the internal/output pointers
140 // EO namespace bbcreaVtk