Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkOdfVtkMapper2D.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef ODFVTKMAPPER2D_H_HEADER_INCLUDED
19 #define ODFVTKMAPPER2D_H_HEADER_INCLUDED
20 
21 #include "mitkVtkMapper.h"
22 #include "vtkPropAssembly.h"
23 #include "vtkAppendPolyData.h"
24 #include "vtkActor.h"
25 #include "vtkPolyDataMapper.h"
26 #include "vtkPlane.h"
27 #include "vtkCutter.h"
28 #include "vtkClipPolyData.h"
29 #include "vtkTransform.h"
30 #include "vtkDataArrayTemplate.h"
31 #include "vtkSmartPointer.h"
32 #include "vtkOdfSource.h"
33 #include "vtkThickPlane.h"
34 
35 namespace mitk {
36 
37 //##Documentation
38 //## @brief Mapper for spherical object densitiy function representations
39 //##
40 template<class TPixelType, int NrOdfDirections>
41 class OdfVtkMapper2D : public VtkMapper
42 {
43  struct OdfDisplayGeometry {
44  double vp[ 3 ], vnormal[ 3 ];
45  Vector3D normal;
46  double d, d1, d2;
47  mitk::Point3D M3D, L3D, O3D;
48 
49  double vp_original[ 3 ], vnormal_original[ 3 ];
50  mitk::Vector2D size, origin;
51 
52  bool Equals(OdfDisplayGeometry other)
53  {
54  return other.vp_original[0] == vp[0] &&
55  other.vp_original[1] == vp[1] &&
56  other.vp_original[2] == vp[2] &&
57  other.vnormal_original[0] == vnormal[0] &&
58  other.vnormal_original[1] == vnormal[1] &&
59  other.vnormal_original[2] == vnormal[2] &&
60  other.size[0] == size[0] &&
61  other.size[1] == size[1] &&
62  other.origin[0] == origin[0] &&
63  other.origin[1] == origin[1];
64  }
65  };
66 
67 public:
68 
70  itkFactorylessNewMacro(Self)
71  itkCloneMacro(Self)
72 
73  virtual vtkProp* GetVtkProp(mitk::BaseRenderer* renderer) override;
74  bool IsVisibleOdfs(mitk::BaseRenderer* renderer);
75  virtual void MitkRenderOverlay(mitk::BaseRenderer* renderer) override;
76  virtual void MitkRenderOpaqueGeometry(mitk::BaseRenderer* renderer) override;
77  virtual void MitkRenderTranslucentGeometry(mitk::BaseRenderer* renderer) override;
78  virtual void MitkRenderVolumetricGeometry(mitk::BaseRenderer* /*renderer*/) override{}
79 
80  OdfDisplayGeometry MeasureDisplayedGeometry(mitk::BaseRenderer* renderer);
81  double GetMinImageSpacing( int index );
82  void ApplyPropertySettings();
83  virtual void Slice(mitk::BaseRenderer* renderer, OdfDisplayGeometry dispGeo);
84  virtual int GetIndex(mitk::BaseRenderer* renderer);
85  static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false);
86  virtual void Update(mitk::BaseRenderer * renderer) override;
87  virtual void GenerateDataForRenderer(mitk::BaseRenderer* renderer) override;
88  virtual bool IsLODEnabled( BaseRenderer * /*renderer*/ ) const override { return true; }
89 
91  {
92  public:
93 
94  std::vector< vtkSmartPointer<vtkPropAssembly> > m_PropAssemblies;
95  std::vector< vtkSmartPointer<vtkAppendPolyData> > m_OdfsPlanes;
96  std::vector< vtkSmartPointer<vtkActor> > m_OdfsActors;
97  std::vector< vtkSmartPointer<vtkPolyDataMapper> > m_OdfsMappers;
98  vtkSmartPointer< vtkPolyData > m_TemplateOdf;
99 
100  itk::TimeStamp m_LastUpdateTime;
101 
103  LocalStorage();
106  {
107  }
108  };
109 
110 protected:
111 
112  OdfVtkMapper2D();
113  virtual ~OdfVtkMapper2D();
114 
115  static void GlyphMethod(void *arg);
116  bool IsPlaneRotated(mitk::BaseRenderer* renderer);
120 
121  typedef vnl_matrix_fixed<double, 3, 3> DirectionsType;
122 
123 
124 private:
125 
126  mitk::Image* GetInput();
127 
128  static vtkSmartPointer<vtkTransform> m_OdfTransform;
129  static vtkSmartPointer<vtkOdfSource> m_OdfSource;
130  static float m_Scaling;
131  static int m_Normalization;
132  static int m_ScaleBy;
133  static float m_IndexParam1;
134  static float m_IndexParam2;
135  static vtkSmartPointer<vtkDoubleArray> m_colourScalars;
136 
137  int m_ShowMaxNumber;
138 
139  std::vector< vtkSmartPointer<vtkPlane> > m_Planes;
140  std::vector< vtkSmartPointer<vtkCutter> > m_Cutters;
141  std::vector< vtkSmartPointer<vtkThickPlane> > m_ThickPlanes1;
142  std::vector< vtkSmartPointer<vtkClipPolyData> > m_Clippers1;
143  std::vector< vtkSmartPointer<vtkThickPlane> > m_ThickPlanes2;
144  std::vector< vtkSmartPointer<vtkClipPolyData> > m_Clippers2;
145  vtkImageData* m_VtkImage ;
146  OdfDisplayGeometry m_LastDisplayGeometry;
148 };
149 
150 } // namespace mitk
151 
152 #include "mitkOdfVtkMapper2D.txx"
153 
154 #endif /* ODFVTKMAPPER2D_H_HEADER_INCLUDED */
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
OdfDisplayGeometry MeasureDisplayedGeometry(mitk::BaseRenderer *renderer)
Base class for mapper specific rendering ressources.
Definition: mitkMapper.h:200
virtual void MitkRenderOpaqueGeometry(mitk::BaseRenderer *renderer) override
Checks visibility and renders untransparent geometry.
virtual void Update(mitk::BaseRenderer *renderer) override
Calls the time step of the input data for the specified renderer and checks whether the time step is ...
vtkSmartPointer< vtkPolyData > m_TemplateOdf
~LocalStorage()
Default deconstructor of the local storage.
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
std::vector< vtkSmartPointer< vtkActor > > m_OdfsActors
bool IsVisibleOdfs(mitk::BaseRenderer *renderer)
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
static bool m_toggleTensorEllipsoidView
Mapper for spherical object densitiy function representations.
virtual void MitkRenderVolumetricGeometry(mitk::BaseRenderer *) override
Checks visibility and renders volumes.
static bool m_toggleColourisationMode
Base class of all Vtk Mappers in order to display primitives by exploiting Vtk functionality.
Definition: mitkVtkMapper.h:53
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:54
static bool m_toggleGlyphPlacementMode
vnl_matrix_fixed< double, 3, 3 > DirectionsType
virtual void MitkRenderOverlay(mitk::BaseRenderer *renderer) override
Checks visibility and renders the overlay.
LocalStorage()
Default constructor of the local storage.
virtual int GetIndex(mitk::BaseRenderer *renderer)
virtual void Slice(mitk::BaseRenderer *renderer, OdfDisplayGeometry dispGeo)
bool IsPlaneRotated(mitk::BaseRenderer *renderer)
static void GlyphMethod(void *arg)
Image class for storing images.
Definition: mitkImage.h:76
std::vector< vtkSmartPointer< vtkPolyDataMapper > > m_OdfsMappers
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
std::vector< vtkSmartPointer< vtkPropAssembly > > m_PropAssemblies
double GetMinImageSpacing(int index)
std::vector< vtkSmartPointer< vtkAppendPolyData > > m_OdfsPlanes
virtual void MitkRenderTranslucentGeometry(mitk::BaseRenderer *renderer) override
Checks visiblity and renders transparent geometry.
virtual bool IsLODEnabled(BaseRenderer *) const override
virtual ~OdfVtkMapper2D()
mitkClassMacro(OdfVtkMapper2D, VtkMapper) static Pointer New()
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66