1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: volumerenderermanager.h,v $
31 Date: $Date: 2012/11/15 14:16:37 $
32 Version: $Revision: 1.3 $
34 Copyright: (c) 2002, 2003
37 This software is distributed WITHOUT ANY WARRANTY; without even
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39 PURPOSE. See the above copyright notice for more information.
41 =========================================================================*/
46 #ifndef __VolumeRendererManagerH__
47 #define __VolumeRendererManagerH__
51 #include <vtkMatrix4x4.h>
53 #include "volumerenderermanagerdata.h"
56 class VolumeRendererManager {
59 VolumeRendererManager();
60 ~VolumeRendererManager();
63 ** Sets the renderer to manage the prop3D from the view
65 void setRenderer(vtkRenderer* renderer);
68 ** Gets the renderer to manage the prop3D from the view
70 vtkRenderer* getRenderer();
75 int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
78 * @pre The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
79 three of them. If the image has multiple components and the separate components flag is set to false, then
80 the vtkImageAppendComponents is used to create a single image.
81 * @post The volume rendering is performed over the image vol
82 * @param vtkImageData* the image volume
83 * @param bool independentcomponents, if the image has multiple components, the mapper will be created either for managing
84 an rgb image plus a luminance channel (the luminance will be calculated using the luminance image filter)
85 to control the opacity or to manage the multiple components in a single image
87 int addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents = false);
90 ** loads a prop3D from a nSTL file
92 vtkProp3D* getVolume(std::string filename);
95 ** loads a MHD file to convert it into an actor
97 vtkImageData* getImageData(std::string filename);
100 ** Gets image data asotiated with the rendering manager
102 vtkImageData* getImageData();
105 ** adds or removes an actor depending of the bool value
107 void addRemoveActor(int propid, bool addremove) throw(char*);
110 ** Check if the variables are setted correctly
112 void checkInvariant()throw(char*);
115 ** Set Volume Opacity
117 void setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*);
121 void setVolumeColor(int volid, std::vector<double> greylevel,
122 std::vector<double> red,
123 std::vector<double> green,
124 std::vector<double> blue)throw(char*);
127 ** Given an id search the data in the vector
129 VolumeRendererManagerData* getViewData(int id)throw(char*);
131 void changeCompositeMIPFunction(int id, int function) throw (char *);
134 ** Deletes given actor
136 void deleteActor(int volumeid)throw (char *);
139 ** Updates given volume
141 void Update(int propid);
143 vtkPiecewiseFunction* GetTransferFunction(int volumeid);
144 vtkColorTransferFunction* GetColorFunction(int volumeid);
148 Changes the interpolation of the volume rendering.
149 type == 0 for linear interpolation
150 type == 1 for nearest interpolation
152 void changeInterpolationType(int type, int propid = -1);
155 * Set the lookuptable to the volumes in memory
156 * if the id is set then it only changes the lookup table for a specific volume
158 void SetLookupTable(vtkLookupTable* lookup, int id = -1);
161 * @returns all the props3D in this manager
163 vector< vtkProp3D* > getProps3D();
166 * @param std::vector<double> greylevel, the corresponding greylevel in the image
167 * @param std::vector<double> value, the corresponding value for the opacity
168 * @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
170 void setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid = -1);
173 void EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid = -1);
175 void DisableBoundingBox(int propid = -1);
177 std::vector<VolumeRendererManagerData*> prop3Dvect;
179 vtkRenderer* _renderer;
185 * @pre the image is not null and has more than one scalar component
186 * @post Each component in the image is separated to form a different image
187 * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
188 * @return vector<vtkImageData* > a vector of images, one for each component
190 void GetImages(vtkImageData* img, vector<vtkImageData* >& images);
193 * @pre the image is not null and has more than one scalar component
194 * @post Each component in the image is put in a single image
195 * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
196 * @return vtkImageData* double type image
198 void GetImageDouble(vtkImageData* img, vtkImageData* imgdouble);