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);
43 bbGetInputImage()->GetWholeExtent(ext);
44 int maxX = ext[1]-ext[0]+1;
45 int maxY = ext[3]-ext[2]+1;
46 int maxZ = ext[5]-ext[4]+1;
51 // Generate the colors for each point based on the color map
52 colors = vtkUnsignedCharArray::New();
53 colors->SetNumberOfComponents(3);
54 colors->SetName("Colors");
56 // Create the color map
57 if (bbGetInputColorType()==1)
59 colorLookupTableWL = vtkWindowLevelLookupTable::New();
60 colorLookupTableWL->InverseVideoOn();
61 colorLookupTable = colorLookupTableWL;
63 colorLookupTable = vtkLookupTable::New();
65 colorLookupTable->SetTableRange(range[0],range[1]);
66 colorLookupTable->Build();
69 for (int iLookTable = 0; iLookTable<128; iLookTable++)
71 colorLookupTable->GetTableValue( iLookTable, rgba1);
72 colorLookupTable->GetTableValue(256-1-iLookTable, rgba2);
74 colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
75 colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
78 //EED 2018-06-8 ***********************ARDS Projet***********************************************
79 if (bbGetInputColorType()==2)
82 colorLookupTable = vtkLookupTable::New();
83 // colorLookupTable->SetNumberOfTableValues(tableSize);
84 colorLookupTable->SetTableRange(range[0],range[1]);
85 // colorLookupTable->SetTableRange(0,11);
86 colorLookupTable->Build();
89 for (unsigned int i = 0; i < tableSize; ++i)
91 colorLookupTable->SetTableValue(i,
92 vtkMath::Random(.25, 1.0),
93 vtkMath::Random(.25, 1.0),
94 vtkMath::Random(.25, 1.0),
102 for (int iLookTable = 0; iLookTable<tableSize*3; iLookTable++)
104 i=rand() % tableSize;
105 j=rand() % tableSize;
106 colorLookupTable->GetTableValue(i, rgba1);
107 colorLookupTable->GetTableValue(j, rgba2);
109 colorLookupTable->SetTableValue(j, rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
110 colorLookupTable->SetTableValue(i, rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
116 if (bbGetInputColorType()==3)
119 colorLookupTable = vtkLookupTable::New();
120 colorLookupTable->SetNumberOfTableValues(tableSize);
121 colorLookupTable->SetTableRange(6,range[1]);
122 colorLookupTable->Build();
124 colorLookupTable->SetTableValue(0, 1 ,1 ,1 ,1);
125 colorLookupTable->SetTableValue(1, 1 ,0 ,0 ,1);
126 colorLookupTable->SetTableValue(2, 0 ,1 ,0 ,1);
127 colorLookupTable->SetTableValue(3, 0 ,0 ,1 ,1);
128 colorLookupTable->SetTableValue(4, 0 ,1 ,1 ,1);
129 colorLookupTable->SetTableValue(5, 1 ,1 ,0 ,1);
130 colorLookupTable->SetTableValue(6, 1 ,0 ,1 ,1);
132 colorLookupTable->SetTableValue(7, 0.5,1 ,1 ,1);
133 colorLookupTable->SetTableValue(8, 1 ,0.5,1 ,1);
134 colorLookupTable->SetTableValue(9, 1 ,1 ,0.5,1);
136 colorLookupTable->SetTableValue(10,1 ,0.5,0.5,1);
137 colorLookupTable->SetTableValue(11,0.5,0.5,1 ,1);
146 bbGetInputMesh()->GetPointData()->SetScalars(colors);
148 if (bbGetInputColorType()==1)
150 colorLookupTableWL->SetLevel( bbGetInputColorLevel() );
151 colorLookupTableWL->SetWindow( bbGetInputColorWindow() );
154 int missingpoints = bbGetInputMesh()->GetNumberOfPoints() - colors->GetDataSize()/colors->GetNumberOfComponents();
155 for(i = 0; i < missingpoints; i++)
157 colors->InsertNextTuple3(0,0,0);
160 if (bbGetInputTransform()!=NULL)
162 bbGetInputTransform()->Update();
169 for(i = 0; i < bbGetInputMesh()->GetNumberOfPoints(); i++)
171 if (bbGetInputTransform()!=NULL)
173 bbGetInputMesh()->GetPoint(i,p1);
174 bbGetInputTransform()->TransformPoint(p1,p2);
176 bbGetInputMesh()->GetPoint(i,p2);
178 p2[0] = p2[0]/spc[0];
179 p2[1] = p2[1]/spc[1];
180 p2[2] = p2[2]/spc[2];
182 if ( (p2[0]>=0) && (p2[0]<maxX) && (p2[1]>=0) && (p2[1]<maxY) &&(p2[2]>=0) && (p2[2]<maxZ) )
184 gl = bbGetInputImage()->GetScalarComponentAsDouble(p2[0], p2[1], p2[2],0);
188 colorLookupTable->GetColor(gl, dcolor);
189 colors->SetTuple3(i,255*dcolor[0],255*dcolor[1],255*dcolor[2]);
191 bbGetInputMesh()->Modified();
195 // 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)
197 void SurfaceTexture::bbUserSetDefaultValues()
200 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
201 // Here we initialize the input 'In' to 0
202 bbSetInputMesh(NULL);
203 bbSetInputImage(NULL);
204 bbSetInputColorType(0);
205 bbSetInputColorLevel(500);
206 bbSetInputColorWindow(500);
207 bbSetInputTransform(NULL);
211 colorLookupTable = NULL;
212 colorLookupTableWL = NULL;
215 // 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)
217 void SurfaceTexture::bbUserInitializeProcessing()
220 // THE INITIALIZATION METHOD BODY :
222 // but this is where you should allocate the internal/output pointers
228 // 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)
230 void SurfaceTexture::bbUserFinalizeProcessing()
233 // THE FINALIZATION METHOD BODY :
235 // but this is where you should desallocate the internal/output pointers
240 // EO namespace bbvtk