Computer Assited Medical Intervention Tool Kit  version 3.3
 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-2014 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 {
106 {
107 public:
108  /* -------------------------------------------------------------------- */
112  /* -------------------------------------------------------------------- */
113 
115  Slice(vtkSmartPointer<vtkImageData> volume, PossibleOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable=NULL);
116 
118  virtual ~Slice() {};
119 
120  /* -------------------------------------------------------------------- */
124  /* -------------------------------------------------------------------- */
125 
127  virtual vtkSmartPointer<vtkImageData> getImageData() const;
128 
130  virtual void setOriginalVolume(vtkSmartPointer<vtkImageData> img);
131 
133  virtual vtkSmartPointer<vtkImageActor> get2DImageActor() const;
134 
136  virtual vtkSmartPointer<vtkImageActor> get3DImageActor() const;
137 
138 
140  virtual vtkSmartPointer<vtkActor> getPickPlaneActor() const;
141 
143  virtual vtkSmartPointer<vtkActor> getPixelActor();
144 
148  virtual void pixelPicked(double, double, double);
149 
155  void reslicedToVolumeCoords(const double *ijk, double *xyz);
158  void volumeToReslicedCoords(const double *xyz, double *ijk);
159 
160  virtual void updatePickPlane();
161 
163  virtual int getNumberOfSlices() const;
164 
166  virtual int getSlice() const;
167 
172  virtual void setSlice(int s);
173 
175  virtual void setSlice(double x, double y, double z);
176 
178  virtual double getRotationX() const {
179  return currentXAngle;
180  };
181  virtual double getRotationY() const {
182  return currentYAngle;
183  };
184  virtual double getRotationZ() const {
185  return currentZAngle;
186  };
187 
189  virtual void setRotationX(double angle);
190  virtual void setRotationY(double angle);
191  virtual void setRotationZ(double angle);
192  void applyRotation();
193 
197  virtual int getNumberOfColors() const;
198 
200  virtual void setPixelRealPosition(double, double, double);
201 
202  // TODO : put all of this into a dedicated interface
204  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
205 
207  virtual vtkSmartPointer<vtkProp> getProp(const QString &);
208 
210  virtual unsigned int getNumberOfProp() const;
211 
213  virtual vtkSmartPointer<vtkProp> getProp(unsigned int);
214 
218  virtual bool addProp(const QString &, vtkSmartPointer<vtkProp>);
219 
223  virtual bool removeProp(const QString &);
224  // END TODO
225 
226 
227 protected:
228  /* -------------------------------------------------------------------- */
232  /* -------------------------------------------------------------------- */
233 
238  void setTransformOrientation(double *xCosines, double *yCosines, double *zCosines);
239 
245  void setTransformOrigin(double *resliceOrigin);
246 
248  void initActors();
249 
251  void setInitialSlicerTransformation();
252 
255  void updateLocalTransformation();
256 
258  void computeReslicedDimensions();
259 
261  void setSliceOrientation(PossibleOrientation orientation);
262 
263 
264 
265 
266 private:
267  /* -------------------------------------------------------------------- */
271  /* ---------------------------------------------------------------------*/
272 
274  void init();
275 
277  PossibleOrientation sliceOrientation;
278 
280  vtkSmartPointer<vtkImageData> originalVolume;
281 
284  int extent[6];
285 
291  int originalDimensions[3];
292 
294  int reslicedDimensions[3];
295 
297  double originalSpacing[3];
298 
300  double resliceSpacing[3];
301 
306 
308  vtkSmartPointer<vtkMatrix4x4> coordsTransform;
309 
311  vtkSmartPointer<vtkMatrix4x4> sliceCoordsTransform;
312 
314  vtkSmartPointer<vtkTransform> transformReslice2Volume;
315 
320 
322  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
323 
325  vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
326 
328  vtkSmartPointer<vtkImageActor> image3DActor;
329 
332  vtkSmartPointer<vtkImageReslice> image2DReslicer;
336  vtkSmartPointer<vtkImageChangeInformation> image2DChangeInfo;
338  vtkSmartPointer<vtkImageActor> image2DActor;
348  vtkSmartPointer<vtkPlaneSource> pickPlane;
349 
351  vtkSmartPointer<vtkPolyDataMapper> pickPlaneMapper;
352 
354  vtkSmartPointer<vtkActor> pickPlaneActor;
360  void initPixelActor();
361 
372  void updatePixelActorPosition(double x, double y, double z);
373 
374 
376  vtkSmartPointer<vtkActor> pixelActor;
377 
378 };
379 
380 }
381 
382 #endif // CANONICAL_SLICE_H
This class describes what are the methods to implement for a BitMap.
Definition: InterfaceBitMap.h:63
vtkSmartPointer< vtkPlaneSource > pickPlane
A plane used for picking.
Definition: Slice.h:348
virtual double getRotationY() const
Definition: Slice.h:181
QMap< QString, vtkSmartPointer< vtkProp > > extraProp
The additional map for prop (include at least "label" and "glyph".
Definition: Slice.h:204
vtkSmartPointer< vtkActor > pickPlaneActor
Actor representing the pickPlane.
Definition: Slice.h:354
vtkSmartPointer< vtkTransform > transformReslice2Volume
Transformation between the reslice volume and the original volume.
Definition: Slice.h:314
int currentSliceIndex
Keep track of the slice number.
Definition: Slice.h:319
Display a slice (i.e.
Definition: Slice.h:105
vtkSmartPointer< vtkMatrix4x4 > coordsTransform
Transform matrix between resliced and original coords.
Definition: Slice.h:308
vtkSmartPointer< vtkImageChangeInformation > image2DChangeInfo
To put the origin of the reslicer at (0, 0, 0) (mandatory to visualize 2D actor (axial, coronal or sagittal) properly in a 2D window)
Definition: Slice.h:336
virtual ~Slice()
virtual destructor
Definition: Slice.h:118
vtkSmartPointer< vtkImageMapToColors > imgToMapFilter
To be able to extract a slice.
Definition: Slice.h:325
#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:280
double currentXAngle
Angle apply to the arbitrary slice.
Definition: Slice.h:303
double currentYAngle
Definition: Slice.h:304
vtkSmartPointer< vtkActor > pixelActor
Actor representing a pixel, displayed over the image.
Definition: Slice.h:376
virtual double getRotationX() const
Return the current angle applied to the arbitrary slice.
Definition: Slice.h:178
vtkSmartPointer< vtkMatrix4x4 > sliceCoordsTransform
Transform matrix between resliced and original coords taking the slice number into account...
Definition: Slice.h:311
vtkSmartPointer< vtkImageActor > image3DActor
3D actor
Definition: Slice.h:328
PossibleOrientation sliceOrientation
Direction of the reslice.
Definition: Slice.h:277
vtkSmartPointer< vtkWindowLevelLookupTable > lut
Common lookup table.
Definition: Slice.h:322
virtual double getRotationZ() const
Definition: Slice.h:184
double currentZAngle
Definition: Slice.h:305
vtkSmartPointer< vtkImageActor > image2DActor
2D actor itself
Definition: Slice.h:338
vtkSmartPointer< vtkPolyDataMapper > pickPlaneMapper
Mapper of the the pickPlane.
Definition: Slice.h:351