2 /*=========================================================================
5 Module: $RCSfile: volumerenderermanager.h,v $
7 Date: $Date: 2011/10/05 16:27:04 $
8 Version: $Revision: 1.2 $
10 Copyright: (c) 2002, 2003
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
22 #ifndef __VolumeRendererManagerH__
23 #define __VolumeRendererManagerH__
27 #include <vtkMatrix4x4.h>
29 #include "volumerenderermanagerdata.h"
32 class VolumeRendererManager {
35 VolumeRendererManager();
36 ~VolumeRendererManager();
39 ** Sets the renderer to manage the prop3D from the view
41 void setRenderer(vtkRenderer* renderer);
44 ** Gets the renderer to manage the prop3D from the view
46 vtkRenderer* getRenderer();
51 int addVolume(int idTP, vtkImageData* img, std::string dataname) throw (char*);
54 * @pre The image can have one or multiple components per voxel, and volume rendering is performed seprately over the
55 three of them. If the image has multiple components and the separate components flag is set to false, then
56 the vtkImageAppendComponents is used to create a single image.
57 * @post The volume rendering is performed over the image vol
58 * @param vtkImageData* the image volume
59 * @param bool independentcomponents, if the image has multiple components, the mapper will be created either for managing
60 an rgb image plus a luminance channel (the luminance will be calculated using the luminance image filter)
61 to control the opacity or to manage the multiple components in a single image
63 int addVolume(vtkImageData* img, vtkRenderWindowInteractor* interactor, bool independentcomponents = false);
66 ** loads a prop3D from a nSTL file
68 vtkProp3D* getVolume(std::string filename);
71 ** loads a MHD file to convert it into an actor
73 vtkImageData* getImageData(std::string filename);
76 ** Gets image data asotiated with the rendering manager
78 vtkImageData* getImageData();
81 ** adds or removes an actor depending of the bool value
83 void addRemoveActor(int propid, bool addremove) throw(char*);
86 ** Check if the variables are setted correctly
88 void checkInvariant()throw(char*);
93 void setVolumeOpacity(int propid, std::vector<double> greylevel,std::vector<double> value) throw(char*);
97 void setVolumeColor(int volid, std::vector<double> greylevel,
98 std::vector<double> red,
99 std::vector<double> green,
100 std::vector<double> blue)throw(char*);
103 ** Given an id search the data in the vector
105 VolumeRendererManagerData* getViewData(int id)throw(char*);
107 void changeCompositeMIPFunction(int id, int function) throw (char *);
110 ** Deletes given actor
112 void deleteActor(int volumeid)throw (char *);
115 ** Updates given volume
117 void Update(int propid);
119 vtkPiecewiseFunction* GetTransferFunction(int volumeid);
120 vtkColorTransferFunction* GetColorFunction(int volumeid);
124 Changes the interpolation of the volume rendering.
125 type == 0 for linear interpolation
126 type == 1 for nearest interpolation
128 void changeInterpolationType(int type, int propid = -1);
131 * Set the lookuptable to the volumes in memory
132 * if the id is set then it only changes the lookup table for a specific volume
134 void SetLookupTable(vtkLookupTable* lookup, int id = -1);
137 * @returns all the props3D in this manager
139 vector< vtkProp3D* > getProps3D();
142 * @param std::vector<double> greylevel, the corresponding greylevel in the image
143 * @param std::vector<double> value, the corresponding value for the opacity
144 * @param int propid, the correspoding id, by default it applies the changes to the first volume in the array
146 void setVolumeOpacity(std::vector<double> greylevel, std::vector<double> value, int propid = -1);
149 void EnableBoundingBox(vtkRenderWindowInteractor* interactor, int propid = -1);
151 void DisableBoundingBox(int propid = -1);
153 std::vector<VolumeRendererManagerData*> prop3Dvect;
155 vtkRenderer* _renderer;
161 * @pre the image is not null and has more than one scalar component
162 * @post Each component in the image is separated to form a different image
163 * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
164 * @return vector<vtkImageData* > a vector of images, one for each component
166 void GetImages(vtkImageData* img, vector<vtkImageData* >& images);
169 * @pre the image is not null and has more than one scalar component
170 * @post Each component in the image is put in a single image
171 * @param vtkImageData* img, multiple component image i.e. an image of vectors like an rgb
172 * @return vtkImageData* double type image
174 void GetImageDouble(vtkImageData* img, vtkImageData* imgdouble);