7 #include "fwVtkIO/helper/TransferFunction.hpp" 9 #include <vtkLookupTable.h> 19 ::fwData::TransferFunction::csptr tf,
20 vtkSmartPointer<vtkLookupTable> lt,
21 bool allowTransparency,
25 lt->SetNumberOfTableValues( size );
26 lt->SetScaleToLinear();
28 ::fwData::TransferFunction::TFValuePairType minMax = tf->getMinMaxTFValues();
30 lt->SetTableRange( minMax.first, minMax.second );
32 double delta = ( minMax.second - minMax.first ) / (
double) (size - 1);
35 if ( allowTransparency )
37 for(
unsigned int k = 0; k < size; ++k )
39 interpolatedColor = tf->getInterpolatedColor( k*delta + minMax.first );
40 lt->SetTableValue(k, interpolatedColor.
r, interpolatedColor.
g, interpolatedColor.
b, interpolatedColor.
a);
45 for(
unsigned int k = 0; k < size; ++k )
47 interpolatedColor = tf->getInterpolatedColor( k*delta + minMax.first );
48 lt->SetTableValue(k, interpolatedColor.
r, interpolatedColor.
g, interpolatedColor.
b, 1.0);
60 vtkSmartPointer<vtkLookupTable> lt,
66 lt->Allocate( size, size );
67 lt->SetScaleToLinear();
69 lt->SetRampToLinear();
70 lt->SetTableRange( rangeMin, rangeMax );
71 lt->SetAlphaRange( 1.0, 1.0 );
72 lt->SetHueRange( 0.0, 0.0 );
73 lt->SetSaturationRange( 0.0, 0.0 );
74 lt->SetValueRange( 0.0, 1.0 );
ColorType r
red color (value [0,1])
#define SLM_TRACE_FUNC()
Trace contextual function signature.
static FWVTKIO_API void toVtkLookupTable(fwData::TransferFunction::csptr tf, vtkSmartPointer< vtkLookupTable > lt, bool allowTransparency=false, unsigned int size=256)
Convert a fwData::TransferFunction to a vtkLookupTable.
static FWVTKIO_API void toBWVtkLookupTable(double rangeMin, double rangeMax, vtkSmartPointer< vtkLookupTable > lt, unsigned int size=256)
Convert the range of an Image or a TransferFunction to a black and white vtkLookupTable.
ColorType b
blue color (value [0,1])
ColorType a
alpha (value [0,1])
ColorType g
green color (value [0,1])
Macro for deep and shallow copies.