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 "bbvtkSurfaceTexture.h"
5 #include "bbvtkPackage.h"
7 #include <vtkPointData.h>
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SurfaceTexture)
14 BBTK_BLACK_BOX_IMPLEMENTATION(SurfaceTexture,bbtk::AtomicBlackBox);
16 // 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)
18 void SurfaceTexture::Process()
21 // THE MAIN PROCESSING METHOD BODY
22 // Here we simply set the input 'In' value to the output 'Out'
23 // And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 // void bbSet{Input|Output}NAME(const TYPE&)
26 // const TYPE& bbGet{Input|Output}NAME() const
28 // * NAME is the name of the input/output
29 // (the one provided in the attribute 'name' of the tag 'input')
30 // * TYPE is the C++ type of the input/output
31 // (the one provided in the attribute 'type' of the tag 'input')
33 // bbSetOutputOut( bbGetInputIn() );
34 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
41 bbGetInputImage()->GetSpacing(spc);
42 bbGetInputImage()->GetScalarRange(range);
44 //EED 2017-01-01 Migration VTK7
45 #if VTK_MAJOR_VERSION <= 5
46 bbGetInputImage()->GetWholeExtent(ext);
48 bbGetInputImage()->GetExtent(ext);
51 int maxX = ext[1]-ext[0]+1;
52 int maxY = ext[3]-ext[2]+1;
53 int maxZ = ext[5]-ext[4]+1;
58 // Generate the colors for each point based on the color map
59 colors = vtkUnsignedCharArray::New();
60 colors->SetNumberOfComponents(3);
61 colors->SetName("Colors");
63 // Create the color map
64 if (bbGetInputColorType()==1)
66 colorLookupTableWL = vtkWindowLevelLookupTable::New();
67 colorLookupTableWL->InverseVideoOn();
68 colorLookupTable = colorLookupTableWL;
70 colorLookupTable = vtkLookupTable::New();
72 colorLookupTable->SetTableRange(range[0],range[1]);
73 colorLookupTable->Build();
76 for (int iLookTable = 0; iLookTable<128; iLookTable++)
78 colorLookupTable->GetTableValue( iLookTable, rgba1);
79 colorLookupTable->GetTableValue(256-1-iLookTable, rgba2);
81 colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
82 colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
85 //EED 2018-06-8 ***********************ARDS Projet***********************************************
86 if (bbGetInputColorType()==2)
89 colorLookupTable = vtkLookupTable::New();
90 // colorLookupTable->SetNumberOfTableValues(tableSize);
91 colorLookupTable->SetTableRange(range[0],range[1]);
92 // colorLookupTable->SetTableRange(0,11);
93 colorLookupTable->Build();
96 for (unsigned int i = 0; i < tableSize; ++i)
98 colorLookupTable->SetTableValue(i,
99 vtkMath::Random(.25, 1.0),
100 vtkMath::Random(.25, 1.0),
101 vtkMath::Random(.25, 1.0),
109 for (int iLookTable = 0; iLookTable<tableSize*3; iLookTable++)
111 i=rand() % tableSize;
112 j=rand() % tableSize;
113 colorLookupTable->GetTableValue(i, rgba1);
114 colorLookupTable->GetTableValue(j, rgba2);
116 colorLookupTable->SetTableValue(j, rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
117 colorLookupTable->SetTableValue(i, rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
123 if (bbGetInputColorType()==3)
126 colorLookupTable = vtkLookupTable::New();
127 colorLookupTable->SetNumberOfTableValues(tableSize);
128 colorLookupTable->SetTableRange(6,range[1]);
129 colorLookupTable->Build();
131 colorLookupTable->SetTableValue(0, 1 ,1 ,1 ,1);
132 colorLookupTable->SetTableValue(1, 1 ,0 ,0 ,1);
133 colorLookupTable->SetTableValue(2, 0 ,1 ,0 ,1);
134 colorLookupTable->SetTableValue(3, 0 ,0 ,1 ,1);
135 colorLookupTable->SetTableValue(4, 0 ,1 ,1 ,1);
136 colorLookupTable->SetTableValue(5, 1 ,1 ,0 ,1);
137 colorLookupTable->SetTableValue(6, 1 ,0 ,1 ,1);
139 colorLookupTable->SetTableValue(7, 0.5,1 ,1 ,1);
140 colorLookupTable->SetTableValue(8, 1 ,0.5,1 ,1);
141 colorLookupTable->SetTableValue(9, 1 ,1 ,0.5,1);
143 colorLookupTable->SetTableValue(10,1 ,0.5,0.5,1);
144 colorLookupTable->SetTableValue(11,0.5,0.5,1 ,1);
154 bbGetInputMesh()->GetPointData()->SetScalars(colors);
156 if (bbGetInputColorType()==1)
158 colorLookupTableWL->SetLevel( bbGetInputColorLevel() );
159 colorLookupTableWL->SetWindow( bbGetInputColorWindow() );
163 if (bbGetInputExternalLookupTable()!=NULL)
165 generalLookupTable = bbGetInputExternalLookupTable();
167 generalLookupTable = colorLookupTable;
170 int missingpoints = bbGetInputMesh()->GetNumberOfPoints() - colors->GetDataSize()/colors->GetNumberOfComponents();
171 for(i = 0; i < missingpoints; i++)
173 colors->InsertNextTuple3(0,0,0);
176 if (bbGetInputTransform()!=NULL)
178 bbGetInputTransform()->Update();
185 for(i = 0; i < bbGetInputMesh()->GetNumberOfPoints(); i++)
187 if (bbGetInputTransform()!=NULL)
189 bbGetInputMesh()->GetPoint(i,p1);
190 bbGetInputTransform()->TransformPoint(p1,p2);
192 bbGetInputMesh()->GetPoint(i,p2);
194 p2[0] = p2[0]/spc[0];
195 p2[1] = p2[1]/spc[1];
196 p2[2] = p2[2]/spc[2];
198 if ( (p2[0]>=0) && (p2[0]<maxX) && (p2[1]>=0) && (p2[1]<maxY) &&(p2[2]>=0) && (p2[2]<maxZ) )
200 gl = bbGetInputImage()->GetScalarComponentAsDouble(p2[0], p2[1], p2[2],0);
204 generalLookupTable->GetColor(gl, dcolor);
205 colors->SetTuple3(i,255*dcolor[0],255*dcolor[1],255*dcolor[2]);
207 bbGetInputMesh()->Modified();
211 // 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)
213 void SurfaceTexture::bbUserSetDefaultValues()
216 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
217 // Here we initialize the input 'In' to 0
218 bbSetInputMesh(NULL);
219 bbSetInputImage(NULL);
220 bbSetInputColorType(0);
221 bbSetInputColorLevel(500);
222 bbSetInputColorWindow(500);
223 bbSetInputTransform(NULL);
227 colorLookupTable = NULL;
228 colorLookupTableWL = NULL;
231 // 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)
233 void SurfaceTexture::bbUserInitializeProcessing()
236 // THE INITIALIZATION METHOD BODY :
238 // but this is where you should allocate the internal/output pointers
244 // 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)
246 void SurfaceTexture::bbUserFinalizeProcessing()
249 // THE FINALIZATION METHOD BODY :
251 // but this is where you should desallocate the internal/output pointers
256 // EO namespace bbvtk