-
Notifications
You must be signed in to change notification settings - Fork 1
/
vtk_visualizer.h
83 lines (67 loc) · 2.98 KB
/
vtk_visualizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef VTK_VISUALIZER_H
#define VTK_VISUALIZER_H
#include "tendon_robot.h"
#include <vector>
#include <Eigen/Dense>
// VTK Factory initialisation (for VTK version above 6)
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkRenderingFreeType);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <QVTKOpenGLNativeWidget.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkSmartPointer.h>
#include <vtkCylinderSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkParametricSpline.h>
#include <vtkParametricFunctionSource.h>
#include <vtkLineSource.h>
#include <vtkTubeFilter.h>
#include <vtkAxesActor.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
class VtkVisualizer
{
public:
VtkVisualizer(std::vector<TendonRobot> & robots);
~VtkVisualizer();
QVTKOpenGLNativeWidget* getWidget();
bool UpdateVisualization(const std::vector<std::vector<Eigen::Matrix4d>> & allDisksPose);
bool UpdateTargetTipPose(const Eigen::Matrix4d & pose);
private:
QVTKOpenGLNativeWidget* widget;
vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow;
vtkSmartPointer<vtkRenderer> renderer;
class TACRVisual
{
public:
TACRVisual(TendonRobot & robot);
std::vector<vtkSmartPointer<vtkCylinderSource>> diskSources; // size: seg_num
std::vector<vtkSmartPointer<vtkPolyDataMapper>> diskMappers; // size: total_disk_num
std::vector<vtkSmartPointer<vtkActor>> diskActors; // size: total_disk_num
vtkSmartPointer<vtkParametricSpline> backboneSpline;
vtkSmartPointer<vtkParametricFunctionSource> backboneFunctionSource;
vtkSmartPointer<vtkTubeFilter> backboneTubeFilter;
vtkSmartPointer<vtkPolyDataMapper> backboneMapper;
vtkSmartPointer<vtkActor> backboneActor;
std::vector<std::vector< vtkSmartPointer<vtkLineSource> >> tendonLines; // size: seg_num * tendon_num
std::vector<std::vector< vtkSmartPointer<vtkTubeFilter> >> tendonTubeFilters;
std::vector<std::vector< vtkSmartPointer<vtkPolyDataMapper> >> tendonMappers;
std::vector<std::vector< vtkSmartPointer<vtkActor> >> tendonActors;
vtkSmartPointer<vtkAxesActor> baseAxes, tipAxes, targetAxes;
// Helper data stuctures to store robot property details
std::vector<unsigned> segDiskNum; // size: seg_num
std::vector<unsigned> segTendonNum;
std::vector<double> segPitchRad;
void setAxesStyle(vtkSmartPointer<vtkAxesActor> axes, double axisLength, double cylinderRadius, double coneRadius);
bool UpdateRobotVisualization(const std::vector<Eigen::Matrix4d> & robotDisksPose);
bool UpdateTargetPose(const Eigen::Matrix4d & pose);
bool SetDiskPose(vtkSmartPointer<vtkActor> actor, const Eigen::Matrix4d & pose);
bool SetAxesPose(vtkSmartPointer<vtkAxesActor> axes, const Eigen::Matrix4d & pose);
};
private:
int numRobots;
std::vector<TACRVisual> robotsVisual;
vtkSmartPointer<vtkAxesActor> originAxes;
};
#endif // VTK_VISUALIZER_H