UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-05-15)
usMeshDeformation.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
38 #ifndef __usMeshDeformation_h_
39 #define __usMeshDeformation_h_
40 
41 // VISP includes
42 #include <visp3/ustk_core/usConfig.h>
43 
44 #ifdef USTK_HAVE_VTK_QT
45 
46 #include <visp3/core/vpHomogeneousMatrix.h>
47 
48 #include <visp3/ustk_gui/usViewerWidget.h>
49 
50 #include <visp3/ustk_gui/usVTKConverter.h>
51 
52 // VTK includes
53 #include <vtkArrowSource.h>
54 #include <vtkCylinderSource.h>
55 #include <vtkDataSetMapper.h>
56 #include <vtkInteractorStyleTrackballCamera.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkProperty.h>
59 #include <vtkRenderWindowInteractor.h>
60 #include <vtkSTLReader.h>
61 #include <vtkSTLWriter.h>
62 #include <vtkSmartPointer.h>
63 #include <vtkUnstructuredGrid.h>
64 
65 #include <QPaintEngine>
66 #include <QPainter>
67 
68 #include <vtkActor.h>
69 #include <vtkAxesActor.h>
70 #include <vtkPoints.h>
71 #include <vtkPolyDataMapper.h>
72 #include <vtkRenderWindow.h>
73 #include <vtkRenderer.h>
74 #include <vtkSmartPointer.h>
75 
76 // Qt includes
77 #if defined(USTK_HAVE_VTK_QT4)
78 #include <QApplication>
79 #include <QKeyEvent>
80 #include <QVTKWidget.h>
81 #include <QtGui/QGridLayout>
82 #include <QtGui/QMainWindow>
83 #include <QtGui/QPushButton>
84 #elif defined USTK_HAVE_VTK_QT5
85 #include <QApplication>
86 #include <QKeyEvent>
87 #if USTK_HAVE_VTK_VERSION < 0x090000
88 #include <QVTKWidget.h>
89 #else
90 #include <QVTKOpenGLWidget.h>
91 #endif
92 #include <QtWidgets/QGridLayout>
93 #include <QtWidgets/QMainWindow>
94 #include <QtWidgets/QPushButton>
95 #endif
96 
104 {
105  Q_OBJECT
106 public:
107  // Constructor/Destructor
108  usMeshDeformation(QWidget *parent = NULL, Qt::WindowFlags f = Qt::WindowFlags());
110 
111  void keyPressEvent(QKeyEvent *event);
112 
113  vtkPoints *getMeshPoints();
114 
115  void setMeshInScene(vtkUnstructuredGrid *mesh);
116 
117  // Catch paint events, in case we want to display some informations (writing in this widget) over the vtk scene
118  void paintEvent(QPaintEvent *event);
119 
120  void render();
121 
122 public slots:
123  void updateMeshPosition(vpHomogeneousMatrix transform);
124 
125 private:
126  // mesh polydata
127  vtkUnstructuredGrid *m_meshPolyData;
128 
129  // actor
130  vtkSmartPointer<vtkActor> m_meshActor;
131 
132  // vtk renderer
133  vtkRenderer *renderer;
134 };
135 #endif
136 #endif // __usMeshDeformation_h_
Class used to render a 3D mesh in a 3D environment.
void updateMeshPosition(vpHomogeneousMatrix transform)
void keyPressEvent(QKeyEvent *event)
usMeshDeformation(QWidget *parent=NULL, Qt::WindowFlags f=Qt::WindowFlags())
void setMeshInScene(vtkUnstructuredGrid *mesh)
vtkPoints * getMeshPoints()
void paintEvent(QPaintEvent *event)
View used to render a vtk scene in a QWidget (based on QVTKWidget for Qt4, QVTKOpenGLWidget for Qt5)