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);
71 _colorLookupTable->GetTableValue(500+i, rgba);
72 rgba[3]=(double)i/(double)iMax;
73 _colorLookupTable->SetTableValue(500+i,rgba);
74 _colorLookupTable->GetTableValue(500-i, rgba);
75 rgba[3]=(double)i/(double)iMax;
76 _colorLookupTable->SetTableValue(500-i,rgba);
86 _colorLookupTable->GetTableValue(500+100+i, rgba);
87 rgba[3]=(double)i/(double)iMax;
88 _colorLookupTable->SetTableValue(500+100+i,rgba);
89 _colorLookupTable->GetTableValue(500-100-i, rgba);
90 rgba[3]=(double)i/(double)iMax;
91 _colorLookupTable->SetTableValue(500-100-i,rgba);
98 _colorLookupTable->GetTableValue(500+i, rgba);
100 _colorLookupTable->SetTableValue(500+i,rgba);
101 _colorLookupTable->GetTableValue(500-i, rgba);
103 _colorLookupTable->SetTableValue(500-i,rgba);
111 //EED 2018-06-8 ***********************ARDS Projet***********************************************
112 if (bbGetInputType()==1)
114 _colorLookupTable = vtkLookupTable::New();
115 if (bbGetInputRange().size()==2)
117 _colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]);
118 // _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]);
120 _colorLookupTable->SetRange(0,255);
122 _colorLookupTable->SetValueRange(0.0, 1.0); // from black to white
123 _colorLookupTable->SetSaturationRange(0.0, 0.0); // no color saturation
124 _colorLookupTable->SetRampToLinear();
125 _colorLookupTable->Build();
127 _colorLookupTable->GetTableValue(0,rgba);
129 _colorLookupTable->SetTableValue(0,rgba);
138 std::vector<double>colorRGB;
139 _colorLookupTable->GetColor( bbGetInputScalarValue() , rgb );
140 colorRGB.push_back( rgb[0] );
141 colorRGB.push_back( rgb[1] );
142 colorRGB.push_back( rgb[2] );
143 bbSetOutputColor( colorRGB );
144 bbSetOutputLookupTable(_colorLookupTable);
146 printf("EED ScalarsToColors::Process End\n");
150 // 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)
152 void ScalarsToColors::bbUserSetDefaultValues()
155 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
156 // Here we initialize the input 'In' to 0
158 std::vector<double>range;
159 range.push_back( 0 );
160 range.push_back( 1 );
161 bbSetInputRange(range);
162 bbSetInputScalarValue(0);
165 _colorLookupTable=NULL;
168 // 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)
170 void ScalarsToColors::bbUserInitializeProcessing()
173 // THE INITIALIZATION METHOD BODY :
175 // but this is where you should allocate the internal/output pointers
181 // 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)
183 void ScalarsToColors::bbUserFinalizeProcessing()
186 // THE FINALIZATION METHOD BODY :
188 // but this is where you should desallocate the internal/output pointers
193 // EO namespace bbcreaVtk