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;
36 printf("EED SurfaceTexture::Process Start\n");
42 bbGetInputImage()->GetSpacing(spc);
43 bbGetInputImage()->GetScalarRange(range);
44 bbGetInputImage()->GetWholeExtent(ext);
45 int maxX = ext[1]-ext[0]+1;
46 int maxY = ext[3]-ext[2]+1;
47 int maxZ = ext[5]-ext[4]+1;
52 // Generate the colors for each point based on the color map
53 colors = vtkUnsignedCharArray::New();
54 colors->SetNumberOfComponents(3);
55 colors->SetName("Colors");
57 // Create the color map
58 if (bbGetInputColorType()==1)
60 colorLookupTableWL = vtkWindowLevelLookupTable::New();
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]);
80 bbGetInputMesh()->GetPointData()->SetScalars(colors);
82 if (bbGetInputColorType()==1)
84 colorLookupTableWL->SetLevel( bbGetInputColorLevel() );
85 colorLookupTableWL->SetWindow( bbGetInputColorWindow() );
88 int missingpoints = bbGetInputMesh()->GetNumberOfPoints() - colors->GetDataSize()/colors->GetNumberOfComponents();
89 for(i = 0; i < missingpoints; i++)
91 colors->InsertNextTuple3(0,0,0);
94 if (bbGetInputTransform()!=NULL)
96 bbGetInputTransform()->Update();
103 for(i = 0; i < bbGetInputMesh()->GetNumberOfPoints(); i++)
105 if (bbGetInputTransform()!=NULL)
107 bbGetInputMesh()->GetPoint(i,p1);
108 bbGetInputTransform()->TransformPoint(p1,p2);
110 bbGetInputMesh()->GetPoint(i,p2);
112 p2[0] = p2[0]/spc[0];
113 p2[1] = p2[1]/spc[1];
114 p2[2] = p2[2]/spc[2];
116 if ( (p2[0]>=0) && (p2[0]<maxX) && (p2[1]>=0) && (p2[1]<maxY) &&(p2[2]>=0) && (p2[2]<maxZ) )
118 gl = bbGetInputImage()->GetScalarComponentAsDouble(p2[0], p2[1], p2[2],0);
122 colorLookupTable->GetColor(gl, dcolor);
123 colors->SetTuple3(i,255*dcolor[0],255*dcolor[1],255*dcolor[2]);
125 bbGetInputMesh()->Modified();
129 // 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)
131 void SurfaceTexture::bbUserSetDefaultValues()
134 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
135 // Here we initialize the input 'In' to 0
136 bbSetInputMesh(NULL);
137 bbSetInputImage(NULL);
138 bbSetInputColorType(0);
139 bbSetInputColorLevel(500);
140 bbSetInputColorWindow(500);
141 bbSetInputTransform(NULL);
145 colorLookupTable = NULL;
146 colorLookupTableWL = NULL;
149 // 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)
151 void SurfaceTexture::bbUserInitializeProcessing()
154 // THE INITIALIZATION METHOD BODY :
156 // but this is where you should allocate the internal/output pointers
162 // 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)
164 void SurfaceTexture::bbUserFinalizeProcessing()
167 // THE FINALIZATION METHOD BODY :
169 // but this is where you should desallocate the internal/output pointers
174 // EO namespace bbvtk