Computer Assited Medical Intervention Tool Kit  version 3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  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 {
175  return currentXAngle;
176  };
177  virtual double getRotationY() const {
178  return currentYAngle;
179  };
180  virtual double getRotationZ() const {
181  return currentZAngle;
182  };
183 
185  virtual void setRotationX(double angle);
186  virtual void setRotationY(double angle);
187  virtual void setRotationZ(double angle);
188  void applyRotation();
189 
193  virtual int getNumberOfColors() const;
194 
196  virtual void setPixelRealPosition(double, double, double);
197 
198  // TODO : put all of this into a dedicated interface
200  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
201 
203  virtual vtkSmartPointer<vtkProp> getProp(const QString &);
204 
206  virtual unsigned int getNumberOfProp() const;
207 
209  virtual vtkSmartPointer<vtkProp> getProp(unsigned int);
210 
214  virtual bool addProp(const QString &, vtkSmartPointer<vtkProp>);
215 
219  virtual bool removeProp(const QString &);
220  // END TODO
221 
222 
223 protected:
224  /* -------------------------------------------------------------------- */
228  /* -------------------------------------------------------------------- */
229 
233  void setTransformOrientation(double xCosines[3], double yCosines[3], double zCosines[3]);
234 
239  void setTransformOrigin(double resliceOrigin[3]);
240 
242  void initActors();
243 
245  void setInitialSlicerTransformation();
246 
249  void updateLocalTransformation();
250 
252  void computeReslicedDimensions();
253 
255  void setSliceOrientation(PossibleOrientation orientation);
256 
257 
258 
259 
260 private:
261  /* -------------------------------------------------------------------- */
265  /* ---------------------------------------------------------------------*/
266 
268  void init();
269 
271  PossibleOrientation sliceOrientation;
272 
274  vtkSmartPointer<vtkImageData> originalVolume;
275 
278  int extent[6];
279 
285  int originalDimensions[3];
286 
288  int reslicedDimensions[3];
289 
291  double originalSpacing[3];
292 
294  double resliceSpacing[3];
295 
300 
302  vtkSmartPointer<vtkMatrix4x4> coordsTransform;
303 
305  vtkSmartPointer<vtkMatrix4x4> sliceCoordsTransform;
306 
308  vtkSmartPointer<vtkTransform> transformReslice2Volume;
309 
314 
316  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
317 
319  vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
320 
322  vtkSmartPointer<vtkImageActor> image3DActor;
323 
326  vtkSmartPointer<vtkImageReslice> image2DReslicer;
330  vtkSmartPointer<vtkImageChangeInformation> image2DChangeInfo;
332  vtkSmartPointer<vtkImageActor> image2DActor;
342  vtkSmartPointer<vtkPlaneSource> pickPlane;
343 
345  vtkSmartPointer<vtkPolyDataMapper> pickPlaneMapper;
346 
348  vtkSmartPointer<vtkActor> pickPlaneActor;
354  void initPixelActor();
355 
366  void updatePixelActorPosition(double x, double y, double z);
367 
368 
370  vtkSmartPointer<vtkActor> pixelActor;
371 
372 };
373 
374 }
375 
376 #endif // CANONICAL_SLICE_H