Computer Assited Medical Intervention Tool Kit  version 4.1
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-2018 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 {
103 public:
104  /* -------------------------------------------------------------------- */
108  /* -------------------------------------------------------------------- */
109 
137  ARBITRARY
138  };
139 
141  Slice(vtkSmartPointer<vtkImageData> volume, SliceOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable = nullptr);
142 
144  ~Slice() override;
145 
146  /* -------------------------------------------------------------------- */
150  /* -------------------------------------------------------------------- */
151 
153  void setOriginalVolume(vtkSmartPointer<vtkImageData> img) override;
154 
156  void setImageWorldTransform(vtkSmartPointer<vtkTransform>) override;
157 
159  vtkSmartPointer<vtkImageActor> get2DImageActor() const override;
160 
162  vtkSmartPointer<vtkImageActor> get3DImageActor() const override;
163 
165  vtkSmartPointer<vtkActor> getPickPlaneActor() const override;
166 
168  vtkSmartPointer<vtkActor> getPixelActor() override;
169 
171  virtual vtkSmartPointer<vtkAxesActor> get2DAxesActor();
172 
176  void pixelPicked(double, double, double) override;
177 
183  void reslicedToVolumeCoords(const double* ijk, double* xyz);
185 
187  void volumeToReslicedCoords(const double* xyz, double* ijk);
188 
189  void updatePickPlane() override;
190 
192  int getNumberOfSlices() const override;
193 
195  int getSlice() const override;
196 
201  void setSlice(int s) override;
202 
204  void setSlice(double x, double y, double z) override;
205 
209  int getNumberOfColors() const override;
210 
212  void setPixelRealPosition(double, double, double) override;
213 
215  vtkSmartPointer<vtkImageData> getImageData() const override;
216 
217  // BEGIN TODO : put all of this into a dedicated interface
219  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
220 
222  vtkSmartPointer<vtkProp> getProp(const QString&) override;
223 
225  unsigned int getNumberOfProp() const override;
226 
228  vtkSmartPointer<vtkProp> getProp(unsigned int) override;
229 
233  bool addProp(const QString&, vtkSmartPointer<vtkProp>) override;
234 
238  bool removeProp(const QString&) override;
239  // END TODO
240 
241 
242 protected:
243  /* -------------------------------------------------------------------- */
247  /* -------------------------------------------------------------------- */
248 
250  virtual void init();
251 
253  virtual void initActors();
254 
255  /* -------------------------------------------------------------------- */
259  /* ---------------------------------------------------------------------*/
260 
263 
265  vtkSmartPointer<vtkImageData> originalVolume;
266 
269  int extent[6];
270 
273 
275  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
276 
278  int originalDimensions[3];
279 
281  double originalSpacing[3];
282 
284  double originalSize[3];
285 
287  vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
288 
290  vtkSmartPointer<vtkImageActor> image3DActor;
291 
293  vtkSmartPointer<vtkImageActor> image2DActor;
303  vtkSmartPointer<vtkPlaneSource> pickPlane;
304 
306  vtkSmartPointer<vtkPolyDataMapper> pickPlaneMapper;
307 
309  vtkSmartPointer<vtkActor> pickPlaneActor;
310 
311 
315  void initPixelActor();
316 
327  void updatePixelActorPosition(double x, double y, double z);
328 
329 
331  vtkSmartPointer<vtkActor> pixelActor;
332 
333 
334  void update2DAxesActorPosition();
335  void init2DAxesActor();
336  vtkSmartPointer<vtkAxesActor> axes2DActor;
337 
338 
339 };
340 
341 }
342 
343 #endif // CANONICAL_SLICE_H
SliceOrientation
Common slices orientation: axial, sagittal, coronal axial_neuro.
Definition: Slice.h:132
SliceOrientation sliceOrientation
Direction of the reslice.
Definition: Slice.h:262
This class describes what are the methods to implement for a BitMap.
Definition: InterfaceBitMap.h:63
vtkSmartPointer< vtkAxesActor > axes2DActor
Definition: Slice.h:336
Definition: Slice.h:135
vtkSmartPointer< vtkPlaneSource > pickPlane
A plane used for picking.
Definition: Slice.h:303
QMap< QString, vtkSmartPointer< vtkProp > > extraProp
The additional map for prop (include at least "label" and "glyph")
Definition: Slice.h:219
vtkSmartPointer< vtkActor > pickPlaneActor
Actor representing the pickPlane.
Definition: Slice.h:309
int currentSliceIndex
Keep track of the slice number.
Definition: Slice.h:272
Display a slice (i.e.
Definition: Slice.h:102
Definition: Action.cpp:36
vtkSmartPointer< vtkImageMapToColors > imgToMapFilter
To be able to extract a slice.
Definition: Slice.h:287
#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:265
Definition: Slice.h:133
vtkSmartPointer< vtkActor > pixelActor
Actor representing a pixel, displayed over the image.
Definition: Slice.h:331
vtkSmartPointer< vtkImageActor > image3DActor
3D actor
Definition: Slice.h:290
vtkSmartPointer< vtkWindowLevelLookupTable > lut
Common lookup table.
Definition: Slice.h:275
Definition: Slice.h:136
vtkSmartPointer< vtkImageActor > image2DActor
2D actor
Definition: Slice.h:293
vtkSmartPointer< vtkPolyDataMapper > pickPlaneMapper
Mapper of the the pickPlane.
Definition: Slice.h:306
Definition: Slice.h:134