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;
33 printf("EED ScalarsToColors::Process Start\n");
37 // Create the color map
38 if (bbGetInputType()==0)
40 _colorLookupTable = vtkLookupTable::New();
41 if (bbGetInputRange().size()==2)
43 _colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]);
44 // _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]);
46 _colorLookupTable->SetRange(0,255);
48 _colorLookupTable->SetNumberOfTableValues(1000);
49 _colorLookupTable->Build();
53 for (iLookTable = 0; iLookTable<500; iLookTable++)
55 _colorLookupTable->GetTableValue( iLookTable, rgba1);
56 _colorLookupTable->GetTableValue(1000-1-iLookTable, rgba2);
57 _colorLookupTable->SetTableValue(1000-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
58 _colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
61 _colorLookupTable->GetTableValue(0,rgba);
63 _colorLookupTable->SetTableValue(0,rgba);
68 _colorLookupTable->GetTableValue(500+100+i, rgba);
69 rgba[3]=(double)i/(double)iMax;
70 _colorLookupTable->SetTableValue(500+100+i,rgba);
71 _colorLookupTable->GetTableValue(500-100-i, rgba);
72 rgba[3]=(double)i/(double)iMax;
73 _colorLookupTable->SetTableValue(500-100-i,rgba);
79 _colorLookupTable->GetTableValue(500+i, rgba);
81 _colorLookupTable->SetTableValue(500+i,rgba);
82 _colorLookupTable->GetTableValue(500-i, rgba);
84 _colorLookupTable->SetTableValue(500-i,rgba);
89 //EED 2018-06-8 ***********************ARDS Projet***********************************************
90 if (bbGetInputType()==1)
92 _colorLookupTable = vtkLookupTable::New();
93 if (bbGetInputRange().size()==2)
95 _colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]);
96 // _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]);
98 _colorLookupTable->SetRange(0,255);
100 _colorLookupTable->SetValueRange(0.0, 1.0); // from black to white
101 _colorLookupTable->SetSaturationRange(0.0, 0.0); // no color saturation
102 _colorLookupTable->SetRampToLinear();
103 _colorLookupTable->Build();
105 _colorLookupTable->GetTableValue(0,rgba);
107 _colorLookupTable->SetTableValue(0,rgba);
116 std::vector<double>colorRGB;
117 _colorLookupTable->GetColor( bbGetInputScalarValue() , rgb );
118 colorRGB.push_back( rgb[0] );
119 colorRGB.push_back( rgb[1] );
120 colorRGB.push_back( rgb[2] );
121 bbSetOutputColor( colorRGB );
122 bbSetOutputLookupTable(_colorLookupTable);
124 printf("EED ScalarsToColors::Process End\n");
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 ScalarsToColors::bbUserSetDefaultValues()
133 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
134 // Here we initialize the input 'In' to 0
136 std::vector<double>range;
137 range.push_back( 0 );
138 range.push_back( 1 );
139 bbSetInputRange(range);
140 bbSetInputScalarValue(0);
143 _colorLookupTable=NULL;
146 // 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)
148 void ScalarsToColors::bbUserInitializeProcessing()
151 // THE INITIALIZATION METHOD BODY :
153 // but this is where you should allocate the internal/output pointers
159 // 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)
161 void ScalarsToColors::bbUserFinalizeProcessing()
164 // THE FINALIZATION METHOD BODY :
166 // but this is where you should desallocate the internal/output pointers
171 // EO namespace bbcreaVtk