NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
vtkCalibratedModelRenderingPipeline.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef vtkCalibratedModelRenderingPipeline_h
16 #define vtkCalibratedModelRenderingPipeline_h
17 
18 #include "niftkIGIExports.h"
19 
20 #include <cv.h>
21 
22 #include <mitkVector.h>
23 #include <mitkPoint.h>
24 
25 #include <vtkObject.h>
26 #include <vtkIndent.h>
27 #include <vtkSmartPointer.h>
29 #include <vtkRenderer.h>
30 #include <vtkRenderWindow.h>
31 #include <vtkPNGReader.h>
32 #include <vtkPolyDataReader.h>
33 #include <vtkPolyDataWriter.h>
34 #include <vtkPolyDataMapper.h>
35 #include <vtkProperty.h>
36 #include <vtkTransformPolyDataFilter.h>
37 #include <vtkMatrixToLinearTransform.h>
38 #include <vtkSphereSource.h>
39 #include <vtkGlyph3D.h>
40 #include <vtkWindowToImageFilter.h>
41 #include <vtkPNGWriter.h>
42 #include <vtkBMPWriter.h>
43 #include <vtkSetGet.h>
44 #include <vtkPlaneSource.h>
45 #include <vtkTexture.h>
46 #include <vtkImageFlip.h>
47 
56 class NIFTKIGI_EXPORT vtkCalibratedModelRenderingPipeline {
57 
58 public:
59 
75  const std::string& name,
76  const mitk::Point2I& windowSize,
77  const mitk::Point2I& calibratedWindowSize,
78  const std::string& leftIntrinsicsFileName,
79  const std::string& rightIntrinsicsFileName,
80  const std::string& visualisationModelFileName,
81  const std::string& rightToLeftFileName,
82  const std::string& textureFileName,
83  const std::string& trackingModelFileName,
84  const std::string& ultrasoundCalibrationMatrixFileName,
85  const std::string& ultrasoundImageFileName,
86  const float& trackingGlyphRadius
87  );
88 
90 
94  std::string GetName() const { return m_Name; }
95 
99  void SetIsRightHandCamera(const bool& isRight);
100 
104  bool GetIsRightHandCamera() const { return m_IsRightHandCamera; }
105 
109  virtual void Render();
110 
115  void DumpScreen(const std::string fileName);
116 
121  void SaveModelToWorld(const std::string& fileName);
122 
127  void SaveCameraToWorld(const std::string& fileName);
128 
134  void SetModelToWorldMatrix(const vtkMatrix4x4& modelToWorld);
135 
139  void SetModelToWorldTransform(const std::vector<float>&);
140 
145  void SetCameraToWorldMatrix(const vtkMatrix4x4& cameraToWorld);
146 
150  void SetCameraToWorldTransform(const std::vector<float>&);
151 
156  void SetWorldToCameraMatrix(const vtkMatrix4x4& worldToCamera);
157 
161  void SetWorldToCameraTransform(const std::vector<float>&);
162 
167  bool IsFacingCamera(const double normal[3]);
168 
172  void ProjectPoint(const double world[3], double imagePoint[2]);
173 
177  void ProjectToCameraSpace(const double worldPoint[3], double cameraPoint[3]);
178 
182  vtkPolyData* GetTrackingModel() const;
183 
187  vtkRenderWindow* GetRenderWindow() const;
188 
189 private:
190 
191  vtkCalibratedModelRenderingPipeline(const vtkCalibratedModelRenderingPipeline&); // Purposefully not implemented.
192  void operator=(const vtkCalibratedModelRenderingPipeline&); // Purposefully not implemented.
193 
194  void UpdateCamera();
195  void UpdateUltrasoundPlanePosition();
196  vtkSmartPointer<vtkMatrix4x4> GetTransform(const std::vector<float> &transform);
197 
198  std::string m_Name;
199 
200  bool m_UseDistortion;
201  bool m_IsRightHandCamera;
202  cv::Mat m_LeftIntrinsicMatrix;
203  cv::Mat m_LeftDistortionVector;
204  cv::Mat m_RightIntrinsicMatrix;
205  cv::Mat m_RightDistortionVector;
206 
207  vtkSmartPointer<vtkOpenGLMatrixDrivenCamera> m_Camera;
208  vtkSmartPointer<vtkMatrix4x4> m_RightToLeftMatrix;
209 
210  vtkSmartPointer<vtkMatrix4x4> m_ModelToWorldMatrix;
211  vtkSmartPointer<vtkMatrixToLinearTransform> m_ModelToWorldTransform;
212  vtkSmartPointer<vtkMatrix4x4> m_CameraToWorldMatrix;
213  vtkSmartPointer<vtkMatrix4x4> m_CameraMatrix; // combines m_CameraToWorldMatrix and m_RightToLeftMatrix if necessary.
214  vtkSmartPointer<vtkMatrix4x4> m_CameraMatrixInverted;
215 
216  vtkSmartPointer<vtkPolyDataReader> m_TrackingModelReader;
217  vtkSmartPointer<vtkSphereSource> m_SphereForGlyph;
218  vtkSmartPointer<vtkGlyph3D> m_GlyphFilter;
219  vtkSmartPointer<vtkTransformPolyDataFilter> m_TrackingModelTransformFilter;
220  vtkSmartPointer<vtkPolyDataMapper> m_TrackingModelMapper;
221  vtkSmartPointer<vtkActor> m_TrackingModelActor;
222  vtkSmartPointer<vtkPolyDataWriter> m_TrackingModelWriter;
223 
224  vtkSmartPointer<vtkPNGReader> m_TextureReader;
225  vtkSmartPointer<vtkTexture> m_Texture;
226  vtkSmartPointer<vtkPolyDataReader> m_VisualisationModelReader;
227  vtkSmartPointer<vtkTransformPolyDataFilter> m_VisualisationModelTransformFilter;
228  vtkSmartPointer<vtkPolyDataMapper> m_VisualisationModelMapper;
229  vtkSmartPointer<vtkActor> m_VisualisationModelActor;
230  vtkSmartPointer<vtkPolyDataWriter> m_VisualisationModelWriter;
231 
232  vtkSmartPointer<vtkMatrix4x4> m_UltrasoundCalibrationMatrix;
233  vtkSmartPointer<vtkMatrix4x4> m_UltrasoundTransformMatrix;
234  vtkSmartPointer<vtkPNGReader> m_UltrasoundImageReader;
235  vtkSmartPointer<vtkImageFlip> m_UltrasoundImageYAxisFlipper;
236  vtkSmartPointer<vtkPlaneSource> m_UltrasoundImagePlane;
237  vtkSmartPointer<vtkTexture> m_UltrasoundImageTexture;
238  vtkSmartPointer<vtkPolyDataMapper> m_UltrasoundImageMapper;
239  vtkSmartPointer<vtkActor> m_UltrasoundImageActor;
240 
241  vtkSmartPointer<vtkRenderer> m_Renderer;
242  vtkSmartPointer<vtkRenderWindow> m_RenderWin;
243 };
244 
245 #endif
bool GetIsRightHandCamera() const
Get the right(true)/left(false) indicator.
Definition: vtkCalibratedModelRenderingPipeline.h:104
GLuint GLenum GLenum transform
Definition: glew.h:12775
std::string GetName() const
Returns the name of this object, just used for reference.
Definition: vtkCalibratedModelRenderingPipeline.h:94
Used to quickly make test harnesses demos and research prototypes.
Definition: vtkCalibratedModelRenderingPipeline.h:56
GLuint const GLchar * name
Definition: glew.h:1798
GLsizei const GLcharARB ** string
Definition: glew.h:5194