1 /*=========================================================================
3 Module: $RCSfile: bbvtkVolumeRenderer.cxx,v $
5 Date: $Date: 2009/10/16 08:52:13 $
6 Version: $Revision: 1.5 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
41 #include "bbvtkVolumeRenderer.h"
42 #include "bbvtkPackage.h"
48 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,VolumeRenderer)
49 BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRenderer,bbtk::AtomicBlackBox);
55 void VolumeRenderer::bbUserSetDefaultValues()
57 mRayCastFunction = NULL;
60 bbSetInputColorFunction(0);
61 bbSetInputColorFunction1(0);
62 bbSetInputOpacityFunction(0);
65 void VolumeRenderer::bbUserInitializeProcessing()
68 // Create the pipeline
69 // mCast = vtkImageShiftScale::New();
70 // mCast->SetOutputScalarTypeToUnsignedChar();
71 // mCast->ClampOverflowOn();
73 // mMIP = vtkVolumeRayCastMIPFunction::New();
74 // mMIP->SetMaximizeMethodToScalarValue();
76 mRayCastFunction = vtkVolumeRayCastCompositeFunction::New();
77 mMapper = vtkVolumeRayCastMapper::New();
78 mMapper->SetVolumeRayCastFunction(mRayCastFunction);
79 mMapper->AutoAdjustSampleDistancesOn();
81 _volumeProperty = vtkVolumeProperty::New();
82 _volumeProperty->SetInterpolationTypeToLinear();
83 _volumeProperty->ShadeOn();
84 _volumeProperty->DisableGradientOpacityOn();
85 //_volumeProperty->SetColor(_ctfun);
86 //_volumeProperty->SetScalarOpacity(_tfun );
88 mVolume = vtkVolume::New();
89 mVolume->SetMapper(mMapper);
90 mVolume->SetProperty(_volumeProperty );
92 // mMapper->ScalarVisibilityOff();
93 // mMapper->ImmediateModeRenderingOn();
97 //---------------------------------------------------------------------
98 void VolumeRenderer::bbUserFinalizeProcessing()
100 if (mRayCastFunction!=NULL)
102 mRayCastFunction->Delete();
103 mRayCastFunction=NULL;
117 //---------------------------------------------------------------------
119 void VolumeRenderer::Process()
121 bool changed = false;
122 if ( bbGetInputStatus("In") != bbtk::UPTODATE )
124 mMapper->SetInput( bbGetInputIn() );
128 if ( ( bbGetInputStatus("ColorFunction") != bbtk::UPTODATE ) &&
129 ( bbGetInputColorFunction() != 0 ) )
131 mVolume->GetProperty()->SetColor( bbGetInputColorFunction() );
135 if ( ( bbGetInputStatus("ColorFunction1") != bbtk::UPTODATE ) &&
136 ( bbGetInputColorFunction1() != 0 ) )
138 mVolume->GetProperty()->SetColor( bbGetInputColorFunction1() );
142 if ( ( bbGetInputStatus("OpacityFunction") != bbtk::UPTODATE ) &&
143 ( bbGetInputOpacityFunction() != 0 ) )
145 mVolume->GetProperty()->SetScalarOpacity(bbGetInputOpacityFunction());
149 if (changed) mMapper->Update();
151 bbSetOutputOut(mVolume);