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 "bbcreaVtkScalarsToColors.h"
5 #include "bbcreaVtkPackage.h"
10 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ScalarsToColors)
11 BBTK_BLACK_BOX_IMPLEMENTATION(ScalarsToColors,bbtk::AtomicBlackBox);
13 // 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)
15 void ScalarsToColors::Process()
18 // THE MAIN PROCESSING METHOD BODY
19 // Here we simply set the input 'In' value to the output 'Out'
20 // And print out the output value
21 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
22 // void bbSet{Input|Output}NAME(const TYPE&)
23 // const TYPE& bbGet{Input|Output}NAME() const
25 // * NAME is the name of the input/output
26 // (the one provided in the attribute 'name' of the tag 'input')
27 // * TYPE is the C++ type of the input/output
28 // (the one provided in the attribute 'type' of the tag 'input')
30 // bbSetOutputOut( bbGetInputIn() );
31 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
37 // Create the color map
38 if (bbGetInputType()==0)
40 _colorLookupTable = vtkLookupTable::New();
41 _colorLookupTable->Build();
44 for (int iLookTable = 0; iLookTable<128; iLookTable++)
46 _colorLookupTable->GetTableValue( iLookTable, rgba1);
47 _colorLookupTable->GetTableValue(256-1-iLookTable, rgba2);
49 _colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
50 _colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
55 if (bbGetInputRange().size()==2)
57 _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]);
59 _colorLookupTable->SetTableRange( 0,1 );
63 _colorLookupTable->GetColor( bbGetInputScalarValue() , rgb );
64 std::vector<double>colorRGB;
65 colorRGB.push_back( rgb[0] );
66 colorRGB.push_back( rgb[1] );
67 colorRGB.push_back( rgb[2] );
69 bbSetOutputColor( colorRGB );
70 bbSetOutputLookupTable(_colorLookupTable);
74 // 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)
76 void ScalarsToColors::bbUserSetDefaultValues()
79 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
80 // Here we initialize the input 'In' to 0
82 std::vector<double>range;
85 bbSetInputRange(range);
86 bbSetInputScalarValue(0);
89 _colorLookupTable=NULL;
92 // 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)
94 void ScalarsToColors::bbUserInitializeProcessing()
97 // THE INITIALIZATION METHOD BODY :
99 // but this is where you should allocate the internal/output pointers
105 // 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)
107 void ScalarsToColors::bbUserFinalizeProcessing()
110 // THE FINALIZATION METHOD BODY :
112 // but this is where you should desallocate the internal/output pointers
117 // EO namespace bbcreaVtk