Computer Assited Medical Intervention Tool Kit  version 5.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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
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 // disable warning generated by clang about the surrounded headers
35 #include <CamiTKDisableWarnings>
36 #include <vtkWindowLevelLookupTable.h>
37 #include <vtkActor.h>
38 #include <vtkImageActor.h>
39 #include <CamiTKReEnableWarnings>
40 
41 #include <vtkImageData.h>
42 #include <vtkTransform.h>
43 #include <vtkUnstructuredGrid.h>
44 #include <vtkImageReslice.h>
45 
46 namespace camitk {
126 class CAMITK_API Slice : public InterfaceBitMap {
127 public:
151  enum SliceOrientation {
152  AXIAL,
153  CORONAL,
154  SAGITTAL,
155  AXIAL_NEURO,
156  ARBITRARY
157  };
158 
162  Slice(vtkSmartPointer<vtkImageData> volume, SliceOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable = nullptr);
163 
165  ~Slice() override;
167 
170 
172  void setOriginalVolume(vtkSmartPointer<vtkImageData> img) override final;
173 
177  void setImageWorldTransform(vtkSmartPointer<vtkTransform>) override;
178 
180  vtkSmartPointer<vtkImageActor> get2DImageActor() const override;
181 
183  vtkSmartPointer<vtkImageActor> get3DImageActor() const override;
184 
186  vtkSmartPointer<vtkActor> getPickPlaneActor() const override;
187 
189  vtkSmartPointer<vtkActor> getPixelActor() override;
190 
194  void pixelPicked(double, double, double) override;
195 
197  void updatePickPlane() override final;
198 
200  int getNumberOfSlices() const override final;
201 
203  int getSlice() const override;
204 
209  void setSlice(int s) override final;
210 
212  void setSlice(double x, double y, double z) override;
213 
217  int getNumberOfColors() const override;
218 
220  void setPixelRealPosition(double, double, double) override;
221 
228  virtual void setArbitraryTransform(vtkSmartPointer<vtkTransform>) override;
229 
231  vtkSmartPointer<vtkImageData> getImageData() const override;
232 
233  // @}
234 
244 
246  vtkSmartPointer<vtkProp> getProp(const QString&) override;
247 
249  unsigned int getNumberOfProp() const override;
250 
252  vtkSmartPointer<vtkProp> getProp(unsigned int) override;
253 
257  bool addProp(const QString&, vtkSmartPointer<vtkProp>) override;
258 
262  bool removeProp(const QString&) override;
263 
265 
266 
267 protected:
268 
271 
273  void init();
274 
276  void initActors();
277 
282  void reslicedToVolumeCoords(const double* ijk, double* xyz);
283 
287  void volumeToReslicedCoords(const double* xyz, double* ijk);
289 
292 
294  SliceOrientation sliceOrientation;
295 
297  vtkSmartPointer<vtkImageData> originalVolume;
298 
300  int currentSliceIndex;
301 
303  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
304 
306  double originalSpacing[3];
307 
309  double originalSize[3];
310 
312  vtkSmartPointer<vtkImageActor> image3DActor;
313 
315  vtkSmartPointer<vtkImageActor> image2DActor;
317 
320 
322  vtkSmartPointer<vtkImageReslice> image2DReslicer;
323 
325 
328 
330  void initPickPlaneActor();
331 
335  void initPixelActor();
336 
347  void updatePixelActor(double x, double y, double z);
348 
350  void updatePixelActor();
351 
353  vtkSmartPointer<vtkActor> pickPlaneActor;
354 
356  vtkSmartPointer<vtkUnstructuredGrid> pickPlaneActorPointSet;
357 
359  vtkSmartPointer<vtkActor> pixelActor;
360 
362  vtkSmartPointer<vtkUnstructuredGrid> pixelActorPointSet;
364 
368 
370  QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
371 
373 };
374 
375 }
376 
377 #endif // CANONICAL_SLICE_H
378 
camitk::Slice::getNumberOfColors
int getNumberOfColors() const override
Return the number of colors in the images.
Definition: Slice.cpp:273
camitk::Slice::reslicedToVolumeCoords
void reslicedToVolumeCoords(const double *ijk, double *xyz)
Compute the volume coordinates (xyz) from the resliced coordinates (ijk)
Definition: Slice.cpp:154
camitk::Slice::setSlice
void setSlice(int s) override final
Set the current slice index.
Definition: Slice.cpp:200
CamiTKAPI.h
camitk::Slice::getSlice
int getSlice() const override
Return the index of the current displayed slice.
Definition: Slice.cpp:195
InterfaceBitMap.h
camitk::Slice::pixelPicked
void pixelPicked(double, double, double) override
This method is called when the associated plane has been picked in the InteractiveViewer,...
Definition: Slice.cpp:149
camitk::Slice::pixelActorPointSet
vtkSmartPointer< vtkUnstructuredGrid > pixelActorPointSet
the pixel actor unstructured grid
Definition: Slice.h:408
camitk::Slice::volumeToReslicedCoords
void volumeToReslicedCoords(const double *xyz, double *ijk)
Compute the resliced coordinates (ijk) from the volume coordinates (xyz)
Definition: Slice.cpp:161
camitk::Slice::AXIAL
@ AXIAL
Definition: Slice.h:221
camitk::Slice::init
void init()
Initialize Attributes.
Definition: Slice.cpp:87
camitk::Slice::pixelActor
vtkSmartPointer< vtkActor > pixelActor
Actor representing a pixel, displayed over the image.
Definition: Slice.h:405
camitk::Slice::setPixelRealPosition
void setPixelRealPosition(double, double, double) override
move the pixel selection green indicator (pixelActor) to the given real position
Definition: Slice.cpp:278
camitk::Slice::get3DImageActor
vtkSmartPointer< vtkImageActor > get3DImageActor() const override
Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 3D viewers.
Definition: Slice.cpp:290
Log.h
camitk::Slice::~Slice
~Slice() override
virtual destructor
Definition: Slice.cpp:81
camitk::Slice::addProp
bool addProp(const QString &, vtkSmartPointer< vtkProp >) override
insert an additional prop, defining it by its name (default visibility = false)
Definition: Slice.cpp:676
camitk::Slice::getPickPlaneActor
vtkSmartPointer< vtkActor > getPickPlaneActor() const override
Return the vtkActor visualizing the plane of the slices.
Definition: Slice.cpp:300
camitk::Slice::pickPlaneActor
vtkSmartPointer< vtkActor > pickPlaneActor
Actor representing the pickPlane.
Definition: Slice.h:399
camitk::Slice::initActors
void initActors()
Initialize actors and everything they need.
Definition: Slice.cpp:305
camitk::Slice::image2DReslicer
vtkSmartPointer< vtkImageReslice > image2DReslicer
The image reslicer computes the arbitrary slice pixels.
Definition: Slice.h:368
camitk::Slice::sliceOrientation
SliceOrientation sliceOrientation
Direction of the reslice.
Definition: Slice.h:340
camitk::Slice::initPickPlaneActor
void initPickPlaneActor()
init the pick plane actor
Definition: Slice.cpp:348
camitk::Slice::originalSpacing
double originalSpacing[3]
Voxel size of the original image volume.
Definition: Slice.h:352
camitk::Slice::setArbitraryTransform
virtual void setArbitraryTransform(vtkSmartPointer< vtkTransform >) override
Set the pointer to the arbitrary slice transformation.
Definition: Slice.cpp:143
camitk::Slice::lut
vtkSmartPointer< vtkWindowLevelLookupTable > lut
Common lookup table.
Definition: Slice.h:349
camitk::Slice::getImageData
vtkSmartPointer< vtkImageData > getImageData() const override
get the current image data
Definition: Slice.cpp:105
camitk::Slice::updatePixelActor
void updatePixelActor()
update the pixel actor to the middle of the current slice
Definition: Slice.cpp:580
camitk::addProp
addProp(axes)
camitk::Slice::currentSliceIndex
int currentSliceIndex
Keep track of the slice number.
Definition: Slice.h:346
camitk::Slice::pickPlaneActorPointSet
vtkSmartPointer< vtkUnstructuredGrid > pickPlaneActorPointSet
the pick plane actor unstructured grid
Definition: Slice.h:402
camitk::transform
vtkSmartPointer< vtkTransform > transform
Definition: RendererWidget.cpp:372
camitk::Slice::CORONAL
@ CORONAL
Definition: Slice.h:222
camitk::Slice::getNumberOfSlices
int getNumberOfSlices() const override final
Return the number of slices in the image data set.
Definition: Slice.cpp:168
camitk::Slice::ARBITRARY
@ ARBITRARY
Definition: Slice.h:225
camitk::Slice::updatePickPlane
void updatePickPlane() override final
update the position of the plane surrounding the currently selected slice
Definition: Slice.cpp:506
camitk::Slice::originalVolume
vtkSmartPointer< vtkImageData > originalVolume
Smart pointer to the original volume to reslice (input of the vtk pipeline)
Definition: Slice.h:343
camitk::Slice::getNumberOfProp
unsigned int getNumberOfProp() const override
return the number of additional prop
Definition: Slice.cpp:697
camitk::Slice::getProp
vtkSmartPointer< vtkProp > getProp(const QString &) override
Return the vtkProp (actors, volumes and annotations) corresponding to the given name.
Definition: Slice.cpp:687
camitk::removeProp
void removeProp(vtkSmartPointer< vtkProp > p, bool refresh=false)
remove the given vtkProp (e.g.
camitk::Slice::get2DImageActor
vtkSmartPointer< vtkImageActor > get2DImageActor() const override
Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 2D viewers.
Definition: Slice.cpp:285
camitk::Slice::SAGITTAL
@ SAGITTAL
Definition: Slice.h:223
camitk::Slice::setImageWorldTransform
void setImageWorldTransform(vtkSmartPointer< vtkTransform >) override
set the transformation for 3D image representation This is the transformation relative to the world.
Definition: Slice.cpp:137
camitk::Slice::setOriginalVolume
void setOriginalVolume(vtkSmartPointer< vtkImageData > img) override final
set the original volume image data (the source vtkImageData before any reslice) and refresh the vtk p...
Definition: Slice.cpp:110
camitk::Slice::getPixelActor
vtkSmartPointer< vtkActor > getPixelActor() override
Return the vtkActor visualizing the picked pixels in the slices.
Definition: Slice.cpp:295
camitk::Slice::AXIAL_NEURO
@ AXIAL_NEURO
Definition: Slice.h:224
camitk::Slice::extraProp
QMap< QString, vtkSmartPointer< vtkProp > > extraProp
The additional map for prop.
Definition: Slice.h:416
camitk::Slice::SliceOrientation
SliceOrientation
Common slices orientation: axial, sagittal, coronal axial_neuro.
Definition: Slice.h:197
camitk::Slice::image3DActor
vtkSmartPointer< vtkImageActor > image3DActor
3D actor
Definition: Slice.h:358
camitk::Slice::removeProp
bool removeProp(const QString &) override
remove a given additional prop.
Definition: Slice.cpp:707
Slice.h
camitk::Slice::image2DActor
vtkSmartPointer< vtkImageActor > image2DActor
2D actor
Definition: Slice.h:361
camitk::Slice::initPixelActor
void initPixelActor()
Init the pixel actor for pixel picking.
Definition: Slice.cpp:434
camitk::Slice::Slice
Slice(vtkSmartPointer< vtkImageData > volume, SliceOrientation AXIAL_ORIENTATION, vtkSmartPointer< vtkWindowLevelLookupTable > lookupTable=nullptr)
Definition: Slice.cpp:72
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35
camitk::Slice::originalSize
double originalSize[3]
Real size (originalDimension * originalSpacing in x, y and z) of the original image.
Definition: Slice.h:355