]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkVolumeRenderer.cxx
*** empty log message ***
[bbtk.git] / packages / vtk / src / bbvtkVolumeRenderer.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbvtkVolumeRenderer.cxx,v $
4   Language:  C++
5   Date:      $Date: 2009/07/08 14:23:08 $
6   Version:   $Revision: 1.3 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief 
34  */
35
36
37
38 #ifdef _USE_VTK_
39
40
41 #include "bbvtkVolumeRenderer.h"
42 #include "bbvtkPackage.h"
43
44 namespace bbvtk
45 {
46
47
48    BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,VolumeRenderer)
49    BBTK_BLACK_BOX_IMPLEMENTATION(VolumeRenderer,bbtk::AtomicBlackBox);
50
51
52
53
54
55    void VolumeRenderer::bbUserSetDefaultValues() 
56    { 
57            mRayCastFunction = NULL;
58            mMapper                      = NULL;
59            mVolume                      = NULL;
60            bbSetInputColorFunction(0);
61            bbSetInputOpacityFunction(0);
62    }
63         
64    void VolumeRenderer::bbUserInitializeProcessing() 
65    { 
66
67     // Create the pipeline
68      //    mCast = vtkImageShiftScale::New();
69      //    mCast->SetOutputScalarTypeToUnsignedChar();
70      //    mCast->ClampOverflowOn();
71     
72     //    mMIP = vtkVolumeRayCastMIPFunction::New();
73     //    mMIP->SetMaximizeMethodToScalarValue();
74
75     mRayCastFunction = vtkVolumeRayCastCompositeFunction::New();
76     mMapper = vtkVolumeRayCastMapper::New();
77            mMapper->SetVolumeRayCastFunction(mRayCastFunction);
78     mVolume = vtkVolume::New();
79            mVolume->SetMapper(mMapper);
80
81     //  mMapper->ScalarVisibilityOff();
82     //    mMapper->ImmediateModeRenderingOn();
83
84 }
85
86         //---------------------------------------------------------------------
87    void VolumeRenderer::bbUserFinalizeProcessing() 
88    { 
89            if (mRayCastFunction!=NULL)
90            {
91                    mRayCastFunction->Delete();
92                    mRayCastFunction=NULL;
93            }      
94            if (mMapper!=NULL)
95            {
96                    mMapper->Delete();
97                    mMapper=NULL;
98            }      
99            if (mVolume!=NULL)
100            {
101                    mVolume->Delete();
102                    mVolume=NULL;
103            }      
104
105    }
106 //---------------------------------------------------------------------
107
108    void VolumeRenderer::Process()
109    {
110      bool changed = false;
111      if ( bbGetInputStatus("In") != bbtk::UPTODATE )
112        {
113          mMapper->SetInput( bbGetInputIn() );
114          changed = true;
115        }
116
117            if ( ( bbGetInputStatus("ColorFunction") != bbtk::UPTODATE ) &&
118           ( bbGetInputColorFunction() != 0 ) )
119        {
120          mVolume->GetProperty()->SetColor( bbGetInputColorFunction() );
121          changed = true;
122        }
123
124      if ( ( bbGetInputStatus("ColorFunction1") != bbtk::UPTODATE ) &&
125           ( bbGetInputColorFunction1() != 0 ) )
126        {
127          mVolume->GetProperty()->SetColor( bbGetInputColorFunction1() );
128          changed = true;
129        }
130
131      if ( ( bbGetInputStatus("OpacityFunction") != bbtk::UPTODATE ) &&
132           ( bbGetInputOpacityFunction() != 0 ) )
133        {
134          mVolume->GetProperty()->SetScalarOpacity(bbGetInputOpacityFunction());
135          changed = true;
136        }
137     
138      if (changed) mMapper->Update();
139
140          bbSetOutputOut(mVolume);
141            
142    }
143
144 }//namespace bbtk
145
146 #endif // _USE_VTK_
147