Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Slice.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef CANONICAL_SLICE_H
27 #define CANONICAL_SLICE_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 #include "InterfaceBitMap.h"
32 
33 // -- vtk stuff
34 #include <vtkSmartPointer.h>
35 #include <vtkWindowLevelLookupTable.h>
36 #include <vtkImageMapToColors.h>
37 #include <vtkActor.h>
38 #include <vtkImageActor.h>
39 #include <vtkImageChangeInformation.h>
40 #include <vtkImageReslice.h>
41 #include <vtkMatrix4x4.h>
42 #include <vtkPolyDataMapper.h>
43 #include <vtkPlaneSource.h>
44 #include <vtkTransform.h>
45 #include <vtkPixel.h>
46 #include <vtkUnstructuredGrid.h>
47 #include <vtkDataSetMapper.h>
48 #include <vtkLine.h>
49 #include <vtkPolygon.h>
50 
51 namespace camitk
52 {
102 {
103 public:
104  /* -------------------------------------------------------------------- */
108  /* -------------------------------------------------------------------- */
109 
111  Slice(vtkSmartPointer<vtkImageData> volume, PossibleOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable=NULL);
112 
114  virtual ~Slice() {};
115 
116  /* -------------------------------------------------------------------- */
120  /* -------------------------------------------------------------------- */
121 
123  virtual vtkSmartPointer<vtkImageData> getImageData() const;
124 
126  virtual void setOriginalVolume(vtkSmartPointer<vtkImageData> img);
127 
129  virtual vtkSmartPointer<vtkImageActor> get2DImageActor() const;
130 
132  virtual vtkSmartPointer<vtkImageActor> get3DImageActor() const;
133 
134 
136  virtual vtkSmartPointer<vtkActor> getPickPlaneActor() const;
137 
139  virtual vtkSmartPointer<vtkActor> getPixelActor();
140 
144  virtual void pixelPicked(double, double, double);
145 
151 
152  void reslicedToVolumeCoords(const double ijk[3], double xyz[3]);
154  void volumeToReslicedCoords(const double xyz[3], double ijk[3]);
155 
156  virtual void updatePickPlane();
157 
159  virtual int getNumberOfSlices() const;
160 
162  virtual int getSlice() const;
163 
168  virtual void setSlice(int s);
169 
171  virtual void setSlice(double x, double y, double z);
172 
174  virtual double getRotationX() const{return currentXAngle;};
175  virtual double getRotationY() const{return currentYAngle;};
176  virtual double getRotationZ() const{return currentZAngle;};
177 
179  virtual void setRotationX(double angle);
180  virtual void setRotationY(double angle);
181  virtual void setRotationZ(double angle);
182  void applyRotation();
183 
187  virtual int getNumberOfColors() const;
188 
190  virtual void setPixelRealPosition(double, double, double);
191 
192  // TODO : put all of this into a dedicated interface
194  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
195 
197  virtual vtkSmartPointer<vtkProp> getProp(const QString &);
198 
200  virtual unsigned int getNumberOfProp() const;
201 
203  virtual vtkSmartPointer<vtkProp> getProp(unsigned int);
204 
208  virtual bool addProp(const QString &, vtkSmartPointer<vtkProp>);
209 
213  virtual bool removeProp(const QString &);
214  // END TODO
215 
216 
217 protected:
218  /* -------------------------------------------------------------------- */
222  /* -------------------------------------------------------------------- */
223 
227  void setTransformOrientation(double xCosines[3], double yCosines[3], double zCosines[3]);
228 
233  void setTransformOrigin(double resliceOrigin[3]);
234 
236  void initActors();
237 
239  void setInitialSlicerTransformation();
240 
243  void updateLocalTransformation();
244 
246  void computeReslicedDimensions();
247 
249  void setSliceOrientation(PossibleOrientation orientation);
250 
251 
252 
253 
254 private:
255  /* -------------------------------------------------------------------- */
259  /* ---------------------------------------------------------------------*/
260 
262  void init();
263 
266 
268  vtkSmartPointer<vtkImageData> originalVolume;
269 
272  int extent[6];
273 
279  int originalDimensions[3];
280 
282  int reslicedDimensions[3];
283 
285  double originalSpacing[3];
286 
288  double resliceSpacing[3];
289 
294 
296  vtkSmartPointer<vtkMatrix4x4> coordsTransform;
297 
299  vtkSmartPointer<vtkMatrix4x4> sliceCoordsTransform;
300 
302  vtkSmartPointer<vtkTransform> transformReslice2Volume;
303 
308 
310  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
311 
313  vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
314 
316  vtkSmartPointer<vtkImageActor> image3DActor;
317 
320 
321  vtkSmartPointer<vtkImageReslice> image2DReslicer;
324  vtkSmartPointer<vtkImageChangeInformation> image2DChangeInfo;
326  vtkSmartPointer<vtkImageActor> image2DActor;
336  vtkSmartPointer<vtkPlaneSource> pickPlane;
337 
339  vtkSmartPointer<vtkPolyDataMapper> pickPlaneMapper;
340 
342  vtkSmartPointer<vtkActor> pickPlaneActor;
348  void initPixelActor();
349 
360  void updatePixelActorPosition(double x, double y, double z);
361 
362 
364  vtkSmartPointer<vtkActor> pixelActor;
365 
366 };
367 
368 }
369 
370 #endif // CANONICAL_SLICE_H