1 #include "bbcreaMaracasVisuVolumeRendering.h"
2 #include "bbcreaMaracasVisuPackage.h"
3 namespace bbcreaMaracasVisu
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,VolumeRendering)
7 BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRendering,bbtk::AtomicBlackBox);
8 void VolumeRendering::Process()
11 // THE MAIN PROCESSING METHOD BODY
12 // Here we simply set the input 'In' value to the output 'Out'
13 // And print out the output value
14 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
15 // void bbSet{Input|Output}NAME(const TYPE&)
16 // const TYPE& bbGet{Input|Output}NAME() const
18 // * NAME is the name of the input/output
19 // (the one provided in the attribute 'name' of the tag 'input')
20 // * TYPE is the C++ type of the input/output
21 // (the one provided in the attribute 'type' of the tag 'input')
24 vtkImageData* _img = bbGetInputIn();
28 _img->GetScalarRange(range);
29 double max = range[1];
30 _tfun->AddPoint(max * 0/2 , 0.0);
31 _tfun->AddPoint(max * 1/2 , 1.0);
32 _tfun->AddPoint(max * 2/2 , 1.0);
33 _ctfun->AddRGBPoint( max*0/4 , 0.0, 0.0, 0.0);
34 _ctfun->AddRGBPoint( max*1/4 , 1.0, 0.0, 0.0);
35 _ctfun->AddRGBPoint( max*2/4 , 0.0, 0.0, 1.0);
36 _ctfun->AddRGBPoint( max*3/4 , 0.0, 1.0, 0.0);
37 _ctfun->AddRGBPoint( max*4/4 , 0.0, 0.2, 0.0);
39 _volumeMapper->SetInput( _img );
41 _volumeMapper->Update();
44 bbSetOutputOut(_newvol);
50 void VolumeRendering::bbUserSetDefaultValues()
53 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
54 // Here we initialize the input 'In' to 0
59 void VolumeRendering::bbUserInitializeProcessing()
61 _tfun = vtkPiecewiseFunction::New();
62 _ctfun = vtkColorTransferFunction::New();
64 _volumePlanes = vtkPlanes::New();
65 _compositeFunction = vtkVolumeRayCastCompositeFunction::New();
66 _volumeMapper = vtkVolumeRayCastMapper::New();
67 _volumeMapper->SetVolumeRayCastFunction(_compositeFunction);
68 _volumeMapper->SetClippingPlanes( _volumePlanes );
69 _volumeMapper->AutoAdjustSampleDistancesOn();
70 _volumeProperty = vtkVolumeProperty::New();
71 _volumeProperty->SetInterpolationTypeToLinear();
72 _volumeProperty->ShadeOn();
73 _volumeProperty->DisableGradientOpacityOn();
74 _volumeProperty->SetColor(_ctfun);
75 _volumeProperty->SetScalarOpacity( _tfun );
76 _newvol = vtkVolume::New();
77 _newvol->SetMapper(_volumeMapper );
78 _newvol->SetProperty(_volumeProperty );
81 void VolumeRendering::bbUserFinalizeProcessing()
84 // THE FINALIZATION METHOD BODY :
86 // but this is where you should desallocate the internal/output pointers
91 // EO namespace bbcreaMaracasVisu