1 /*=========================================================================
3 Module: $RCSfile: bbvtkMIPCreator.cxx,v $
5 Date: $Date: 2011/03/17 15:49:14 $
6 Version: $Revision: 1.8 $
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 * ------------------------------------------------------------------------ */
38 #include <vtkVolumeProperty.h>
39 #include <vtkPiecewiseFunction.h>
41 #include "bbvtkMIPCreator.h"
42 #include "bbvtkPackage.h"
46 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MIPCreator)
47 BBTK_BLACK_BOX_IMPLEMENTATION(MIPCreator,bbtk::AtomicBlackBox);
49 //---------------------------------------------------------------------
50 void MIPCreator::bbUserSetDefaultValues()
59 //---------------------------------------------------------------------
60 void MIPCreator::bbUserInitializeProcessing()
62 // Create the pipeline
63 mCast = vtkImageShiftScale::New();
64 mCast->SetOutputScalarTypeToUnsignedChar();
65 mCast->ClampOverflowOn();
70 //define range of values
71 vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
72 opacityTransferFunction->AddPoint( 0 , 0.0/100.0 );
73 // opacityTransferFunction->AddPoint( 85 , 2.0/100.0 );
74 // opacityTransferFunction->AddPoint( 160 , 25.0/100.0 );
75 // opacityTransferFunction->AddPoint( 210 , 50.0/100.0 );
76 opacityTransferFunction->AddPoint( 255 , 90.0/100.0 );
79 //Create a transfer function mapping scalar value to color (grey)
80 vtkPiecewiseFunction *grayTransferFunction = vtkPiecewiseFunction::New();
81 grayTransferFunction->AddSegment( 0 , 0.0 , 255 , 1.0 );
83 // Create a set of properties for mip
84 vtkVolumeProperty *mipProperty;
85 mipProperty = vtkVolumeProperty::New();
86 mipProperty->SetScalarOpacity( opacityTransferFunction );
87 mipProperty->SetColor( grayTransferFunction );
89 // mipProperty->SetInterpolationTypeToLinear();
90 mipProperty->SetInterpolationTypeToNearest();
92 // mipProperty->ShadeOff();
93 mipProperty->ShadeOn();
95 mipProperty->SetAmbient(0.9);
96 mipProperty->SetDiffuse(0.9);
97 mipProperty->SetSpecular(0.9);
100 mMIP = vtkVolumeRayCastMIPFunction::New();
101 mMIP->SetMaximizeMethodToScalarValue();
102 // mMIP->SetMaximizeMethodToOpacity();
104 mMapper = vtkVolumeRayCastMapper::New();
105 mMapper->SetVolumeRayCastFunction(mMIP);
106 mMapper->SetInput(mCast->GetOutput()); // (smoother.GetOutput())
108 mVolume = vtkVolume::New();
109 mVolume->SetMapper(mMapper);
110 mVolume->SetProperty( mipProperty );
112 // mMapper->ScalarVisibilityOff();
113 // mMapper->ImmediateModeRenderingOn();
115 bbSetOutputOut(mVolume);
118 //---------------------------------------------------------------------
119 void MIPCreator::bbUserFinalizeProcessing()
145 //---------------------------------------------------------------------
147 void MIPCreator::Process()
149 mCast->SetInput( bbGetInputIn() );
150 mCast->SetScale( bbGetInputScale() / 100.0 );
151 mCast->SetShift( -bbGetInputShift() );
155 // mVolume->GetProperty()->SetColor( bbGetInputColour()[0], bbGetInputColour()[1], bbGetInputColour()[2] );
156 // mVolume->GetProperty()->SetOpacity( bbGetInputOpacity() );