Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVtkModel.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 #ifndef mitkVtkModel_h
18 #define mitkVtkModel_h
19 
20 #include <mitkDataNode.h>
21 #include <mitkPoint.h>
22 #include <mitkSurface.h>
23 #include <mitkVector.h>
24 #include <sofa/component/visualmodel/VisualModelImpl.h>
25 #include <sofa/helper/system/gl.h>
26 #include <vtkCellArray.h>
27 #include <vtkFloatArray.h>
28 #include <vtkPoints.h>
29 #include <vtkPolyData.h>
30 #include <vtkSmartPointer.h>
31 #include <MitkSimulationExports.h>
32 
33 class vtkOpenGLTexture;
34 class vtkRenderer;
35 
36 namespace mitk
37 {
38  class MITKSIMULATION_EXPORT VtkModel : public sofa::component::visualmodel::VisualModelImpl
39  {
40  public:
41  enum Mode
42  {
45  };
46 
47  SOFA_CLASS(VtkModel, sofa::component::visualmodel::VisualModelImpl);
48 
49  void internalDraw(const sofa::core::visual::VisualParams* vparams, bool transparent) override;
50  bool loadTextures() override;
51  void SetVtkRenderer(vtkRenderer* renderer);
52  void updateBuffers() override;
53 
54  DataNode::Pointer GetDataNode() const;
55 
56  Mode GetMode() const;
57  void SetMode(Mode mode);
58 
59  private:
60  VtkModel();
61  ~VtkModel();
62 
63  VtkModel(MyType&);
64  MyType& operator=(const MyType&);
65 
66  void CreateIndexBuffer();
67  void CreateVertexBuffer();
68  void DrawGroup(int group, bool transparent);
69  void DrawOpenGLGroup(int group, bool transparent);
70  void DrawSurfaceGroup(int group, bool transparent);
71  void DrawGroups(bool transparent);
72  void DrawNormals();
73  void InitIndexBuffer();
74  void InitVertexBuffer();
75  void UpdateIndexBuffer();
76  void UpdateVertexBuffer();
77  void ValidateBoundBuffers();
78 
79  bool m_GlewIsInitialized;
80  bool m_BuffersWereCreated;
81  size_t m_LastNumberOfVertices;
82  size_t m_LastNumberOfTriangles;
83  size_t m_LastNumberOfQuads;
84  GLuint m_VertexBuffer;
85  GLuint m_IndexBuffer;
86  std::map<unsigned int, vtkSmartPointer<vtkOpenGLTexture> > m_Textures;
87  vtkRenderer* m_VtkRenderer;
88  Mode m_Mode;
89  vtkSmartPointer<vtkPoints> m_Points;
90  vtkSmartPointer<vtkCellArray> m_Polys;
91  vtkSmartPointer<vtkFloatArray> m_Normals;
92  vtkSmartPointer<vtkFloatArray> m_TexCoords;
93  vtkSmartPointer<vtkPolyData> m_PolyData;
94  Surface::Pointer m_Surface;
95  DataNode::Pointer m_DataNode;
96  };
97 }
98 
99 #endif
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
DataCollection - Class to facilitate loading/accessing structured data.