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 mRayCastFunction = NULL;
65 bbSetInputColorFunction(0);
66 bbSetInputColorFunction1(0);
67 bbSetInputOpacityFunction(0);
70 void VolumeRenderer::bbUserInitializeProcessing()
73 // Create the pipeline
74 // mCast = vtkImageShiftScale::New();
75 // mCast->SetOutputScalarTypeToUnsignedChar();
76 // mCast->ClampOverflowOn();
78 // mMIP = vtkVolumeRayCastMIPFunction::New();
79 // mMIP->SetMaximizeMethodToScalarValue();
81 mRayCastFunction = vtkVolumeRayCastCompositeFunction::New();
82 mMapper = vtkVolumeRayCastMapper::New();
83 mMapper->SetVolumeRayCastFunction(mRayCastFunction);
84 mMapper->AutoAdjustSampleDistancesOn();
86 _volumeProperty = vtkVolumeProperty::New();
87 _volumeProperty->SetInterpolationTypeToLinear();
88 _volumeProperty->ShadeOn();
89 _volumeProperty->DisableGradientOpacityOn();
90 //_volumeProperty->SetColor(_ctfun);
91 //_volumeProperty->SetScalarOpacity(_tfun );
93 mVolume = vtkVolume::New();
94 mVolume->SetMapper(mMapper);
95 mVolume->SetProperty(_volumeProperty );
97 // mMapper->ScalarVisibilityOff();
98 // mMapper->ImmediateModeRenderingOn();
102 //---------------------------------------------------------------------
103 void VolumeRenderer::bbUserFinalizeProcessing()
105 if (mRayCastFunction!=NULL)
107 mRayCastFunction->Delete();
108 mRayCastFunction=NULL;
122 //---------------------------------------------------------------------
124 void VolumeRenderer::Process()
126 bool changed = false;
127 if ( bbGetInputStatus("In") != bbtk::UPTODATE )
130 //EED 2017-01-01 Migration VTK7
131 #if VTK_MAJOR_VERSION <= 5
132 mMapper->SetInput( bbGetInputIn() );
134 mMapper->SetInputData( bbGetInputIn() );
139 if ( ( bbGetInputStatus("ColorFunction") != bbtk::UPTODATE ) &&
140 ( bbGetInputColorFunction() != 0 ) )
142 mVolume->GetProperty()->SetColor( bbGetInputColorFunction() );
146 if ( ( bbGetInputStatus("ColorFunction1") != bbtk::UPTODATE ) &&
147 ( bbGetInputColorFunction1() != 0 ) )
149 mVolume->GetProperty()->SetColor( bbGetInputColorFunction1() );
153 if ( ( bbGetInputStatus("OpacityFunction") != bbtk::UPTODATE ) &&
154 ( bbGetInputOpacityFunction() != 0 ) )
156 mVolume->GetProperty()->SetScalarOpacity(bbGetInputOpacityFunction());
164 bbSetOutputOut(mVolume);