2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbvtkVolumeRenderer.cxx,v $
32 Date: $Date: 2012/11/16 08:51:58 $
33 Version: $Revision: 1.6 $
34 =========================================================================*/
46 #include "bbvtkVolumeRenderer.h"
47 #include "bbvtkPackage.h"
53 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,VolumeRenderer)
54 BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRenderer,bbtk::AtomicBlackBox);
60 void VolumeRenderer::bbUserSetDefaultValues()
62 //EED 2017-01-01 Migration VTK7
63 #if VTK_MAJOR_VERSION <= 5
64 mRayCastFunction = NULL;
70 bbSetInputColorFunction(0);
71 bbSetInputColorFunction1(0);
72 bbSetInputOpacityFunction(0);
75 void VolumeRenderer::bbUserInitializeProcessing()
78 // Create the pipeline
79 // mCast = vtkImageShiftScale::New();
80 // mCast->SetOutputScalarTypeToUnsignedChar();
81 // mCast->ClampOverflowOn();
83 // mMIP = vtkVolumeRayCastMIPFunction::New();
84 // mMIP->SetMaximizeMethodToScalarValue();
86 //EED 2018-07-20 Migration VTK8
87 #if (VTK_MAJOR_VERSION <= 7)
88 mRayCastFunction = vtkVolumeRayCastCompositeFunction::New();
89 mMapper = vtkVolumeRayCastMapper::New();
90 mMapper->SetVolumeRayCastFunction(mRayCastFunction);
91 mMapper->AutoAdjustSampleDistancesOn();
93 mMapper = vtkFixedPointVolumeRayCastMapper::New();
96 _volumeProperty = vtkVolumeProperty::New();
97 _volumeProperty->SetInterpolationTypeToLinear();
98 _volumeProperty->ShadeOn();
99 _volumeProperty->DisableGradientOpacityOn();
100 //_volumeProperty->SetColor(_ctfun);
101 //_volumeProperty->SetScalarOpacity(_tfun );
103 mVolume = vtkVolume::New();
104 mVolume->SetMapper(mMapper);
105 mVolume->SetProperty(_volumeProperty );
107 // mMapper->ScalarVisibilityOff();
108 // mMapper->ImmediateModeRenderingOn();
112 //---------------------------------------------------------------------
113 void VolumeRenderer::bbUserFinalizeProcessing()
115 //EED 2017-01-01 Migration VTK7
116 #if VTK_MAJOR_VERSION <= 5
117 if (mRayCastFunction!=NULL)
119 mRayCastFunction->Delete();
120 mRayCastFunction=NULL;
137 //---------------------------------------------------------------------
139 void VolumeRenderer::Process()
141 bool changed = false;
142 if ( bbGetInputStatus("In") != bbtk::UPTODATE )
145 //EED 2017-01-01 Migration VTK7
146 #if VTK_MAJOR_VERSION <= 5
147 mMapper->SetInput( bbGetInputIn() );
149 mMapper->SetInputData( bbGetInputIn() );
154 if ( ( bbGetInputStatus("ColorFunction") != bbtk::UPTODATE ) &&
155 ( bbGetInputColorFunction() != 0 ) )
157 mVolume->GetProperty()->SetColor( bbGetInputColorFunction() );
161 if ( ( bbGetInputStatus("ColorFunction1") != bbtk::UPTODATE ) &&
162 ( bbGetInputColorFunction1() != 0 ) )
164 mVolume->GetProperty()->SetColor( bbGetInputColorFunction1() );
168 if ( ( bbGetInputStatus("OpacityFunction") != bbtk::UPTODATE ) &&
169 ( bbGetInputOpacityFunction() != 0 ) )
171 mVolume->GetProperty()->SetScalarOpacity(bbGetInputOpacityFunction());
179 bbSetOutputOut(mVolume);