vision
vtkTimerCallback.hpp
1 #ifndef __VTK_TIMER_CALLBACK_HPP__
2 #define __VTK_TIMER_CALLBACK_HPP__
3 
4 #include <pcl/point_types.h>
5 #include <pcl/kdtree/kdtree_flann.h>
6 //#include <pcl/surface/mls.h> // too slow
7 #include <pcl/ModelCoefficients.h>
8 #include <pcl/filters/extract_indices.h>
9 #include <pcl/filters/filter.h>
10 #include <pcl/filters/voxel_grid.h>
11 #include <pcl/features/normal_3d.h>
12 #include <pcl/io/pcd_io.h>
13 //#include <pcl/io/ply_io.h> // for file writer
14 #include <pcl/io/openni_grabber.h>
15 #include <pcl/kdtree/kdtree.h>
16 #include <pcl/sample_consensus/method_types.h>
17 #include <pcl/sample_consensus/model_types.h>
18 #include <pcl/segmentation/sac_segmentation.h>
19 #include <pcl/segmentation/extract_clusters.h>
20 //#include <pcl/surface/gp3.h> // better use poisson; this leaves holes
21 #include <pcl/surface/poisson.h>
22 //#include <pcl/surface/vtk_utils.h> // worked in pcl-1.6
23 #include <pcl/surface/vtk_smoothing/vtk_utils.h> // worked in pcl-1.7
24 #include <pcl/search/impl/search.hpp> // linker errors on pcl-1.7
25 
26 #include <vtkActor.h>
27 #include <vtkAxesActor.h>
28 #include <vtkCellArray.h>
29 #include <vtkCommand.h>
30 #include <vtkLine.h>
31 #include <vtkLineSource.h>
32 #include <vtkOBBTree.h>
33 #include <vtkPoints.h>
34 #include <vtkPointData.h>
35 #include <vtkPolyData.h>
36 #include <vtkPolyDataMapper.h>
37 #include <vtkPolygon.h>
38 #include <vtkProperty.h>
39 #include <vtkRenderer.h>
40 #include <vtkRenderWindow.h>
41 #include <vtkRenderWindowInteractor.h>
42 #include <vtkSmartPointer.h>
43 #include <vtkTransform.h>
44 #include <vtkVersion.h>
45 
46 #include "SharedArea.hpp"
47 
48 namespace roboticslab {
49 
58 class vtkTimerCallback : public vtkCommand {
59  public:
60  static vtkTimerCallback *New() {
62  // cb->TimerCount = 0;
63  return cb;
64  }
65  void init();
66  void setRenderer(vtkRenderer* _renderer);
67  void setSharedArea(SharedArea* _sharedArea);
68  void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cbCloud); // The cloud callback
69  virtual void Execute(vtkObject *caller, unsigned long eventId, void * vtkNotUsed(callData));
70 
71  private:
72  // int TimerCount;
73  // pcl::PCDWriter writer;
74 
75  vtkRenderer *renderer;
76  SharedArea* sharedArea;
77 
78  void makeLineActor(vtkActor* _lineActor);
79  vtkSmartPointer<vtkLineSource> lineSource; // Keep here: he gets updated
80  double p0[3];
81  double p1[3];
82  void updateLine();
83 
84  pcl::Grabber* interface; // the Kinect Grabber
85  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud; // The updated Kinect cloud
86  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered;
87  bool cloudInit; // true if we have received first Point Cloud
88  vtkSmartPointer<vtkPolyData> cloud_vtkPD;
89  void makeCloudActor(vtkActor* _cloudActor);
90  void updateCloud();
91  vtkSmartPointer<vtkPolyData> cloud_filtered_vtkPD;
92  void makeFilteredCloudActor(vtkActor* _filteredCloudActor);
93  void updateFilteredCloud();
94 
95  void createFilteredCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr& _outCloud);
96 
97  void removePlanes(pcl::PointCloud<pcl::PointXYZ>::Ptr& _inOutCloud);
98 
99  vtkSmartPointer<vtkActorCollection> objectActorCollection;
100 
101  void objectSegmentation(pcl::PointCloud<pcl::PointXYZ>::Ptr& _inCloud, vtkActorCollection* _actorCollection);
102 
103  // Copied from pcl_visualizer.cpp @ 36441
104  void convertPointCloudToVTKPolyData (const pcl::PointCloud<pcl::PointXYZ> &cloud,
105  vtkSmartPointer<vtkPolyData> &polydata);
106 
107 };
108 
109 } // namespace roboticslab
110 
111 #endif // __VTK_TIMER_CALLBACK_HPP__
112 
Definition: SharedArea.hpp:12
Definition: vtkTimerCallback.hpp:58
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:5