]> Creatis software - creaMaracasVisu.git/blob - lib/Kernel/VTKObjects/VolumeRenderer/volumerenderermanager.h
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / Kernel / VTKObjects / VolumeRenderer / volumerenderermanager.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 /*=========================================================================
27
28   Program:   wxMaracas
29   Module:    $RCSfile: volumerenderermanager.h,v $
30   Language:  C++
31   Date:      $Date: 2012/11/15 14:16:37 $
32   Version:   $Revision: 1.3 $
33
34   Copyright: (c) 2002, 2003
35   License:
36
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.
40
41 =========================================================================*/
42
43
44
45
46 #ifndef __VolumeRendererManagerH__
47 #define __VolumeRendererManagerH__
48
49 #include <iostream>
50 #include <vector>
51 #include <vtkMatrix4x4.h>
52
53 #include "volumerenderermanagerdata.h"
54
55
56 class VolumeRendererManager  {
57
58 public:
59         VolumeRendererManager();
60         ~VolumeRendererManager();
61
62         /**
63         **      Sets the renderer to manage the prop3D from the view
64         **/
65         void setRenderer(vtkRenderer*  renderer);
66
67         /**
68         **      Gets the renderer to manage the prop3D from the view
69         **/
70         vtkRenderer* getRenderer();
71
72         /**
73         **      Adds a volume
74         **/
75         int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
76
77         /**
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
86         */
87         int addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents = false);
88
89         /**
90         **      loads a prop3D from a nSTL file
91         **/
92         vtkProp3D* getVolume(std::string filename);
93
94         /**
95         **      loads a MHD file to convert it into an actor
96         **/
97         vtkImageData* getImageData(std::string filename);
98
99         /**
100         ** Gets image data asotiated with the rendering manager
101         **/
102         vtkImageData* getImageData();
103
104         /**
105         **      adds or removes an actor depending of the bool value
106         **/
107         void addRemoveActor(int propid, bool addremove) throw(char*);
108
109         /**
110         **      Check if the variables are setted correctly
111         **/
112         void checkInvariant()throw(char*);
113
114         /**
115         ** Set Volume Opacity
116         **/
117         void setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*);
118         /**
119         **      Set Volume Color
120         **/
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*);
125
126         /**
127         ** Given an id search the data in the vector
128         **/
129         VolumeRendererManagerData* getViewData(int id)throw(char*);
130
131         void changeCompositeMIPFunction(int id, int function) throw (char *);
132
133         /**
134         ** Deletes given actor
135         **/
136         void deleteActor(int volumeid)throw (char *);
137
138         /**
139         ** Updates given volume
140         **/
141         void Update(int propid);
142
143         vtkPiecewiseFunction* GetTransferFunction(int volumeid);
144         vtkColorTransferFunction* GetColorFunction(int volumeid);
145
146
147         /**
148           Changes the interpolation of the volume rendering.
149           type == 0 for linear interpolation
150           type == 1 for nearest interpolation
151           */
152         void changeInterpolationType(int type, int propid = -1);
153
154         /**
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
157          */
158         void SetLookupTable(vtkLookupTable* lookup, int id = -1);
159
160         /**
161           * @returns all the props3D in this manager
162         */
163         vector< vtkProp3D* > getProps3D();
164
165         /**
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
169           */
170         void setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid = -1);
171
172
173         void EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid = -1);
174
175         void DisableBoundingBox(int propid = -1);
176 private:
177         std::vector<VolumeRendererManagerData*> prop3Dvect;
178
179         vtkRenderer*  _renderer;
180         vtkImageData* image;
181
182         int _idCount;
183
184         /**
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
189           */
190         void GetImages(vtkImageData* img, vector<vtkImageData* >& images);
191
192         /**
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
197           */
198         void GetImageDouble(vtkImageData* img, vtkImageData* imgdouble);
199
200
201
202 };
203
204 #endif