Computer Assited Medical Intervention Tool Kit  version 4.0
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-2016 Univ. Grenoble Alpes, 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 #include <vtkTextProperty.h>
51 #include <vtkTextMapper.h>
52 #include <vtkAxesActor.h>
53 #include <vtkTransformPolyDataFilter.h>
54 
55 namespace camitk {
102 class CAMITK_API Slice : public InterfaceBitMap {
103 public:
104  /* -------------------------------------------------------------------- */
108  /* -------------------------------------------------------------------- */
109 
134  AXIAL_NEURO
135  };
136 
142  Slice(vtkSmartPointer<vtkImageData> volume, PossibleOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable=NULL);
144 
146  Slice(vtkSmartPointer<vtkImageData> volume, SliceOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable=NULL);
147 
149  virtual ~Slice();
150 
151  /* -------------------------------------------------------------------- */
155  /* -------------------------------------------------------------------- */
156 
158  virtual void setOriginalVolume(vtkSmartPointer<vtkImageData> img);
159 
161  virtual void setImageWorldTransform(vtkSmartPointer<vtkTransform>);
162 
163 
165  virtual vtkSmartPointer<vtkImageActor> get2DImageActor() const;
166 
168  virtual vtkSmartPointer<vtkImageActor> get3DImageActor() const;
169 
170 
172  virtual vtkSmartPointer<vtkActor> getPickPlaneActor() const;
173 
175  virtual vtkSmartPointer<vtkActor> getPixelActor();
176 
178  virtual vtkSmartPointer<vtkAxesActor> get2DAxesActor();
179 
183  virtual void pixelPicked(double, double, double);
184 
190  void reslicedToVolumeCoords(const double *ijk, double *xyz);
193  void volumeToReslicedCoords(const double *xyz, double *ijk);
194 
195  virtual void updatePickPlane();
196 
198  virtual int getNumberOfSlices() const;
199 
201  virtual int getSlice() const;
202 
207  virtual void setSlice(int s);
208 
210  virtual void setSlice(double x, double y, double z);
211 
215  virtual int getNumberOfColors() const;
216 
218  virtual void setPixelRealPosition(double, double, double);
219 
220 
222  // TODO CAMITK_DEPRECATED. This section list all the methods marked as deprecated. They are to be removed in CamiTK 4.0
225  virtual vtkSmartPointer<vtkImageData> getImageData()const {
226  return NULL;
227  };
230  virtual double getRotationX() const {
231  return 0.0;
232  };
235  virtual double getRotationY() const {
236  return 0.0;
237  };
240  virtual double getRotationZ() const {
241  return 0.0;
242  };
243 
246  virtual void setRotationX(double angle) {};
249  virtual void setRotationY(double angle) {};
252  virtual void setRotationZ(double angle) {};
255  void applyRotation() {};
257 
258  // TODO : put all of this into a dedicated interface
260  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
261 
263  virtual vtkSmartPointer<vtkProp> getProp(const QString &);
264 
266  virtual unsigned int getNumberOfProp() const;
267 
269  virtual vtkSmartPointer<vtkProp> getProp(unsigned int);
270 
274  virtual bool addProp(const QString &, vtkSmartPointer<vtkProp>);
275 
279  virtual bool removeProp(const QString &);
280  // END TODO
281 
282 
283 protected:
284  /* -------------------------------------------------------------------- */
288  /* -------------------------------------------------------------------- */
289 
291  virtual void init();
292 
294  virtual void initActors();
295 
296 
298  // TODO CAMITK_DEPRECATED. This section list all the methods marked as deprecated. They are to be removed in CamiTK 4.0
302  void setSliceOrientation(PossibleOrientation orientation);
303 
306  void setInitialSlicerTransformation() {};
307 
311  void updateLocalTransformation() {};
312 
315  void computeReslicedDimensions() {};
316 
322  void setTransformOrientation(double *xCosines, double *yCosines, double *zCosines);
323 
330  void setTransformOrigin(double *resliceOrigin);
331 
333 
334 
335  /* -------------------------------------------------------------------- */
339  /* ---------------------------------------------------------------------*/
340 
343 
345  vtkSmartPointer<vtkImageData> originalVolume;
346 
349  int extent[6];
350 
353 
355  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
356 
358  int originalDimensions[3];
359 
361  double originalSpacing[3];
362 
364  double originalSize[3];
365 
367  vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
368 
370  vtkSmartPointer<vtkImageActor> image3DActor;
372  vtkSmartPointer<vtkImageActor> image2DActor;
382  vtkSmartPointer<vtkPlaneSource> pickPlane;
383 
385  vtkSmartPointer<vtkPolyDataMapper> pickPlaneMapper;
386 
388  vtkSmartPointer<vtkActor> pickPlaneActor;
389 
390 
394  void initPixelActor();
395 
406  void updatePixelActorPosition(double x, double y, double z);
407 
408 
410  vtkSmartPointer<vtkActor> pixelActor;
411 
412 
413  void update2DAxesActorPosition();
414  void init2DAxesActor();
415  vtkSmartPointer<vtkAxesActor> axes2DActor;
416 
417 
418 };
419 
420 }
421 
422 #endif // CANONICAL_SLICE_H
SliceOrientation
Common slices orientation: axial, sagittal, coronal axial_neuro.
Definition: Slice.h:130
SliceOrientation sliceOrientation
Direction of the reslice.
Definition: Slice.h:342
vtkSmartPointer< vtkAxesActor > axes2DActor
Definition: Slice.h:415
Definition: Slice.h:133
vtkSmartPointer< vtkPlaneSource > pickPlane
A plane used for picking.
Definition: Slice.h:382
QMap< QString, vtkSmartPointer< vtkProp > > extraProp
The additional map for prop (include at least "label" and "glyph")
Definition: Slice.h:260
vtkSmartPointer< vtkActor > pickPlaneActor
Actor representing the pickPlane.
Definition: Slice.h:388
int currentSliceIndex
Keep track of the slice number.
Definition: Slice.h:352
Display a slice (i.e.
Definition: Slice.h:102
Definition: Action.cpp:40
vtkSmartPointer< vtkImageMapToColors > imgToMapFilter
To be able to extract a slice.
Definition: Slice.h:367
#define CAMITK_API
Definition: CamiTKAPI.h:49
vtkSmartPointer< vtkImageData > originalVolume
Smart pointer to the original volume to reslice (input of the vtk pipeline)
Definition: Slice.h:345
Definition: Slice.h:131
vtkSmartPointer< vtkActor > pixelActor
Actor representing a pixel, displayed over the image.
Definition: Slice.h:410
vtkSmartPointer< vtkImageActor > image3DActor
3D actor
Definition: Slice.h:370
vtkSmartPointer< vtkWindowLevelLookupTable > lut
Common lookup table.
Definition: Slice.h:355
vtkSmartPointer< vtkImageActor > image2DActor
2D actor
Definition: Slice.h:372
vtkSmartPointer< vtkPolyDataMapper > pickPlaneMapper
Mapper of the the pickPlane.
Definition: Slice.h:385
Definition: Slice.h:132