Point Cloud Library (PCL)  1.12.1-dev
pcl_visualizer.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
39 #pragma once
40 
41 // PCL includes
42 #include <pcl/correspondence.h>
43 #include <pcl/ModelCoefficients.h>
44 #include <pcl/PolygonMesh.h>
45 #include <pcl/TextureMesh.h>
46 //
47 #include <pcl/console/print.h>
48 #include <pcl/visualization/common/actor_map.h>
49 #include <pcl/visualization/common/common.h>
50 #include <pcl/visualization/point_cloud_geometry_handlers.h>
51 #include <pcl/visualization/point_cloud_color_handlers.h>
52 #include <pcl/visualization/point_picking_event.h>
53 #include <pcl/visualization/area_picking_event.h>
54 #include <pcl/visualization/interactor_style.h>
55 
56 #include <vtkOrientationMarkerWidget.h>
57 #include <vtkRenderWindowInteractor.h>
58 
59 // VTK includes
60 class vtkPolyData;
61 class vtkTextActor;
62 class vtkRenderWindow;
63 class vtkAppendPolyData;
64 class vtkRenderWindow;
65 class vtkTransform;
66 class vtkInteractorStyle;
67 class vtkLODActor;
68 class vtkProp;
69 class vtkActor;
70 class vtkDataSet;
71 class vtkUnstructuredGrid;
72 class vtkCellArray;
73 
74 namespace pcl
75 {
76  template <typename T> class PointCloud;
77  template <typename T> class PlanarPolygon;
78 
79  namespace visualization
80  {
81  namespace details
82  {
83  PCL_EXPORTS vtkIdType fillCells(std::vector<int>& lookup, const std::vector<pcl::Vertices>& vertices, vtkSmartPointer<vtkCellArray> cell_array, int max_size_of_polygon);
84  }
85 
86  /** \brief PCL Visualizer main class.
87  * \author Radu B. Rusu
88  * \ingroup visualization
89  * \note This class can NOT be used across multiple threads. Only call functions of objects of this class
90  * from the same thread that they were created in! Some methods, e.g. addPointCloud, will crash if called
91  * from other threads.
92  */
94  {
95  public:
96  using Ptr = shared_ptr<PCLVisualizer>;
97  using ConstPtr = shared_ptr<const PCLVisualizer>;
98 
102 
106 
107  /** \brief PCL Visualizer constructor.
108  * \param[in] name the window name (empty by default)
109  * \param[in] create_interactor if true (default), create an interactor, false otherwise
110  */
111  PCLVisualizer (const std::string &name = "", const bool create_interactor = true);
112 
113  /** \brief PCL Visualizer constructor. It looks through the passed argv arguments to find the "-cam *.cam" argument.
114  * If the search failed, the name for cam file is calculated with boost uuid. If there is no such file, camera is not initilalized.
115  * \param[in] argc
116  * \param[in] argv
117  * \param[in] name the window name (empty by default)
118  * \param[in] style interactor style (defaults to PCLVisualizerInteractorStyle)
119  * \param[in] create_interactor if true (default), create an interactor, false otherwise
120  */
121  PCLVisualizer (int &argc, char **argv, const std::string &name = "",
122  PCLVisualizerInteractorStyle* style = PCLVisualizerInteractorStyle::New (), const bool create_interactor = true);
123 
124  /** \brief PCL Visualizer constructor.
125  * \param[in] ren custom vtk renderer
126  * \param[in] wind custom vtk render window
127  * \param[in] create_interactor if true (default), create an interactor, false otherwise
128  */
129  PCLVisualizer (vtkSmartPointer<vtkRenderer> ren, vtkSmartPointer<vtkRenderWindow> wind, const std::string &name = "", const bool create_interactor = true);
130 
131  /** \brief PCL Visualizer constructor.
132  * \param[in] argc
133  * \param[in] argv
134  * \param[in] ren custom vtk renderer
135  * \param[in] wind custom vtk render window
136  * \param[in] style interactor style (defaults to PCLVisualizerInteractorStyle)
137  * \param[in] create_interactor if true (default), create an interactor, false otherwise
138  */
139  PCLVisualizer (int &argc, char **argv, vtkSmartPointer<vtkRenderer> ren, vtkSmartPointer<vtkRenderWindow> wind, const std::string &name = "",
141  const bool create_interactor = true);
142 
143 
144  /** \brief PCL Visualizer destructor. */
145  virtual ~PCLVisualizer ();
146 
147  /** \brief Enables/Disabled the underlying window mode to full screen.
148  * \note This might or might not work, depending on your window manager.
149  * See the VTK documentation for additional details.
150  * \param[in] mode true for full screen, false otherwise
151  */
152  void
153  setFullScreen (bool mode);
154 
155  /** \brief Set the visualizer window name.
156  * \param[in] name the name of the window
157  */
158  void
159  setWindowName (const std::string &name);
160 
161  /** \brief Enables or disable the underlying window borders.
162  * \note This might or might not work, depending on your window manager.
163  * See the VTK documentation for additional details.
164  * \param[in] mode true for borders, false otherwise
165  */
166  void
167  setWindowBorders (bool mode);
168 
169  /** \brief Register a callback std::function for keyboard events
170  * \param[in] cb a std function that will be registered as a callback for a keyboard event
171  * \return a connection object that allows to disconnect the callback function.
172  */
173  boost::signals2::connection
175 
176  /** \brief Register a callback function for keyboard events
177  * \param[in] callback the function that will be registered as a callback for a keyboard event
178  * \param[in] cookie user data that is passed to the callback
179  * \return a connection object that allows to disconnect the callback function.
180  */
181  inline boost::signals2::connection
182  registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = nullptr)
183  {
184  return (registerKeyboardCallback ([=] (const pcl::visualization::KeyboardEvent& e) { (*callback) (e, cookie); }));
185  }
186 
187  /** \brief Register a callback function for keyboard events
188  * \param[in] callback the member function that will be registered as a callback for a keyboard event
189  * \param[in] instance instance to the class that implements the callback function
190  * \param[in] cookie user data that is passed to the callback
191  * \return a connection object that allows to disconnect the callback function.
192  */
193  template<typename T> inline boost::signals2::connection
194  registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = nullptr)
195  {
196  return (registerKeyboardCallback ([=, &instance] (const pcl::visualization::KeyboardEvent& e) { (instance.*callback) (e, cookie); }));
197  }
198 
199  /** \brief Register a callback function for mouse events
200  * \param[in] cb a std function that will be registered as a callback for a mouse event
201  * \return a connection object that allows to disconnect the callback function.
202  */
203  boost::signals2::connection
204  registerMouseCallback (std::function<void (const pcl::visualization::MouseEvent&)> cb);
205 
206  /** \brief Register a callback function for mouse events
207  * \param[in] callback the function that will be registered as a callback for a mouse event
208  * \param[in] cookie user data that is passed to the callback
209  * \return a connection object that allows to disconnect the callback function.
210  */
211  inline boost::signals2::connection
212  registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = nullptr)
213  {
214  return (registerMouseCallback ([=] (const pcl::visualization::MouseEvent& e) { (*callback) (e, cookie); }));
215  }
216 
217  /** \brief Register a callback function for mouse events
218  * \param[in] callback the member function that will be registered as a callback for a mouse event
219  * \param[in] instance instance to the class that implements the callback function
220  * \param[in] cookie user data that is passed to the callback
221  * \return a connection object that allows to disconnect the callback function.
222  */
223  template<typename T> inline boost::signals2::connection
224  registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = nullptr)
225  {
226  return (registerMouseCallback ([=, &instance] (const pcl::visualization::MouseEvent& e) { (instance.*callback) (e, cookie); }));
227  }
228 
229  /** \brief Register a callback function for point picking events
230  * \param[in] cb a std function that will be registered as a callback for a point picking event
231  * \return a connection object that allows to disconnect the callback function.
232  */
233  boost::signals2::connection
235 
236  /** \brief Register a callback function for point picking events
237  * \param[in] callback the function that will be registered as a callback for a point picking event
238  * \param[in] cookie user data that is passed to the callback
239  * \return a connection object that allows to disconnect the callback function.
240  */
241  boost::signals2::connection
242  registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = nullptr);
243 
244  /** \brief Register a callback function for point picking events
245  * \param[in] callback the member function that will be registered as a callback for a point picking event
246  * \param[in] instance instance to the class that implements the callback function
247  * \param[in] cookie user data that is passed to the callback
248  * \return a connection object that allows to disconnect the callback function.
249  */
250  template<typename T> inline boost::signals2::connection
251  registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = nullptr)
252  {
253  return (registerPointPickingCallback ([=, &instance] (const pcl::visualization::PointPickingEvent& e) { (instance.*callback) (e, cookie); }));
254  }
255 
256  /** \brief Register a callback function for area picking events
257  * \param[in] cb a std function that will be registered as a callback for an area picking event
258  * \return a connection object that allows to disconnect the callback function.
259  */
260  boost::signals2::connection
262 
263  /** \brief Register a callback function for area picking events
264  * \param[in] callback the function that will be registered as a callback for an area picking event
265  * \param[in] cookie user data that is passed to the callback
266  * \return a connection object that allows to disconnect the callback function.
267  */
268  boost::signals2::connection
269  registerAreaPickingCallback (void (*callback) (const pcl::visualization::AreaPickingEvent&, void*), void* cookie = nullptr);
270 
271  /** \brief Register a callback function for area picking events
272  * \param[in] callback the member function that will be registered as a callback for an area picking event
273  * \param[in] instance instance to the class that implements the callback function
274  * \param[in] cookie user data that is passed to the callback
275  * \return a connection object that allows to disconnect the callback function.
276  */
277  template<typename T> inline boost::signals2::connection
278  registerAreaPickingCallback (void (T::*callback) (const pcl::visualization::AreaPickingEvent&, void*), T& instance, void* cookie = nullptr)
279  {
280  return (registerAreaPickingCallback ([=, &instance] (const pcl::visualization::AreaPickingEvent& e) { (instance.*callback) (e, cookie); }));
281  }
282 
283  /** \brief Spin method. Calls the interactor and runs an internal loop. */
284  void
285  spin ();
286 
287  /** \brief Spin once method. Calls the interactor and updates the screen once.
288  * \param[in] time - How long (in ms) should the visualization loop be allowed to run.
289  * \param[in] force_redraw - if false it might return without doing anything if the
290  * interactor's framerate does not require a redraw yet.
291  */
292  void
293  spinOnce (int time = 1, bool force_redraw = false);
294 
295  /** \brief Adds a widget which shows an interactive axes display for orientation
296  * \param[in] interactor - Pointer to the vtk interactor object used by the PCLVisualizer window
297  */
298  void
299  addOrientationMarkerWidgetAxes (vtkRenderWindowInteractor* interactor);
300 
301  /** \brief Disables the Orientatation Marker Widget so it is removed from the renderer */
302  void
304 
305  /** \brief Adds 3D axes describing a coordinate system to screen at 0,0,0.
306  * \param[in] scale the scale of the axes (default: 1)
307  * \param[in] id the coordinate system object id (default: reference)
308  * \param[in] viewport the view port where the 3D axes should be added (default: all)
309  */
310  void
311  addCoordinateSystem (double scale = 1.0, const std::string& id = "reference", int viewport = 0);
312 
313  /** \brief Adds 3D axes describing a coordinate system to screen at x, y, z
314  * \param[in] scale the scale of the axes (default: 1)
315  * \param[in] x the X position of the axes
316  * \param[in] y the Y position of the axes
317  * \param[in] z the Z position of the axes
318  * \param[in] id the coordinate system object id (default: reference)
319  * \param[in] viewport the view port where the 3D axes should be added (default: all)
320  */
321  void
322  addCoordinateSystem (double scale, float x, float y, float z, const std::string &id = "reference", int viewport = 0);
323 
324  /** \brief Adds 3D axes describing a coordinate system to screen at x, y, z, Roll,Pitch,Yaw
325  *
326  * \param[in] scale the scale of the axes (default: 1)
327  * \param[in] t transformation matrix
328  * \param[in] id the coordinate system object id (default: reference)
329  * \param[in] viewport the view port where the 3D axes should be added (default: all)
330  *
331  * RPY Angles
332  * Rotate the reference frame by the angle roll about axis x
333  * Rotate the reference frame by the angle pitch about axis y
334  * Rotate the reference frame by the angle yaw about axis z
335  *
336  * Description:
337  * Sets the orientation of the Prop3D. Orientation is specified as
338  * X,Y and Z rotations in that order, but they are performed as
339  * RotateZ, RotateX, and finally RotateY.
340  *
341  * All axies use right hand rule. x=red axis, y=green axis, z=blue axis
342  * z direction is point into the screen.
343  * \code
344  * z
345  * \
346  * \
347  * \
348  * -----------> x
349  * |
350  * |
351  * |
352  * |
353  * |
354  * |
355  * y
356  * \endcode
357  */
358 
359  void
360  addCoordinateSystem (double scale, const Eigen::Affine3f& t, const std::string &id = "reference", int viewport = 0);
361 
362  /** \brief Removes a previously added 3D axes (coordinate system)
363  * \param[in] id the coordinate system object id (default: reference)
364  * \param[in] viewport view port where the 3D axes should be removed from (default: all)
365  */
366  bool
367  removeCoordinateSystem (const std::string &id = "reference", int viewport = 0);
368 
369  /** \brief Removes a Point Cloud from screen, based on a given ID.
370  * \param[in] id the point cloud object id (i.e., given on \a addPointCloud)
371  * \param[in] viewport view port from where the Point Cloud should be removed (default: all)
372  * \return true if the point cloud is successfully removed and false if the point cloud is
373  * not actually displayed
374  */
375  bool
376  removePointCloud (const std::string &id = "cloud", int viewport = 0);
377 
378  /** \brief Removes a PolygonMesh from screen, based on a given ID.
379  * \param[in] id the polygon object id (i.e., given on \a addPolygonMesh)
380  * \param[in] viewport view port from where the PolygonMesh should be removed (default: all)
381  */
382  inline bool
383  removePolygonMesh (const std::string &id = "polygon", int viewport = 0)
384  {
385  // Polygon Meshes are represented internally as point clouds with special cell array structures since 1.4
386  return (removePointCloud (id, viewport));
387  }
388 
389  /** \brief Removes an added shape from screen (line, polygon, etc.), based on a given ID
390  * \note This methods also removes PolygonMesh objects and PointClouds, if they match the ID
391  * \param[in] id the shape object id (i.e., given on \a addLine etc.)
392  * \param[in] viewport view port from where the Point Cloud should be removed (default: all)
393  */
394  bool
395  removeShape (const std::string &id = "cloud", int viewport = 0);
396 
397  /** \brief Removes an added 3D text from the scene, based on a given ID
398  * \param[in] id the 3D text id (i.e., given on \a addText3D etc.)
399  * \param[in] viewport view port from where the 3D text should be removed (default: all)
400  */
401  bool
402  removeText3D (const std::string &id = "cloud", int viewport = 0);
403 
404  /** \brief Remove all point cloud data on screen from the given viewport.
405  * \param[in] viewport view port from where the clouds should be removed (default: all)
406  */
407  bool
408  removeAllPointClouds (int viewport = 0);
409 
410  /** \brief Remove all 3D shape data on screen from the given viewport.
411  * \param[in] viewport view port from where the shapes should be removed (default: all)
412  */
413  bool
414  removeAllShapes (int viewport = 0);
415 
416  /** \brief Removes all existing 3D axes (coordinate systems)
417  * \param[in] viewport view port where the 3D axes should be removed from (default: all)
418  */
419  bool
420  removeAllCoordinateSystems (int viewport = 0);
421 
422  /** \brief Set the viewport's background color.
423  * \param[in] r the red component of the RGB color
424  * \param[in] g the green component of the RGB color
425  * \param[in] b the blue component of the RGB color
426  * \param[in] viewport the view port (default: all)
427  */
428  void
429  setBackgroundColor (const double &r, const double &g, const double &b, int viewport = 0);
430 
431  /** \brief Add a text to screen
432  * \param[in] text the text to add
433  * \param[in] xpos the X position on screen where the text should be added
434  * \param[in] ypos the Y position on screen where the text should be added
435  * \param[in] id the text object id (default: equal to the "text" parameter)
436  * \param[in] viewport the view port (default: all)
437  */
438  bool
439  addText (const std::string &text,
440  int xpos, int ypos,
441  const std::string &id = "", int viewport = 0);
442 
443  /** \brief Add a text to screen
444  * \param[in] text the text to add
445  * \param[in] xpos the X position on screen where the text should be added
446  * \param[in] ypos the Y position on screen where the text should be added
447  * \param[in] r the red color value
448  * \param[in] g the green color value
449  * \param[in] b the blue color value
450  * \param[in] id the text object id (default: equal to the "text" parameter)
451  * \param[in] viewport the view port (default: all)
452  */
453  bool
454  addText (const std::string &text, int xpos, int ypos, double r, double g, double b,
455  const std::string &id = "", int viewport = 0);
456 
457  /** \brief Add a text to screen
458  * \param[in] text the text to add
459  * \param[in] xpos the X position on screen where the text should be added
460  * \param[in] ypos the Y position on screen where the text should be added
461  * \param[in] fontsize the fontsize of the text
462  * \param[in] r the red color value
463  * \param[in] g the green color value
464  * \param[in] b the blue color value
465  * \param[in] id the text object id (default: equal to the "text" parameter)
466  * \param[in] viewport the view port (default: all)
467  */
468  bool
469  addText (const std::string &text, int xpos, int ypos, int fontsize, double r, double g, double b,
470  const std::string &id = "", int viewport = 0);
471 
472 
473  /** \brief Update a text to screen
474  * \param[in] text the text to update
475  * \param[in] xpos the new X position on screen
476  * \param[in] ypos the new Y position on screen
477  * \param[in] id the text object id (default: equal to the "text" parameter)
478  */
479  bool
480  updateText (const std::string &text,
481  int xpos, int ypos,
482  const std::string &id = "");
483 
484  /** \brief Update a text to screen
485  * \param[in] text the text to update
486  * \param[in] xpos the new X position on screen
487  * \param[in] ypos the new Y position on screen
488  * \param[in] r the red color value
489  * \param[in] g the green color value
490  * \param[in] b the blue color value
491  * \param[in] id the text object id (default: equal to the "text" parameter)
492  */
493  bool
494  updateText (const std::string &text,
495  int xpos, int ypos, double r, double g, double b,
496  const std::string &id = "");
497 
498  /** \brief Update a text to screen
499  * \param[in] text the text to update
500  * \param[in] xpos the new X position on screen
501  * \param[in] ypos the new Y position on screen
502  * \param[in] fontsize the fontsize of the text
503  * \param[in] r the red color value
504  * \param[in] g the green color value
505  * \param[in] b the blue color value
506  * \param[in] id the text object id (default: equal to the "text" parameter)
507  */
508  bool
509  updateText (const std::string &text,
510  int xpos, int ypos, int fontsize, double r, double g, double b,
511  const std::string &id = "");
512 
513  /** \brief Set the pose of an existing shape.
514  *
515  * Returns false if the shape doesn't exist, true if the pose was successfully
516  * updated.
517  *
518  * \param[in] id the shape or cloud object id (i.e., given on \a addLine etc.)
519  * \param[in] pose the new pose
520  * \return false if no shape or cloud with the specified ID was found
521  */
522  bool
523  updateShapePose (const std::string &id, const Eigen::Affine3f& pose);
524 
525  /** \brief Set the pose of an existing coordinate system.
526  *
527  * Returns false if the coordinate system doesn't exist, true if the pose was successfully
528  * updated.
529  *
530  * \param[in] id the point cloud object id (i.e., given on \a addCoordinateSystem etc.)
531  * \param[in] pose the new pose
532  * \return false if no coordinate system with the specified ID was found
533  */
534  bool
535  updateCoordinateSystemPose (const std::string &id, const Eigen::Affine3f& pose);
536 
537  /** \brief Set the pose of an existing point cloud.
538  *
539  * Returns false if the point cloud doesn't exist, true if the pose was successfully
540  * updated.
541  *
542  * \param[in] id the point cloud object id (i.e., given on \a addPointCloud etc.)
543  * \param[in] pose the new pose
544  * \return false if no point cloud with the specified ID was found
545  */
546  bool
547  updatePointCloudPose (const std::string &id, const Eigen::Affine3f& pose);
548 
549  /** \brief Add a 3d text to the scene
550  * \param[in] text the text to add
551  * \param[in] position the world position where the text should be added
552  * \param[in] textScale the scale of the text to render
553  * \param[in] r the red color value
554  * \param[in] g the green color value
555  * \param[in] b the blue color value
556  * \param[in] id the text object id (default: equal to the "text" parameter)
557  * \param[in] viewport the view port (default: all)
558  */
559  template <typename PointT> bool
560  addText3D (const std::string &text,
561  const PointT &position,
562  double textScale = 1.0,
563  double r = 1.0, double g = 1.0, double b = 1.0,
564  const std::string &id = "", int viewport = 0);
565 
566  /** \brief Add a 3d text to the scene
567  * \param[in] text the text to add
568  * \param[in] position the world position where the text should be added
569  * \param[in] orientation the angles of rotation of the text around X, Y and Z axis,
570  in this order. The way the rotations are effectively done is the
571  Z-X-Y intrinsic rotations:
572  https://en.wikipedia.org/wiki/Euler_angles#Definition_by_intrinsic_rotations
573  * \param[in] textScale the scale of the text to render
574  * \param[in] r the red color value
575  * \param[in] g the green color value
576  * \param[in] b the blue color value
577  * \param[in] id the text object id (default: equal to the "text" parameter)
578  * \param[in] viewport the view port (default: all)
579  */
580  template <typename PointT> bool
581  addText3D (const std::string &text,
582  const PointT &position,
583  double orientation[3],
584  double textScale = 1.0,
585  double r = 1.0, double g = 1.0, double b = 1.0,
586  const std::string &id = "", int viewport = 0);
587 
588  /** \brief Check if the cloud, shape, or coordinate with the given id was already added to this visualizer.
589  * \param[in] id the id of the cloud, shape, or coordinate to check
590  * \return true if a cloud, shape, or coordinate with the specified id was found
591  */
592  inline bool
593  contains(const std::string &id) const
594  {
595  return (cloud_actor_map_->find (id) != cloud_actor_map_->end () ||
596  shape_actor_map_->find (id) != shape_actor_map_->end () ||
597  coordinate_actor_map_->find (id) != coordinate_actor_map_-> end());
598  }
599 
600  /** \brief Add the estimated surface normals of a Point Cloud to screen.
601  * \param[in] cloud the input point cloud dataset containing XYZ data and normals
602  * \param[in] level display only every level'th point (default: 100)
603  * \param[in] scale the normal arrow scale (default: 0.02m)
604  * \param[in] id the point cloud object id (default: cloud)
605  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
606  */
607  template <typename PointNT> bool
608  addPointCloudNormals (const typename pcl::PointCloud<PointNT>::ConstPtr &cloud,
609  int level = 100, float scale = 0.02f,
610  const std::string &id = "cloud", int viewport = 0);
611 
612  /** \brief Add the estimated surface normals of a Point Cloud to screen.
613  * \param[in] cloud the input point cloud dataset containing the XYZ data
614  * \param[in] normals the input point cloud dataset containing the normal data
615  * \param[in] level display only every level'th point (default: 100)
616  * \param[in] scale the normal arrow scale (default: 0.02m)
617  * \param[in] id the point cloud object id (default: cloud)
618  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
619  */
620  template <typename PointT, typename PointNT> bool
621  addPointCloudNormals (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
622  const typename pcl::PointCloud<PointNT>::ConstPtr &normals,
623  int level = 100, float scale = 0.02f,
624  const std::string &id = "cloud", int viewport = 0);
625 
626  /** \brief Add the estimated principal curvatures of a Point Cloud to screen.
627  * \param[in] cloud the input point cloud dataset containing the XYZ data and normals
628  * \param[in] pcs the input point cloud dataset containing the principal curvatures data
629  * \param[in] level display only every level'th point. Default: 100
630  * \param[in] scale the normal arrow scale. Default: 1.0
631  * \param[in] id the point cloud object id. Default: "cloud"
632  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
633  */
634  template <typename PointNT> bool
636  const typename pcl::PointCloud<PointNT>::ConstPtr &cloud,
638  int level = 100, float scale = 1.0f,
639  const std::string &id = "cloud", int viewport = 0);
640 
641  /** \brief Add the estimated principal curvatures of a Point Cloud to screen.
642  * \param[in] cloud the input point cloud dataset containing the XYZ data
643  * \param[in] normals the input point cloud dataset containing the normal data
644  * \param[in] pcs the input point cloud dataset containing the principal curvatures data
645  * \param[in] level display only every level'th point. Default: 100
646  * \param[in] scale the normal arrow scale. Default: 1.0
647  * \param[in] id the point cloud object id. Default: "cloud"
648  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
649  */
650  template <typename PointT, typename PointNT> bool
651  addPointCloudPrincipalCurvatures (
652  const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
653  const typename pcl::PointCloud<PointNT>::ConstPtr &normals,
655  int level = 100, float scale = 1.0f,
656  const std::string &id = "cloud", int viewport = 0);
657 
658  /** \brief Add the estimated surface intensity gradients of a Point Cloud to screen.
659  * \param[in] cloud the input point cloud dataset containing the XYZ data
660  * \param[in] gradients the input point cloud dataset containing the intensity gradient data
661  * \param[in] level display only every level'th point (default: 100)
662  * \param[in] scale the intensity gradient arrow scale (default: 1e-6m)
663  * \param[in] id the point cloud object id (default: cloud)
664  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
665  */
666  template <typename PointT, typename GradientT> bool
667  addPointCloudIntensityGradients (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
668  const typename pcl::PointCloud<GradientT>::ConstPtr &gradients,
669  int level = 100, double scale = 1e-6,
670  const std::string &id = "cloud", int viewport = 0);
671 
672  /** \brief Add a Point Cloud (templated) to screen.
673  * \param[in] cloud the input point cloud dataset
674  * \param[in] id the point cloud object id (default: cloud)
675  * \param viewport the view port where the Point Cloud should be added (default: all)
676  */
677  template <typename PointT> bool
678  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
679  const std::string &id = "cloud", int viewport = 0);
680 
681  /** \brief Updates the XYZ data for an existing cloud object id on screen.
682  * \param[in] cloud the input point cloud dataset
683  * \param[in] id the point cloud object id to update (default: cloud)
684  * \return false if no cloud with the specified ID was found
685  */
686  template <typename PointT> bool
687  updatePointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
688  const std::string &id = "cloud");
689 
690  /** \brief Updates the XYZ data for an existing cloud object id on screen.
691  * \param[in] cloud the input point cloud dataset
692  * \param[in] geometry_handler the geometry handler to use
693  * \param[in] id the point cloud object id to update (default: cloud)
694  * \return false if no cloud with the specified ID was found
695  */
696  template <typename PointT> bool
697  updatePointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
698  const PointCloudGeometryHandler<PointT> &geometry_handler,
699  const std::string &id = "cloud");
700 
701  /** \brief Updates the XYZ data for an existing cloud object id on screen.
702  * \param[in] cloud the input point cloud dataset
703  * \param[in] color_handler the color handler to use
704  * \param[in] id the point cloud object id to update (default: cloud)
705  * \return false if no cloud with the specified ID was found
706  */
707  template <typename PointT> bool
708  updatePointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
709  const PointCloudColorHandler<PointT> &color_handler,
710  const std::string &id = "cloud");
711 
712  /** \brief Add a Point Cloud (templated) to screen.
713  * \param[in] cloud the input point cloud dataset
714  * \param[in] geometry_handler use a geometry handler object to extract the XYZ data
715  * \param[in] id the point cloud object id (default: cloud)
716  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
717  */
718  template <typename PointT> bool
719  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
720  const PointCloudGeometryHandler<PointT> &geometry_handler,
721  const std::string &id = "cloud", int viewport = 0);
722 
723  /** \brief Add a Point Cloud (templated) to screen.
724  *
725  * Because the geometry handler is given as a pointer, it will be pushed back to the list of available
726  * handlers, rather than replacing the current active geometric handler. This makes it possible to
727  * switch between different geometric handlers 'on-the-fly' at runtime, from the PCLVisualizer
728  * interactor interface (using Alt+0..9).
729  *
730  * \param[in] cloud the input point cloud dataset
731  * \param[in] geometry_handler use a geometry handler object to extract the XYZ data
732  * \param[in] id the point cloud object id (default: cloud)
733  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
734  */
735  template <typename PointT> bool
736  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
737  const GeometryHandlerConstPtr &geometry_handler,
738  const std::string &id = "cloud", int viewport = 0);
739 
740  /** \brief Add a Point Cloud (templated) to screen.
741  * \param[in] cloud the input point cloud dataset
742  * \param[in] color_handler a specific PointCloud visualizer handler for colors
743  * \param[in] id the point cloud object id (default: cloud)
744  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
745  */
746  template <typename PointT> bool
747  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
748  const PointCloudColorHandler<PointT> &color_handler,
749  const std::string &id = "cloud", int viewport = 0);
750 
751  /** \brief Add a Point Cloud (templated) to screen.
752  *
753  * Because the color handler is given as a pointer, it will be pushed back to the list of available
754  * handlers, rather than replacing the current active color handler. This makes it possible to
755  * switch between different color handlers 'on-the-fly' at runtime, from the PCLVisualizer
756  * interactor interface (using 0..9).
757  *
758  * \param[in] cloud the input point cloud dataset
759  * \param[in] color_handler a specific PointCloud visualizer handler for colors
760  * \param[in] id the point cloud object id (default: cloud)
761  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
762  */
763  template <typename PointT> bool
764  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
765  const ColorHandlerConstPtr &color_handler,
766  const std::string &id = "cloud", int viewport = 0);
767 
768  /** \brief Add a Point Cloud (templated) to screen.
769  *
770  * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
771  * available handlers, rather than replacing the current active handler. This makes it possible to
772  * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
773  * interface (using [Alt+]0..9).
774  *
775  * \param[in] cloud the input point cloud dataset
776  * \param[in] geometry_handler a specific PointCloud visualizer handler for geometry
777  * \param[in] color_handler a specific PointCloud visualizer handler for colors
778  * \param[in] id the point cloud object id (default: cloud)
779  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
780  */
781  template <typename PointT> bool
782  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
783  const GeometryHandlerConstPtr &geometry_handler,
784  const ColorHandlerConstPtr &color_handler,
785  const std::string &id = "cloud", int viewport = 0);
786 
787  /** \brief Add a binary blob Point Cloud to screen.
788  *
789  * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
790  * available handlers, rather than replacing the current active handler. This makes it possible to
791  * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
792  * interface (using [Alt+]0..9).
793  *
794  * \param[in] cloud the input point cloud dataset
795  * \param[in] geometry_handler a specific PointCloud visualizer handler for geometry
796  * \param[in] color_handler a specific PointCloud visualizer handler for colors
797  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
798  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
799  * \param[in] id the point cloud object id (default: cloud)
800  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
801  */
802  bool
804  const GeometryHandlerConstPtr &geometry_handler,
805  const ColorHandlerConstPtr &color_handler,
806  const Eigen::Vector4f& sensor_origin,
807  const Eigen::Quaternion<float>& sensor_orientation,
808  const std::string &id = "cloud", int viewport = 0);
809 
810  /** \brief Add a binary blob Point Cloud to screen.
811  *
812  * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
813  * available handlers, rather than replacing the current active handler. This makes it possible to
814  * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
815  * interface (using [Alt+]0..9).
816  *
817  * \param[in] cloud the input point cloud dataset
818  * \param[in] geometry_handler a specific PointCloud visualizer handler for geometry
819  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
820  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
821  * \param[in] id the point cloud object id (default: cloud)
822  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
823  */
824  bool
826  const GeometryHandlerConstPtr &geometry_handler,
827  const Eigen::Vector4f& sensor_origin,
828  const Eigen::Quaternion<float>& sensor_orientation,
829  const std::string &id = "cloud", int viewport = 0);
830 
831  /** \brief Add a binary blob Point Cloud to screen.
832  *
833  * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
834  * available handlers, rather than replacing the current active handler. This makes it possible to
835  * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
836  * interface (using [Alt+]0..9).
837  *
838  * \param[in] cloud the input point cloud dataset
839  * \param[in] color_handler a specific PointCloud visualizer handler for colors
840  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
841  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
842  * \param[in] id the point cloud object id (default: cloud)
843  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
844  */
845  bool
847  const ColorHandlerConstPtr &color_handler,
848  const Eigen::Vector4f& sensor_origin,
849  const Eigen::Quaternion<float>& sensor_orientation,
850  const std::string &id = "cloud", int viewport = 0);
851 
852  /** \brief Add a Point Cloud (templated) to screen.
853  * \param[in] cloud the input point cloud dataset
854  * \param[in] color_handler a specific PointCloud visualizer handler for colors
855  * \param[in] geometry_handler use a geometry handler object to extract the XYZ data
856  * \param[in] id the point cloud object id (default: cloud)
857  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
858  */
859  template <typename PointT> bool
860  addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
861  const PointCloudColorHandler<PointT> &color_handler,
862  const PointCloudGeometryHandler<PointT> &geometry_handler,
863  const std::string &id = "cloud", int viewport = 0);
864 
865  /** \brief Add a PointXYZ Point Cloud to screen.
866  * \param[in] cloud the input point cloud dataset
867  * \param[in] id the point cloud object id (default: cloud)
868  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
869  */
870  inline bool
872  const std::string &id = "cloud", int viewport = 0)
873  {
874  return (addPointCloud<pcl::PointXYZ> (cloud, id, viewport));
875  }
876 
877 
878  /** \brief Add a PointXYZRGB Point Cloud to screen.
879  * \param[in] cloud the input point cloud dataset
880  * \param[in] id the point cloud object id (default: cloud)
881  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
882  */
883  inline bool
885  const std::string &id = "cloud", int viewport = 0)
886  {
888  return (addPointCloud<pcl::PointXYZRGB> (cloud, color_handler, id, viewport));
889  }
890 
891  /** \brief Add a PointXYZRGBA Point Cloud to screen.
892  * \param[in] cloud the input point cloud dataset
893  * \param[in] id the point cloud object id (default: cloud)
894  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
895  */
896  inline bool
898  const std::string &id = "cloud", int viewport = 0)
899  {
901  return (addPointCloud<pcl::PointXYZRGBA> (cloud, color_handler, id, viewport));
902  }
903 
904  /** \brief Add a PointXYZL Point Cloud to screen.
905  * \param[in] cloud the input point cloud dataset
906  * \param[in] id the point cloud object id (default: cloud)
907  * \param[in] viewport the view port where the Point Cloud should be added (default: all)
908  */
909  inline bool
911  const std::string &id = "cloud", int viewport = 0)
912  {
914  return (addPointCloud<pcl::PointXYZL> (cloud, color_handler, id, viewport));
915  }
916 
917  /** \brief Updates the XYZ data for an existing cloud object id on screen.
918  * \param[in] cloud the input point cloud dataset
919  * \param[in] id the point cloud object id to update (default: cloud)
920  * \return false if no cloud with the specified ID was found
921  */
922  inline bool
924  const std::string &id = "cloud")
925  {
926  return (updatePointCloud<pcl::PointXYZ> (cloud, id));
927  }
928 
929  /** \brief Updates the XYZRGB data for an existing cloud object id on screen.
930  * \param[in] cloud the input point cloud dataset
931  * \param[in] id the point cloud object id to update (default: cloud)
932  * \return false if no cloud with the specified ID was found
933  */
934  inline bool
936  const std::string &id = "cloud")
937  {
939  return (updatePointCloud<pcl::PointXYZRGB> (cloud, color_handler, id));
940  }
941 
942  /** \brief Updates the XYZRGBA data for an existing cloud object id on screen.
943  * \param[in] cloud the input point cloud dataset
944  * \param[in] id the point cloud object id to update (default: cloud)
945  * \return false if no cloud with the specified ID was found
946  */
947  inline bool
949  const std::string &id = "cloud")
950  {
952  return (updatePointCloud<pcl::PointXYZRGBA> (cloud, color_handler, id));
953  }
954 
955  /** \brief Updates the XYZL data for an existing cloud object id on screen.
956  * \param[in] cloud the input point cloud dataset
957  * \param[in] id the point cloud object id to update (default: cloud)
958  * \return false if no cloud with the specified ID was found
959  */
960  inline bool
962  const std::string &id = "cloud")
963  {
965  return (updatePointCloud<pcl::PointXYZL> (cloud, color_handler, id));
966  }
967 
968  /** \brief Add a PolygonMesh object to screen
969  * \param[in] polymesh the polygonal mesh
970  * \param[in] id the polygon object id (default: "polygon")
971  * \param[in] viewport the view port where the PolygonMesh should be added (default: all)
972  */
973  bool
975  const std::string &id = "polygon",
976  int viewport = 0);
977 
978  /** \brief Add a PolygonMesh object to screen
979  * \param[in] cloud the polygonal mesh point cloud
980  * \param[in] vertices the polygonal mesh vertices
981  * \param[in] id the polygon object id (default: "polygon")
982  * \param[in] viewport the view port where the PolygonMesh should be added (default: all)
983  */
984  template <typename PointT> bool
985  addPolygonMesh (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
986  const std::vector<pcl::Vertices> &vertices,
987  const std::string &id = "polygon",
988  int viewport = 0);
989 
990  /** \brief Update a PolygonMesh object on screen
991  * \param[in] cloud the polygonal mesh point cloud
992  * \param[in] vertices the polygonal mesh vertices
993  * \param[in] id the polygon object id (default: "polygon")
994  * \return false if no polygonmesh with the specified ID was found
995  */
996  template <typename PointT> bool
997  updatePolygonMesh (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
998  const std::vector<pcl::Vertices> &vertices,
999  const std::string &id = "polygon");
1000 
1001  /** \brief Update a PolygonMesh object on screen
1002  * \param[in] polymesh the polygonal mesh
1003  * \param[in] id the polygon object id (default: "polygon")
1004  * \return false if no polygonmesh with the specified ID was found
1005  */
1006  bool
1008  const std::string &id = "polygon");
1009 
1010  /** \brief Add a Polygonline from a polygonMesh object to screen
1011  * \param[in] polymesh the polygonal mesh from where the polylines will be extracted
1012  * \param[in] id the polygon object id (default: "polygon")
1013  * \param[in] viewport the view port where the PolygonMesh should be added (default: all)
1014  */
1015  bool
1017  const std::string &id = "polyline",
1018  int viewport = 0);
1019 
1020  /** \brief Add the specified correspondences to the display.
1021  * \param[in] source_points The source points
1022  * \param[in] target_points The target points
1023  * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
1024  * \param[in] id the polygon object id (default: "correspondences")
1025  * \param[in] viewport the view port where the correspondences should be added (default: all)
1026  */
1027  template <typename PointT> bool
1028  addCorrespondences (const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
1029  const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
1030  const std::vector<int> & correspondences,
1031  const std::string &id = "correspondences",
1032  int viewport = 0);
1033 
1034  /** \brief Add a TextureMesh object to screen
1035  * \param[in] polymesh the textured polygonal mesh
1036  * \param[in] id the texture mesh object id (default: "texture")
1037  * \param[in] viewport the view port where the TextureMesh should be added (default: all)
1038  */
1039  bool
1041  const std::string &id = "texture",
1042  int viewport = 0);
1043 
1044  /** \brief Add the specified correspondences to the display.
1045  * \param[in] source_points The source points
1046  * \param[in] target_points The target points
1047  * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
1048  * \param[in] nth display only the Nth correspondence (e.g., skip the rest)
1049  * \param[in] id the polygon object id (default: "correspondences")
1050  * \param[in] viewport the view port where the correspondences should be added (default: all)
1051  * \param[in] overwrite allow to overwrite already existing correspondences
1052  */
1053  template <typename PointT> bool
1054  addCorrespondences (const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
1055  const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
1056  const pcl::Correspondences &correspondences,
1057  int nth,
1058  const std::string &id = "correspondences",
1059  int viewport = 0,
1060  bool overwrite = false);
1061 
1062  /** \brief Add the specified correspondences to the display.
1063  * \param[in] source_points The source points
1064  * \param[in] target_points The target points
1065  * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
1066  * \param[in] id the polygon object id (default: "correspondences")
1067  * \param[in] viewport the view port where the correspondences should be added (default: all)
1068  */
1069  template <typename PointT> bool
1071  const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
1072  const pcl::Correspondences &correspondences,
1073  const std::string &id = "correspondences",
1074  int viewport = 0)
1075  {
1076  // If Nth not given, display all correspondences
1077  return (addCorrespondences<PointT> (source_points, target_points,
1078  correspondences, 1, id, viewport));
1079  }
1080 
1081  /** \brief Update the specified correspondences to the display.
1082  * \param[in] source_points The source points
1083  * \param[in] target_points The target points
1084  * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
1085  * \param[in] nth display only the Nth correspondence (e.g., skip the rest)
1086  * \param[in] id the polygon object id (default: "correspondences")
1087  * \param[in] viewport the view port where the correspondences should be updated (default: all)
1088  */
1089  template <typename PointT> bool
1090  updateCorrespondences (
1091  const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
1092  const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
1093  const pcl::Correspondences &correspondences,
1094  int nth,
1095  const std::string &id = "correspondences",
1096  int viewport = 0);
1097 
1098  /** \brief Update the specified correspondences to the display.
1099  * \param[in] source_points The source points
1100  * \param[in] target_points The target points
1101  * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
1102  * \param[in] id the polygon object id (default: "correspondences")
1103  * \param[in] viewport the view port where the correspondences should be updated (default: all)
1104  */
1105  template <typename PointT> bool
1107  const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
1108  const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
1109  const pcl::Correspondences &correspondences,
1110  const std::string &id = "correspondences",
1111  int viewport = 0)
1112  {
1113  // If Nth not given, display all correspondences
1114  return (updateCorrespondences<PointT> (source_points, target_points,
1115  correspondences, 1, id, viewport));
1116  }
1117 
1118  /** \brief Remove the specified correspondences from the display.
1119  * \param[in] id the polygon correspondences object id (i.e., given on \ref addCorrespondences)
1120  * \param[in] viewport view port from where the correspondences should be removed (default: all)
1121  */
1122  void
1123  removeCorrespondences (const std::string &id = "correspondences", int viewport = 0);
1124 
1125  /** \brief Get the color handler index of a rendered PointCloud based on its ID
1126  * \param[in] id the point cloud object id
1127  */
1128  int
1129  getColorHandlerIndex (const std::string &id);
1130 
1131  /** \brief Get the geometry handler index of a rendered PointCloud based on its ID
1132  * \param[in] id the point cloud object id
1133  */
1134  int
1135  getGeometryHandlerIndex (const std::string &id);
1136 
1137  /** \brief Update/set the color index of a rendered PointCloud based on its ID
1138  * \param[in] id the point cloud object id
1139  * \param[in] index the color handler index to use
1140  */
1141  bool
1142  updateColorHandlerIndex (const std::string &id, int index);
1143 
1144  /** \brief Set the rendering properties of a PointCloud (3x values - e.g., RGB)
1145  * \param[in] property the property type
1146  * \param[in] val1 the first value to be set
1147  * \param[in] val2 the second value to be set
1148  * \param[in] val3 the third value to be set
1149  * \param[in] id the point cloud object id (default: cloud)
1150  * \param[in] viewport the view port where the Point Cloud's rendering properties should be modified (default: all)
1151  * \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
1152  */
1153  bool
1154  setPointCloudRenderingProperties (int property, double val1, double val2, double val3,
1155  const std::string &id = "cloud", int viewport = 0);
1156 
1157  /** \brief Set the rendering properties of a PointCloud (2x values - e.g., LUT minmax values)
1158  * \param[in] property the property type
1159  * \param[in] val1 the first value to be set
1160  * \param[in] val2 the second value to be set
1161  * \param[in] id the point cloud object id (default: cloud)
1162  * \param[in] viewport the view port where the Point Cloud's rendering properties should be modified (default: all)
1163  * \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
1164  */
1165  bool
1166  setPointCloudRenderingProperties (int property, double val1, double val2,
1167  const std::string &id = "cloud", int viewport = 0);
1168 
1169  /** \brief Set the rendering properties of a PointCloud
1170  * \param[in] property the property type
1171  * \param[in] value the value to be set
1172  * \param[in] id the point cloud object id (default: cloud)
1173  * \param[in] viewport the view port where the Point Cloud's rendering properties should be modified (default: all)
1174  * \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
1175  */
1176  bool
1177  setPointCloudRenderingProperties (int property, double value,
1178  const std::string &id = "cloud", int viewport = 0);
1179 
1180  /** \brief Get the rendering properties of a PointCloud
1181  * \param[in] property the property type
1182  * \param[in] value the resultant property value
1183  * \param[in] id the point cloud object id (default: cloud)
1184  * \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
1185  */
1186  bool
1187  getPointCloudRenderingProperties (int property, double &value,
1188  const std::string &id = "cloud");
1189 
1190  /** \brief Get the rendering properties of a PointCloud
1191  * \param[in] property the property type
1192  * \param[out] val1 the resultant property value
1193  * \param[out] val2 the resultant property value
1194  * \param[out] val3 the resultant property value
1195  * \param[in] id the point cloud object id (default: cloud)
1196  * \return True if the property is effectively retrieved.
1197  * \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
1198  */
1199  bool
1200  getPointCloudRenderingProperties (RenderingProperties property, double &val1, double &val2, double &val3,
1201  const std::string &id = "cloud");
1202 
1203  /** \brief Set whether the point cloud is selected or not
1204  * \param[in] selected whether the cloud is selected or not (true = selected)
1205  * \param[in] id the point cloud object id (default: cloud)
1206  */
1207  bool
1208  setPointCloudSelected (const bool selected, const std::string &id = "cloud" );
1209 
1210  /** \brief Set the rendering properties of a shape
1211  * \param[in] property the property type
1212  * \param[in] value the value to be set
1213  * \param[in] id the shape object id
1214  * \param[in] viewport the view port where the shape's properties should be modified (default: all)
1215  * \note When using \ref addPolygonMesh you you should use \ref setPointCloudRenderingProperties
1216  * \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
1217  */
1218  bool
1219  setShapeRenderingProperties (int property, double value,
1220  const std::string &id, int viewport = 0);
1221 
1222  /** \brief Set the rendering properties of a shape (2x values - e.g., LUT minmax values)
1223  * \param[in] property the property type
1224  * \param[in] val1 the first value to be set
1225  * \param[in] val2 the second value to be set
1226  * \param[in] id the shape object id
1227  * \param[in] viewport the view port where the shape's properties should be modified (default: all)
1228  * \note When using \ref addPolygonMesh you you should use \ref setPointCloudRenderingProperties
1229  */
1230  bool
1231  setShapeRenderingProperties (int property, double val1, double val2,
1232  const std::string &id, int viewport = 0);
1233 
1234  /** \brief Set the rendering properties of a shape (3x values - e.g., RGB)
1235  * \param[in] property the property type
1236  * \param[in] val1 the first value to be set
1237  * \param[in] val2 the second value to be set
1238  * \param[in] val3 the third value to be set
1239  * \param[in] id the shape object id
1240  * \param[in] viewport the view port where the shape's properties should be modified (default: all)
1241  * \note When using \ref addPolygonMesh you you should use \ref setPointCloudRenderingProperties
1242  */
1243  bool
1244  setShapeRenderingProperties (int property, double val1, double val2, double val3,
1245  const std::string &id, int viewport = 0);
1246 
1247  /** \brief Returns true when the user tried to close the window */
1248  bool
1249  wasStopped () const;
1250 
1251  /** \brief Set the stopped flag back to false */
1252  void
1254 
1255  /** \brief Stop the interaction and close the visualizaton window. */
1256  void
1257  close ();
1258 
1259  /** \brief Create a new viewport from [xmin,ymin] -> [xmax,ymax].
1260  * \param[in] xmin the minimum X coordinate for the viewport (0.0 <= 1.0)
1261  * \param[in] ymin the minimum Y coordinate for the viewport (0.0 <= 1.0)
1262  * \param[in] xmax the maximum X coordinate for the viewport (0.0 <= 1.0)
1263  * \param[in] ymax the maximum Y coordinate for the viewport (0.0 <= 1.0)
1264  * \param[in] viewport the id of the new viewport
1265  *
1266  * \note If no renderer for the current window exists, one will be created, and
1267  * the viewport will be set to 0 ('all'). In case one or multiple renderers do
1268  * exist, the viewport ID will be set to the total number of renderers - 1.
1269  */
1270  void
1271  createViewPort (double xmin, double ymin, double xmax, double ymax, int &viewport);
1272 
1273  /** \brief Create a new separate camera for the given viewport.
1274  * \param[in] viewport the viewport to create a new camera for.
1275  */
1276  void
1277  createViewPortCamera (const int viewport);
1278 
1279  /** \brief Add a polygon (polyline) that represents the input point cloud (connects all
1280  * points in order)
1281  * \param[in] cloud the point cloud dataset representing the polygon
1282  * \param[in] r the red channel of the color that the polygon should be rendered with
1283  * \param[in] g the green channel of the color that the polygon should be rendered with
1284  * \param[in] b the blue channel of the color that the polygon should be rendered with
1285  * \param[in] id (optional) the polygon id/name (default: "polygon")
1286  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1287  */
1288  template <typename PointT> bool
1289  addPolygon (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
1290  double r, double g, double b,
1291  const std::string &id = "polygon", int viewport = 0);
1292 
1293  /** \brief Add a polygon (polyline) that represents the input point cloud (connects all
1294  * points in order)
1295  * \param[in] cloud the point cloud dataset representing the polygon
1296  * \param[in] id the polygon id/name (default: "polygon")
1297  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1298  */
1299  template <typename PointT> bool
1300  addPolygon (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
1301  const std::string &id = "polygon",
1302  int viewport = 0);
1303 
1304  /** \brief Add a planar polygon that represents the input point cloud (connects all points in order)
1305  * \param[in] polygon the polygon to draw
1306  * \param[in] r the red channel of the color that the polygon should be rendered with
1307  * \param[in] g the green channel of the color that the polygon should be rendered with
1308  * \param[in] b the blue channel of the color that the polygon should be rendered with
1309  * \param[in] id the polygon id/name (default: "polygon")
1310  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1311  */
1312  template <typename PointT> bool
1313  addPolygon (const pcl::PlanarPolygon<PointT> &polygon,
1314  double r, double g, double b,
1315  const std::string &id = "polygon",
1316  int viewport = 0);
1317 
1318  /** \brief Add a line segment from two points
1319  * \param[in] pt1 the first (start) point on the line
1320  * \param[in] pt2 the second (end) point on the line
1321  * \param[in] id the line id/name (default: "line")
1322  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1323  */
1324  template <typename P1, typename P2> bool
1325  addLine (const P1 &pt1, const P2 &pt2, const std::string &id = "line",
1326  int viewport = 0);
1327 
1328  /** \brief Add a line segment from two points
1329  * \param[in] pt1 the first (start) point on the line
1330  * \param[in] pt2 the second (end) point on the line
1331  * \param[in] r the red channel of the color that the line should be rendered with
1332  * \param[in] g the green channel of the color that the line should be rendered with
1333  * \param[in] b the blue channel of the color that the line should be rendered with
1334  * \param[in] id the line id/name (default: "line")
1335  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1336  */
1337  template <typename P1, typename P2> bool
1338  addLine (const P1 &pt1, const P2 &pt2, double r, double g, double b,
1339  const std::string &id = "line", int viewport = 0);
1340 
1341  /** \brief Add a line arrow segment between two points, and display the distance between them
1342  *
1343  * Arrow heads are attached to both end points of the arrow.
1344  *
1345  * \param[in] pt1 the first (start) point on the line
1346  * \param[in] pt2 the second (end) point on the line
1347  * \param[in] r the red channel of the color that the line should be rendered with
1348  * \param[in] g the green channel of the color that the line should be rendered with
1349  * \param[in] b the blue channel of the color that the line should be rendered with
1350  * \param[in] id the arrow id/name (default: "arrow")
1351  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1352  */
1353  template <typename P1, typename P2> bool
1354  addArrow (const P1 &pt1, const P2 &pt2, double r, double g, double b,
1355  const std::string &id = "arrow", int viewport = 0);
1356 
1357  /** \brief Add a line arrow segment between two points, and (optionally) display the distance between them
1358  *
1359  * Arrow head is attached on the **start** point (\c pt1) of the arrow.
1360  *
1361  * \param[in] pt1 the first (start) point on the line
1362  * \param[in] pt2 the second (end) point on the line
1363  * \param[in] r the red channel of the color that the line should be rendered with
1364  * \param[in] g the green channel of the color that the line should be rendered with
1365  * \param[in] b the blue channel of the color that the line should be rendered with
1366  * \param[in] display_length true if the length should be displayed on the arrow as text
1367  * \param[in] id the line id/name (default: "arrow")
1368  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1369  */
1370  template <typename P1, typename P2> bool
1371  addArrow (const P1 &pt1, const P2 &pt2, double r, double g, double b, bool display_length,
1372  const std::string &id = "arrow", int viewport = 0);
1373 
1374  /** \brief Add a line arrow segment between two points, and display the distance between them in a given color
1375  *
1376  * Arrow heads are attached to both end points of the arrow.
1377  *
1378  * \param[in] pt1 the first (start) point on the line
1379  * \param[in] pt2 the second (end) point on the line
1380  * \param[in] r_line the red channel of the color that the line should be rendered with
1381  * \param[in] g_line the green channel of the color that the line should be rendered with
1382  * \param[in] b_line the blue channel of the color that the line should be rendered with
1383  * \param[in] r_text the red channel of the color that the text should be rendered with
1384  * \param[in] g_text the green channel of the color that the text should be rendered with
1385  * \param[in] b_text the blue channel of the color that the text should be rendered with
1386  * \param[in] id the line id/name (default: "arrow")
1387  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1388  */
1389  template <typename P1, typename P2> bool
1390  addArrow (const P1 &pt1, const P2 &pt2,
1391  double r_line, double g_line, double b_line,
1392  double r_text, double g_text, double b_text,
1393  const std::string &id = "arrow", int viewport = 0);
1394 
1395 
1396  /** \brief Add a sphere shape from a point and a radius
1397  * \param[in] center the center of the sphere
1398  * \param[in] radius the radius of the sphere
1399  * \param[in] id the sphere id/name (default: "sphere")
1400  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1401  */
1402  template <typename PointT> bool
1403  addSphere (const PointT &center, double radius, const std::string &id = "sphere",
1404  int viewport = 0);
1405 
1406  /** \brief Add a sphere shape from a point and a radius
1407  * \param[in] center the center of the sphere
1408  * \param[in] radius the radius of the sphere
1409  * \param[in] r the red channel of the color that the sphere should be rendered with
1410  * \param[in] g the green channel of the color that the sphere should be rendered with
1411  * \param[in] b the blue channel of the color that the sphere should be rendered with
1412  * \param[in] id the sphere id/name (default: "sphere")
1413  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1414  */
1415  template <typename PointT> bool
1416  addSphere (const PointT &center, double radius, double r, double g, double b,
1417  const std::string &id = "sphere", int viewport = 0);
1418 
1419  /** \brief Update an existing sphere shape from a point and a radius
1420  * \param[in] center the center of the sphere
1421  * \param[in] radius the radius of the sphere
1422  * \param[in] r the red channel of the color that the sphere should be rendered with
1423  * \param[in] g the green channel of the color that the sphere should be rendered with
1424  * \param[in] b the blue channel of the color that the sphere should be rendered with
1425  * \param[in] id the sphere id/name (default: "sphere")
1426  */
1427  template <typename PointT> bool
1428  updateSphere (const PointT &center, double radius, double r, double g, double b,
1429  const std::string &id = "sphere");
1430 
1431  /** \brief Add a vtkPolydata as a mesh
1432  * \param[in] polydata vtkPolyData
1433  * \param[in] id the model id/name (default: "PolyData")
1434  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1435  */
1436  bool
1438  const std::string & id = "PolyData",
1439  int viewport = 0);
1440 
1441  /** \brief Add a vtkPolydata as a mesh
1442  * \param[in] polydata vtkPolyData
1443  * \param[in] transform transformation to apply
1444  * \param[in] id the model id/name (default: "PolyData")
1445  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1446  */
1447  bool
1450  const std::string &id = "PolyData",
1451  int viewport = 0);
1452 
1453  /** \brief Add a PLYmodel as a mesh
1454  * \param[in] filename of the ply file
1455  * \param[in] id the model id/name (default: "PLYModel")
1456  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1457  */
1458  bool
1459  addModelFromPLYFile (const std::string &filename,
1460  const std::string &id = "PLYModel",
1461  int viewport = 0);
1462 
1463  /** \brief Add a PLYmodel as a mesh and applies given transformation
1464  * \param[in] filename of the ply file
1465  * \param[in] transform transformation to apply
1466  * \param[in] id the model id/name (default: "PLYModel")
1467  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1468  */
1469  bool
1470  addModelFromPLYFile (const std::string &filename,
1472  const std::string &id = "PLYModel",
1473  int viewport = 0);
1474 
1475  /** \brief Add a cylinder from a set of given model coefficients
1476  * \param[in] coefficients the model coefficients (point_on_axis, axis_direction, radius)
1477  * \param[in] id the cylinder id/name (default: "cylinder")
1478  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1479  *
1480  * \code
1481  * // The following are given (or computed using sample consensus techniques)
1482  * // See SampleConsensusModelCylinder for more information.
1483  * // Eigen::Vector3f pt_on_axis, axis_direction;
1484  * // float radius;
1485  *
1486  * pcl::ModelCoefficients cylinder_coeff;
1487  * cylinder_coeff.values.resize (7); // We need 7 values
1488  * cylinder_coeff.values[0] = pt_on_axis.x ();
1489  * cylinder_coeff.values[1] = pt_on_axis.y ();
1490  * cylinder_coeff.values[2] = pt_on_axis.z ();
1491  *
1492  * cylinder_coeff.values[3] = axis_direction.x ();
1493  * cylinder_coeff.values[4] = axis_direction.y ();
1494  * cylinder_coeff.values[5] = axis_direction.z ();
1495  *
1496  * cylinder_coeff.values[6] = radius;
1497  *
1498  * addCylinder (cylinder_coeff);
1499  * \endcode
1500  */
1501  bool
1502  addCylinder (const pcl::ModelCoefficients &coefficients,
1503  const std::string &id = "cylinder",
1504  int viewport = 0);
1505 
1506  /** \brief Add a sphere from a set of given model coefficients
1507  * \param[in] coefficients the model coefficients (sphere center, radius)
1508  * \param[in] id the sphere id/name (default: "sphere")
1509  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1510  *
1511  * \code
1512  * // The following are given (or computed using sample consensus techniques)
1513  * // See SampleConsensusModelSphere for more information
1514  * // Eigen::Vector3f sphere_center;
1515  * // float radius;
1516  *
1517  * pcl::ModelCoefficients sphere_coeff;
1518  * sphere_coeff.values.resize (4); // We need 4 values
1519  * sphere_coeff.values[0] = sphere_center.x ();
1520  * sphere_coeff.values[1] = sphere_center.y ();
1521  * sphere_coeff.values[2] = sphere_center.z ();
1522  *
1523  * sphere_coeff.values[3] = radius;
1524  *
1525  * addSphere (sphere_coeff);
1526  * \endcode
1527  */
1528  bool
1529  addSphere (const pcl::ModelCoefficients &coefficients,
1530  const std::string &id = "sphere",
1531  int viewport = 0);
1532 
1533  /** \brief Add a line from a set of given model coefficients
1534  * \param[in] coefficients the model coefficients (point_on_line, direction)
1535  * \param[in] id the line id/name (default: "line")
1536  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1537  *
1538  * \code
1539  * // The following are given (or computed using sample consensus techniques)
1540  * // See SampleConsensusModelLine for more information
1541  * // Eigen::Vector3f point_on_line, line_direction;
1542  *
1543  * pcl::ModelCoefficients line_coeff;
1544  * line_coeff.values.resize (6); // We need 6 values
1545  * line_coeff.values[0] = point_on_line.x ();
1546  * line_coeff.values[1] = point_on_line.y ();
1547  * line_coeff.values[2] = point_on_line.z ();
1548  *
1549  * line_coeff.values[3] = line_direction.x ();
1550  * line_coeff.values[4] = line_direction.y ();
1551  * line_coeff.values[5] = line_direction.z ();
1552  *
1553  * addLine (line_coeff);
1554  * \endcode
1555  */
1556  bool
1557  addLine (const pcl::ModelCoefficients &coefficients,
1558  const std::string &id = "line",
1559  int viewport = 0);
1560 
1561  /** \brief Add a line from a set of given model coefficients
1562  * \param[in] coefficients the model coefficients (point_on_line, direction)
1563  * \param[in] id the line id/name (default: "line")
1564  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1565  *
1566  * \code
1567  * // The following are given (or computed using sample consensus techniques)
1568  * // See SampleConsensusModelLine for more information
1569  * // Eigen::Vector3f point_on_line, line_direction;
1570  *
1571  * pcl::ModelCoefficients line_coeff;
1572  * line_coeff.values.resize (6); // We need 6 values
1573  * line_coeff.values[0] = point_on_line.x ();
1574  * line_coeff.values[1] = point_on_line.y ();
1575  * line_coeff.values[2] = point_on_line.z ();
1576  *
1577  * line_coeff.values[3] = line_direction.x ();
1578  * line_coeff.values[4] = line_direction.y ();
1579  * line_coeff.values[5] = line_direction.z ();
1580  *
1581  * addLine (line_coeff);
1582  * \endcode
1583  */
1584  bool
1585  addLine (const pcl::ModelCoefficients &coefficients,
1586  const char *id = "line",
1587  int viewport = 0)
1588  {
1589  return addLine (coefficients, std::string (id), viewport);
1590  }
1591 
1592  /** \brief Add a plane from a set of given model coefficients
1593  * \param[in] coefficients the model coefficients (a, b, c, d with ax+by+cz+d=0)
1594  * \param[in] id the plane id/name (default: "plane")
1595  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1596  *
1597  * \code
1598  * // The following are given (or computed using sample consensus techniques)
1599  * // See SampleConsensusModelPlane for more information
1600  * // Eigen::Vector4f plane_parameters;
1601  *
1602  * pcl::ModelCoefficients plane_coeff;
1603  * plane_coeff.values.resize (4); // We need 4 values
1604  * plane_coeff.values[0] = plane_parameters.x ();
1605  * plane_coeff.values[1] = plane_parameters.y ();
1606  * plane_coeff.values[2] = plane_parameters.z ();
1607  * plane_coeff.values[3] = plane_parameters.w ();
1608  *
1609  * addPlane (plane_coeff);
1610  * \endcode
1611  */
1612  bool
1613  addPlane (const pcl::ModelCoefficients &coefficients,
1614  const std::string &id = "plane",
1615  int viewport = 0);
1616 
1617  bool
1618  addPlane (const pcl::ModelCoefficients &coefficients, double x, double y, double z,
1619  const std::string &id = "plane",
1620  int viewport = 0);
1621  /** \brief Add a circle from a set of given model coefficients
1622  * \param[in] coefficients the model coefficients (x, y, radius)
1623  * \param[in] id the circle id/name (default: "circle")
1624  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1625  *
1626  * \code
1627  * // The following are given (or computed using sample consensus techniques)
1628  * // See SampleConsensusModelCircle2D for more information
1629  * // float x, y, radius;
1630  *
1631  * pcl::ModelCoefficients circle_coeff;
1632  * circle_coeff.values.resize (3); // We need 3 values
1633  * circle_coeff.values[0] = x;
1634  * circle_coeff.values[1] = y;
1635  * circle_coeff.values[2] = radius;
1636  *
1637  * vtkSmartPointer<vtkDataSet> data = pcl::visualization::create2DCircle (circle_coeff, z);
1638  * \endcode
1639  */
1640  bool
1641  addCircle (const pcl::ModelCoefficients &coefficients,
1642  const std::string &id = "circle",
1643  int viewport = 0);
1644 
1645  /** \brief Add a cone from a set of given model coefficients
1646  * \param[in] coefficients the model coefficients (see \ref pcl::visualization::createCone)
1647  * \param[in] id the cone id/name (default: "cone")
1648  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1649  */
1650  bool
1651  addCone (const pcl::ModelCoefficients &coefficients,
1652  const std::string &id = "cone",
1653  int viewport = 0);
1654 
1655  /** \brief Add a cube from a set of given model coefficients
1656  * \param[in] coefficients the model coefficients (see \ref pcl::visualization::createCube)
1657  * \param[in] id the cube id/name (default: "cube")
1658  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1659  */
1660  bool
1661  addCube (const pcl::ModelCoefficients &coefficients,
1662  const std::string &id = "cube",
1663  int viewport = 0);
1664 
1665  /** \brief Add a cube from a set of given model coefficients
1666  * \param[in] translation a translation to apply to the cube from 0,0,0
1667  * \param[in] rotation a quaternion-based rotation to apply to the cube
1668  * \param[in] width the cube's width
1669  * \param[in] height the cube's height
1670  * \param[in] depth the cube's depth
1671  * \param[in] id the cube id/name (default: "cube")
1672  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1673  */
1674  bool
1675  addCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation,
1676  double width, double height, double depth,
1677  const std::string &id = "cube",
1678  int viewport = 0);
1679 
1680  /** \brief Add a cube
1681  * \param[in] x_min the min X coordinate
1682  * \param[in] x_max the max X coordinate
1683  * \param[in] y_min the min Y coordinate
1684  * \param[in] y_max the max Y coordinate
1685  * \param[in] z_min the min Z coordinate
1686  * \param[in] z_max the max Z coordinate
1687  * \param[in] r how much red (0.0 -> 1.0)
1688  * \param[in] g how much green (0.0 -> 1.0)
1689  * \param[in] b how much blue (0.0 -> 1.0)
1690  * \param[in] id the cube id/name (default: "cube")
1691  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1692  */
1693  bool
1694  addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max,
1695  double r = 1.0, double g = 1.0, double b = 1.0, const std::string &id = "cube", int viewport = 0);
1696 
1697  /** \brief Add an ellipsoid from the given parameters
1698  * \param[in] transform a transformation to apply to the ellipsoid from 0,0,0
1699  * \param[in] radius_x the ellipsoid's radius along its local x-axis
1700  * \param[in] radius_y the ellipsoid's radius along its local y-axis
1701  * \param[in] radius_z the ellipsoid's radius along its local z-axis
1702  * \param[in] id the ellipsoid id/name (default: "ellipsoid")
1703  * \param[in] viewport (optional) the id of the new viewport (default: 0)
1704  */
1705  bool
1706  addEllipsoid (const Eigen::Isometry3d &transform,
1707  double radius_x, double radius_y, double radius_z,
1708  const std::string &id = "ellipsoid",
1709  int viewport = 0);
1710 
1711  /**
1712  * @brief Eye-Dome Lighting makes dark areas to improve depth perception
1713  * See https://www.kitware.com/eye-dome-lighting-a-non-photorealistic-shading-technique/
1714  * It is applied to all actors, including texts.
1715  * @param viewport
1716  */
1717  void
1718  enableEDLRendering(int viewport = 0);
1719 
1720  /** \brief Changes the visual representation for all actors to surface representation. */
1721  void
1723 
1724  /** \brief Changes the visual representation for all actors to points representation. */
1725  void
1727 
1728  /** \brief Changes the visual representation for all actors to wireframe representation. */
1729  void
1731 
1732  /** \brief Sets whether the 2D overlay text showing the framerate of the window is displayed or not.
1733  * \param[in] show_fps determines whether the fps text will be shown or not.
1734  */
1735  void
1736  setShowFPS (bool show_fps);
1737 
1738  /** Get the current rendering framerate.
1739  * \see setShowFPS */
1740  float
1741  getFPS () const;
1742 
1743  /** \brief Renders a virtual scene as seen from the camera viewpoint and returns the rendered point cloud.
1744  * ATT: This method will only render the scene if only on viewport exists. Otherwise, returns an empty
1745  * point cloud and exits immediately.
1746  * \param[in] xres is the size of the window (X) used to render the scene
1747  * \param[in] yres is the size of the window (Y) used to render the scene
1748  * \param[in] cloud is the rendered point cloud
1749  */
1750  void
1751  renderView (int xres, int yres, pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud);
1752 
1753  /** \brief The purpose of this method is to render a CAD model added to the visualizer from different viewpoints
1754  * in order to simulate partial views of model. The viewpoint locations are the vertices of a tessellated sphere
1755  * build from an icosaheadron. The tessellation parameter controls how many times the triangles of the original
1756  * icosahedron are divided to approximate the sphere and thus the number of partial view generated for a model,
1757  * with a tesselation_level of 0, 12 views are generated if use_vertices=true and 20 views if use_vertices=false
1758  *
1759  * \param[in] xres the size of the window (X) used to render the partial view of the object
1760  * \param[in] yres the size of the window (Y) used to render the partial view of the object
1761  * \param[in] cloud is a vector of pointcloud with XYZ information that represent the model as seen from the respective viewpoints.
1762  * \param[out] poses represent the transformation from object coordinates to camera coordinates for the respective viewpoint.
1763  * \param[out] enthropies are values between 0 and 1 representing which percentage of the model is seen from the respective viewpoint.
1764  * \param[in] tesselation_level represents the number of subdivisions applied to the triangles of original icosahedron.
1765  * \param[in] view_angle field of view of the virtual camera. Default: 45
1766  * \param[in] radius_sphere the tessellated sphere radius. Default: 1
1767  * \param[in] use_vertices if true, use the vertices of tessellated icosahedron (12,42,...) or if false, use the faces of tessellated
1768  * icosahedron (20,80,...). Default: true
1769  */
1770  void
1772  int xres, int yres,
1774  std::vector<Eigen::Matrix4f,Eigen::aligned_allocator< Eigen::Matrix4f > > & poses, std::vector<float> & enthropies, int tesselation_level,
1775  float view_angle = 45, float radius_sphere = 1, bool use_vertices = true);
1776 
1777 
1778  /** \brief Initialize camera parameters with some default values. */
1779  void
1781 
1782  /** \brief Search for camera parameters at the command line and set them internally.
1783  * \param[in] argc
1784  * \param[in] argv
1785  */
1786  bool
1787  getCameraParameters (int argc, char **argv);
1788 
1789  /** \brief Load camera parameters from a camera parameters file.
1790  * \param[in] file the name of the camera parameters file
1791  */
1792  bool
1793  loadCameraParameters (const std::string &file);
1794 
1795  /** \brief Checks whether the camera parameters were manually loaded.
1796  * \return True if valid "-cam" option is available in command line.
1797  * \sa cameraFileLoaded ()
1798  */
1799  bool
1801 
1802  /** \brief Checks whether a camera file were automatically loaded.
1803  * \return True if a valid camera file is automatically loaded.
1804  * \note The camera file is saved by pressing "ctrl + s" during last run of the program
1805  * and restored automatically when the program runs this time.
1806  * \sa cameraParamsSet ()
1807  */
1808  bool
1810 
1811  /** \brief Get camera file for camera parameter saving/restoring.
1812  * \note This will be valid only when valid "-cam" option were available in command line
1813  * or a saved camera file were automatically loaded.
1814  * \sa cameraParamsSet (), cameraFileLoaded ()
1815  */
1816  std::string
1817  getCameraFile () const;
1818 
1819  /** \brief Update camera parameters and render. */
1820  PCL_DEPRECATED(1,15,"updateCamera will be removed, as it does nothing.")
1821  inline void
1822  updateCamera () {};
1823 
1824  /** \brief Reset camera parameters and render. */
1825  void
1827 
1828  /** \brief Reset the camera direction from {0, 0, 0} to the center_{x, y, z} of a given dataset.
1829  * \param[in] id the point cloud object id (default: cloud)
1830  */
1831  void
1832  resetCameraViewpoint (const std::string &id = "cloud");
1833 
1834  /** \brief Set the camera pose given by position, viewpoint and up vector
1835  * \param[in] pos_x the x coordinate of the camera location
1836  * \param[in] pos_y the y coordinate of the camera location
1837  * \param[in] pos_z the z coordinate of the camera location
1838  * \param[in] view_x the x component of the view point of the camera
1839  * \param[in] view_y the y component of the view point of the camera
1840  * \param[in] view_z the z component of the view point of the camera
1841  * \param[in] up_x the x component of the view up direction of the camera
1842  * \param[in] up_y the y component of the view up direction of the camera
1843  * \param[in] up_z the z component of the view up direction of the camera
1844  * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
1845  */
1846  void
1847  setCameraPosition (double pos_x, double pos_y, double pos_z,
1848  double view_x, double view_y, double view_z,
1849  double up_x, double up_y, double up_z, int viewport = 0);
1850 
1851  /** \brief Set the camera location and viewup according to the given arguments
1852  * \param[in] pos_x the x coordinate of the camera location
1853  * \param[in] pos_y the y coordinate of the camera location
1854  * \param[in] pos_z the z coordinate of the camera location
1855  * \param[in] up_x the x component of the view up direction of the camera
1856  * \param[in] up_y the y component of the view up direction of the camera
1857  * \param[in] up_z the z component of the view up direction of the camera
1858  * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
1859  */
1860  void
1861  setCameraPosition (double pos_x, double pos_y, double pos_z,
1862  double up_x, double up_y, double up_z, int viewport = 0);
1863 
1864  /** \brief Set the camera parameters via an intrinsics and and extrinsics matrix
1865  * \note This assumes that the pixels are square and that the center of the image is at the center of the sensor.
1866  * \param[in] intrinsics the intrinsics that will be used to compute the VTK camera parameters
1867  * \param[in] extrinsics the extrinsics that will be used to compute the VTK camera parameters
1868  * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
1869  */
1870  void
1871  setCameraParameters (const Eigen::Matrix3f &intrinsics, const Eigen::Matrix4f &extrinsics, int viewport = 0);
1872 
1873  /** \brief Set the camera parameters by given a full camera data structure.
1874  * \param[in] camera camera structure containing all the camera parameters.
1875  * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
1876  */
1877  void
1878  setCameraParameters (const Camera &camera, int viewport = 0);
1879 
1880  /** \brief Set the camera clipping distances.
1881  * \param[in] near the near clipping distance (no objects closer than this to the camera will be drawn)
1882  * \param[in] far the far clipping distance (no objects further away than this to the camera will be drawn)
1883  * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
1884  */
1885  void
1886  setCameraClipDistances (double near, double far, int viewport = 0);
1887 
1888  /** \brief Set the camera vertical field of view.
1889  * \param[in] fovy vertical field of view in radians
1890  * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
1891  */
1892  void
1893  setCameraFieldOfView (double fovy, int viewport = 0);
1894 
1895  /** \brief Get the current camera parameters. */
1896  void
1897  getCameras (std::vector<Camera>& cameras);
1898 
1899 
1900  /** \brief Get the current viewing pose. */
1901  Eigen::Affine3f
1902  getViewerPose (int viewport = 0);
1903 
1904  /** \brief Save the current rendered image to disk, as a PNG screenshot.
1905  * \param[in] file the name of the PNG file
1906  */
1907  void
1908  saveScreenshot (const std::string &file);
1909 
1910  /** \brief Save the camera parameters to disk, as a .cam file.
1911  * \param[in] file the name of the .cam file
1912  */
1913  void
1914  saveCameraParameters (const std::string &file);
1915 
1916  /** \brief Get camera parameters of a given viewport (0 means default viewport). */
1917  void
1918  getCameraParameters (Camera &camera, int viewport = 0) const;
1919 
1920  /** \brief Return a pointer to the underlying VTK Render Window used. */
1923  {
1924  return (win_);
1925  }
1926 
1927  /** \brief Return a pointer to the underlying VTK Renderer Collection. */
1930  {
1931  return (rens_);
1932  }
1933 
1934  /** \brief Return a pointer to the CloudActorMap this visualizer uses. */
1937  {
1938  return (cloud_actor_map_);
1939  }
1940 
1941  /** \brief Return a pointer to the ShapeActorMap this visualizer uses. */
1944  {
1945  return (shape_actor_map_);
1946  }
1947 
1948  /** \brief Set the position in screen coordinates.
1949  * \param[in] x where to move the window to (X)
1950  * \param[in] y where to move the window to (Y)
1951  */
1952  void
1953  setPosition (int x, int y);
1954 
1955  /** \brief Set the window size in screen coordinates.
1956  * \param[in] xw window size in horizontal (pixels)
1957  * \param[in] yw window size in vertical (pixels)
1958  */
1959  void
1960  setSize (int xw, int yw);
1961 
1962  /** \brief Use Vertex Buffer Objects renderers.
1963  * This is an optimization for the obsolete OpenGL backend. Modern OpenGL2 backend (VTK ≥ 6.3) uses vertex
1964  * buffer objects by default, transparently for the user.
1965  * \param[in] use_vbos set to true to use VBOs
1966  */
1967  void
1968  setUseVbos (bool use_vbos);
1969 
1970  /** \brief Set the ID of a cloud or shape to be used for LUT display
1971  * \param[in] id The id of the cloud/shape look up table to be displayed
1972  * The look up table is displayed by pressing 'u' in the PCLVisualizer */
1973  void
1974  setLookUpTableID (const std::string id);
1975 
1976  /** \brief Create the internal Interactor object. */
1977  void
1979 
1980  /** \brief Set up our unique PCL interactor style for a given vtkRenderWindowInteractor object
1981  * attached to a given vtkRenderWindow
1982  * \param[in,out] iren the vtkRenderWindowInteractor object to set up
1983  * \param[in,out] win a vtkRenderWindow object that the interactor is attached to
1984  */
1985  void
1986  setupInteractor (vtkRenderWindowInteractor *iren,
1987  vtkRenderWindow *win);
1988 
1989  /** \brief Set up PCLVisualizer with custom interactor style for a given vtkRenderWindowInteractor object
1990  * attached to a given vtkRenderWindow
1991  * \param[in,out] iren the vtkRenderWindowInteractor object to set up
1992  * \param[in,out] win a vtkRenderWindow object that the interactor is attached to
1993  * \param[in,out] style a vtkInteractorStyle object
1994  */
1995  void
1996  setupInteractor (vtkRenderWindowInteractor *iren,
1997  vtkRenderWindow *win,
1998  vtkInteractorStyle *style);
1999 
2000  /** \brief Get a pointer to the current interactor style used. */
2003  {
2004  return (style_);
2005  }
2006  protected:
2007  /** \brief The render window interactor. */
2009  private:
2010  /** \brief Internal function for renderer setup
2011  * \param[in] vtk renderer
2012  */
2013  void setupRenderer (vtkSmartPointer<vtkRenderer> ren);
2014 
2015  /** \brief Internal function for setting up FPS callback
2016  * \param[in] vtk renderer
2017  */
2018  void setupFPSCallback (const vtkSmartPointer<vtkRenderer>& ren);
2019 
2020  /** \brief Internal function for setting up render window
2021  * \param[in] name the window name
2022  */
2023  void setupRenderWindow (const std::string& name);
2024 
2025  /** \brief Internal function for setting up interactor style
2026  */
2027  void setupStyle ();
2028 
2029  /** \brief Internal function for setting the default render window size and position on screen
2030  */
2031  void setDefaultWindowSizeAndPos ();
2032 
2033  /** \brief Set up camera parameters.
2034  *
2035  * Parses command line arguments to find camera parameters (either explicit numbers or a path to a .cam file).
2036  * If not found, will generate a unique .cam file path (based on the rest of command line arguments) and try
2037  * to load that. If it is also not found, just set the defaults.
2038  */
2039  void setupCamera (int argc, char **argv);
2040 
2041  struct PCL_EXPORTS ExitMainLoopTimerCallback : public vtkCommand
2042  {
2043  static ExitMainLoopTimerCallback* New ()
2044  {
2045  return (new ExitMainLoopTimerCallback);
2046  }
2047  void
2048  Execute (vtkObject*, unsigned long event_id, void*) override;
2049 
2050  int right_timer_id;
2051  PCLVisualizer* pcl_visualizer;
2052  };
2053 
2054  struct PCL_EXPORTS ExitCallback : public vtkCommand
2055  {
2056  static ExitCallback* New ()
2057  {
2058  return (new ExitCallback);
2059  }
2060  void
2061  Execute (vtkObject*, unsigned long event_id, void*) override;
2062 
2063  PCLVisualizer* pcl_visualizer;
2064  };
2065 
2066  //////////////////////////////////////////////////////////////////////////////////////////////
2067  struct PCL_EXPORTS FPSCallback : public vtkCommand
2068  {
2069  static FPSCallback *New () { return (new FPSCallback); }
2070 
2071  FPSCallback () : actor (), pcl_visualizer (), decimated (), last_fps(0.0f) {}
2072  FPSCallback (const FPSCallback& src) = default;
2073  FPSCallback& operator = (const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; last_fps = src.last_fps; return (*this); }
2074 
2075  void
2076  Execute (vtkObject*, unsigned long event_id, void*) override;
2077 
2078  vtkTextActor *actor;
2079  PCLVisualizer* pcl_visualizer;
2080  bool decimated;
2081  float last_fps;
2082  };
2083 
2084  /** \brief The FPSCallback object for the current visualizer. */
2085  vtkSmartPointer<FPSCallback> update_fps_;
2086 
2087  /** \brief Set to false if the interaction loop is running. */
2088  bool stopped_;
2089 
2090  /** \brief Global timer ID. Used in destructor only. */
2091  int timer_id_;
2092 
2093  /** \brief Callback object enabling us to leave the main loop, when a timer fires. */
2094  vtkSmartPointer<ExitMainLoopTimerCallback> exit_main_loop_timer_callback_;
2095  vtkSmartPointer<ExitCallback> exit_callback_;
2096 
2097  /** \brief The collection of renderers used. */
2099 
2100  /** \brief The render window. */
2102 
2103  /** \brief The render window interactor style. */
2105 
2106  /** \brief Internal list with actor pointers and name IDs for point clouds. */
2107  CloudActorMapPtr cloud_actor_map_;
2108 
2109  /** \brief Internal list with actor pointers and name IDs for shapes. */
2110  ShapeActorMapPtr shape_actor_map_;
2111 
2112  /** \brief Internal list with actor pointers and viewpoint for coordinates. */
2113  CoordinateActorMapPtr coordinate_actor_map_;
2114 
2115  /** \brief Internal pointer to widget which contains a set of axes */
2117 
2118  /** \brief Boolean that holds whether or not the camera parameters were manually initialized */
2119  bool camera_set_;
2120 
2121  /** \brief Boolean that holds whether or not a camera file were automatically loaded */
2122  bool camera_file_loaded_;
2123 
2124  /** \brief Boolean that holds whether or not to use the vtkVertexBufferObjectMapper*/
2125  bool use_vbos_;
2126 
2127  /** \brief Internal method. Removes a vtk actor from the screen.
2128  * \param[in] actor a pointer to the vtk actor object
2129  * \param[in] viewport the view port where the actor should be removed from (default: all)
2130  */
2131  bool
2132  removeActorFromRenderer (const vtkSmartPointer<vtkLODActor> &actor,
2133  int viewport = 0);
2134 
2135  /** \brief Internal method. Removes a vtk actor from the screen.
2136  * \param[in] actor a pointer to the vtk actor object
2137  * \param[in] viewport the view port where the actor should be removed from (default: all)
2138  */
2139  bool
2140  removeActorFromRenderer (const vtkSmartPointer<vtkActor> &actor,
2141  int viewport = 0);
2142 
2143  /** \brief Internal method. Adds a vtk actor to screen.
2144  * \param[in] actor a pointer to the vtk actor object
2145  * \param[in] viewport port where the actor should be added to (default: 0/all)
2146  *
2147  * \note If viewport is set to 0, the actor will be added to all existing
2148  * renders. To select a specific viewport use an integer between 1 and N.
2149  */
2150  void
2151  addActorToRenderer (const vtkSmartPointer<vtkProp> &actor,
2152  int viewport = 0);
2153 
2154  /** \brief Internal method. Adds a vtk actor to screen.
2155  * \param[in] actor a pointer to the vtk actor object
2156  * \param[in] viewport the view port where the actor should be added to (default: all)
2157  */
2158  bool
2159  removeActorFromRenderer (const vtkSmartPointer<vtkProp> &actor,
2160  int viewport = 0);
2161 
2162  /** \brief Internal method. Creates a vtk actor from a vtk polydata object.
2163  * \param[in] data the vtk polydata object to create an actor for
2164  * \param[out] actor the resultant vtk actor object
2165  * \param[in] use_scalars set scalar properties to the mapper if it exists in the data. Default: true.
2166  */
2167  void
2168  createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
2170  bool use_scalars = true) const;
2171 
2172  /** \brief Internal method. Creates a vtk actor from a vtk polydata object.
2173  * \param[in] data the vtk polydata object to create an actor for
2174  * \param[out] actor the resultant vtk actor object
2175  * \param[in] use_scalars set scalar properties to the mapper if it exists in the data. Default: true.
2176  */
2177  void
2178  createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
2180  bool use_scalars = true) const;
2181 
2182  /** \brief Converts a PCL templated PointCloud object to a vtk polydata object.
2183  * \param[in] cloud the input PCL PointCloud dataset
2184  * \param[out] polydata the resultant polydata containing the cloud
2185  * \param[out] initcells a list of cell indices used for the conversion. This can be set once and then passed
2186  * around to speed up the conversion.
2187  */
2188  template <typename PointT> void
2189  convertPointCloudToVTKPolyData (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
2190  vtkSmartPointer<vtkPolyData> &polydata,
2191  vtkSmartPointer<vtkIdTypeArray> &initcells);
2192 
2193  /** \brief Converts a PCL templated PointCloud object to a vtk polydata object.
2194  * \param[in] geometry_handler the geometry handler object used to extract the XYZ data
2195  * \param[out] polydata the resultant polydata containing the cloud
2196  * \param[out] initcells a list of cell indices used for the conversion. This can be set once and then passed
2197  * around to speed up the conversion.
2198  */
2199  template <typename PointT> void
2200  convertPointCloudToVTKPolyData (const PointCloudGeometryHandler<PointT> &geometry_handler,
2201  vtkSmartPointer<vtkPolyData> &polydata,
2202  vtkSmartPointer<vtkIdTypeArray> &initcells);
2203 
2204  /** \brief Converts a PCL object to a vtk polydata object.
2205  * \param[in] geometry_handler the geometry handler object used to extract the XYZ data
2206  * \param[out] polydata the resultant polydata containing the cloud
2207  * \param[out] initcells a list of cell indices used for the conversion. This can be set once and then passed
2208  * around to speed up the conversion.
2209  */
2210  void
2211  convertPointCloudToVTKPolyData (const GeometryHandlerConstPtr &geometry_handler,
2212  vtkSmartPointer<vtkPolyData> &polydata,
2213  vtkSmartPointer<vtkIdTypeArray> &initcells);
2214 
2215  /** \brief Updates a set of cells (vtkIdTypeArray) if the number of points in a cloud changes
2216  * \param[out] cells the vtkIdTypeArray object (set of cells) to update
2217  * \param[out] initcells a previously saved set of cells. If the number of points in the current cloud is
2218  * higher than the number of cells in \a cells, and initcells contains enough data, then a copy from it
2219  * will be made instead of regenerating the entire array.
2220  * \param[in] nr_points the number of points in the new cloud. This dictates how many cells we need to
2221  * generate
2222  */
2223  void
2224  updateCells (vtkSmartPointer<vtkIdTypeArray> &cells,
2226  vtkIdType nr_points);
2227 
2228  /** \brief Internal function which converts the information present in the geometric
2229  * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
2230  * all the required information to the internal cloud_actor_map_ object.
2231  * \param[in] geometry_handler the geometric handler that contains the XYZ data
2232  * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
2233  * \param[in] id the point cloud object id
2234  * \param[in] viewport the view port where the Point Cloud should be added
2235  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
2236  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
2237  */
2238  template <typename PointT> bool
2239  fromHandlersToScreen (const PointCloudGeometryHandler<PointT> &geometry_handler,
2240  const PointCloudColorHandler<PointT> &color_handler,
2241  const std::string &id,
2242  int viewport,
2243  const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2244  const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2245 
2246  /** \brief Internal function which converts the information present in the geometric
2247  * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
2248  * all the required information to the internal cloud_actor_map_ object.
2249  * \param[in] geometry_handler the geometric handler that contains the XYZ data
2250  * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
2251  * \param[in] id the point cloud object id
2252  * \param[in] viewport the view port where the Point Cloud should be added
2253  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
2254  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
2255  */
2256  template <typename PointT> bool
2257  fromHandlersToScreen (const PointCloudGeometryHandler<PointT> &geometry_handler,
2258  const ColorHandlerConstPtr &color_handler,
2259  const std::string &id,
2260  int viewport,
2261  const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2262  const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2263 
2264  /** \brief Internal function which converts the information present in the geometric
2265  * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
2266  * all the required information to the internal cloud_actor_map_ object.
2267  * \param[in] geometry_handler the geometric handler that contains the XYZ data
2268  * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
2269  * \param[in] id the point cloud object id
2270  * \param[in] viewport the view port where the Point Cloud should be added
2271  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
2272  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
2273  */
2274  bool
2275  fromHandlersToScreen (const GeometryHandlerConstPtr &geometry_handler,
2276  const ColorHandlerConstPtr &color_handler,
2277  const std::string &id,
2278  int viewport,
2279  const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2280  const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2281 
2282  /** \brief Internal function which converts the information present in the geometric
2283  * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
2284  * all the required information to the internal cloud_actor_map_ object.
2285  * \param[in] geometry_handler the geometric handler that contains the XYZ data
2286  * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
2287  * \param[in] id the point cloud object id
2288  * \param[in] viewport the view port where the Point Cloud should be added
2289  * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
2290  * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
2291  */
2292  template <typename PointT> bool
2293  fromHandlersToScreen (const GeometryHandlerConstPtr &geometry_handler,
2294  const PointCloudColorHandler<PointT> &color_handler,
2295  const std::string &id,
2296  int viewport,
2297  const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
2298  const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
2299 
2300  /** \brief Allocate a new polydata smartpointer. Internal
2301  * \param[out] polydata the resultant poly data
2302  */
2303  void
2304  allocVtkPolyData (vtkSmartPointer<vtkAppendPolyData> &polydata);
2305 
2306  /** \brief Allocate a new polydata smartpointer. Internal
2307  * \param[out] polydata the resultant poly data
2308  */
2309  void
2310  allocVtkPolyData (vtkSmartPointer<vtkPolyData> &polydata);
2311 
2312  /** \brief Allocate a new unstructured grid smartpointer. Internal
2313  * \param[out] polydata the resultant poly data
2314  */
2315  void
2317 
2318  /** \brief Transform the point cloud viewpoint to a transformation matrix
2319  * \param[in] origin the camera origin
2320  * \param[in] orientation the camera orientation
2321  * \param[out] transformation the camera transformation matrix
2322  */
2323  void
2324  getTransformationMatrix (const Eigen::Vector4f &origin,
2325  const Eigen::Quaternion<float> &orientation,
2326  Eigen::Matrix4f &transformation);
2327 
2328  /** \brief Fills a vtkTexture structure from pcl::TexMaterial.
2329  * \param[in] tex_mat texture material in PCL format
2330  * \param[out] vtk_tex texture material in VTK format
2331  * \return 0 on success and -1 else.
2332  * \note for now only image based textures are supported, image file must be in
2333  * tex_file attribute of \a tex_mat.
2334  */
2335  int
2336  textureFromTexMaterial (const pcl::TexMaterial& tex_mat,
2337  vtkTexture* vtk_tex) const;
2338 
2339  /** \brief Get camera file for camera parameter saving/restoring from command line.
2340  * Camera filename is calculated using sha1 value of all paths of input .pcd files
2341  * \return empty string if failed.
2342  */
2343  std::string
2344  getUniqueCameraFile (int argc, char **argv);
2345 
2346  //There's no reason these conversion functions shouldn't be public and static so others can use them.
2347  public:
2348  /** \brief Convert Eigen::Matrix4f to vtkMatrix4x4
2349  * \param[in] m the input Eigen matrix
2350  * \param[out] vtk_matrix the resultant VTK matrix
2351  */
2352  static void
2353  convertToVtkMatrix (const Eigen::Matrix4f &m,
2354  vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
2355 
2356  /** \brief Convert origin and orientation to vtkMatrix4x4
2357  * \param[in] origin the point cloud origin
2358  * \param[in] orientation the point cloud orientation
2359  * \param[out] vtk_matrix the resultant VTK 4x4 matrix
2360  */
2361  static void
2362  convertToVtkMatrix (const Eigen::Vector4f &origin,
2363  const Eigen::Quaternion<float> &orientation,
2364  vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
2365 
2366  /** \brief Convert vtkMatrix4x4 to an Eigen4f
2367  * \param[in] vtk_matrix the original VTK 4x4 matrix
2368  * \param[out] m the resultant Eigen 4x4 matrix
2369  */
2370  static void
2372  Eigen::Matrix4f &m);
2373 
2374  };
2375  }
2376 }
2377 
2378 #include <pcl/visualization/impl/pcl_visualizer.hpp>
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
std::vector< PointCloud< PointT >, Eigen::aligned_allocator< PointCloud< PointT > > > CloudVectorType
Definition: point_cloud.h:412
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:414
/brief Class representing 3D area picking events.
Camera class holds a set of camera parameters together with the window pos/size.
Definition: common.h:153
/brief Class representing key hit/release events
PCL Visualizer main class.
void close()
Stop the interaction and close the visualizaton window.
bool setPointCloudRenderingProperties(int property, double val1, double val2, double val3, const std::string &id="cloud", int viewport=0)
Set the rendering properties of a PointCloud (3x values - e.g., RGB)
bool addPolygonMesh(const pcl::PolygonMesh &polymesh, const std::string &id="polygon", int viewport=0)
Add a PolygonMesh object to screen.
void createViewPort(double xmin, double ymin, double xmax, double ymax, int &viewport)
Create a new viewport from [xmin,ymin] -> [xmax,ymax].
void renderViewTesselatedSphere(int xres, int yres, pcl::PointCloud< pcl::PointXYZ >::CloudVectorType &cloud, std::vector< Eigen::Matrix4f, Eigen::aligned_allocator< Eigen::Matrix4f > > &poses, std::vector< float > &enthropies, int tesselation_level, float view_angle=45, float radius_sphere=1, bool use_vertices=true)
The purpose of this method is to render a CAD model added to the visualizer from different viewpoints...
shared_ptr< PCLVisualizer > Ptr
void setPosition(int x, int y)
Set the position in screen coordinates.
bool addPointCloud(const pcl::PCLPointCloud2::ConstPtr &cloud, const GeometryHandlerConstPtr &geometry_handler, const Eigen::Vector4f &sensor_origin, const Eigen::Quaternion< float > &sensor_orientation, const std::string &id="cloud", int viewport=0)
Add a binary blob Point Cloud to screen.
bool addPointCloud(const pcl::PCLPointCloud2::ConstPtr &cloud, const GeometryHandlerConstPtr &geometry_handler, const ColorHandlerConstPtr &color_handler, const Eigen::Vector4f &sensor_origin, const Eigen::Quaternion< float > &sensor_orientation, const std::string &id="cloud", int viewport=0)
Add a binary blob Point Cloud to screen.
bool removePointCloud(const std::string &id="cloud", int viewport=0)
Removes a Point Cloud from screen, based on a given ID.
bool updateCoordinateSystemPose(const std::string &id, const Eigen::Affine3f &pose)
Set the pose of an existing coordinate system.
boost::signals2::connection registerAreaPickingCallback(std::function< void(const pcl::visualization::AreaPickingEvent &)> cb)
Register a callback function for area picking events.
bool addPointCloud(const pcl::PointCloud< pcl::PointXYZRGBA >::ConstPtr &cloud, const std::string &id="cloud", int viewport=0)
Add a PointXYZRGBA Point Cloud to screen.
static void convertToVtkMatrix(const Eigen::Matrix4f &m, vtkSmartPointer< vtkMatrix4x4 > &vtk_matrix)
Convert Eigen::Matrix4f to vtkMatrix4x4.
bool addTextureMesh(const pcl::TextureMesh &polymesh, const std::string &id="texture", int viewport=0)
Add a TextureMesh object to screen.
boost::signals2::connection registerMouseCallback(void(T::*callback)(const pcl::visualization::MouseEvent &, void *), T &instance, void *cookie=nullptr)
Register a callback function for mouse events.
GeometryHandler::Ptr GeometryHandlerPtr
bool addCorrespondences(const typename pcl::PointCloud< PointT >::ConstPtr &source_points, const typename pcl::PointCloud< PointT >::ConstPtr &target_points, const pcl::Correspondences &correspondences, const std::string &id="correspondences", int viewport=0)
Add the specified correspondences to the display.
bool setShapeRenderingProperties(int property, double val1, double val2, const std::string &id, int viewport=0)
Set the rendering properties of a shape (2x values - e.g., LUT minmax values)
void setCameraPosition(double pos_x, double pos_y, double pos_z, double view_x, double view_y, double view_z, double up_x, double up_y, double up_z, int viewport=0)
Set the camera pose given by position, viewpoint and up vector.
vtkSmartPointer< vtkRenderWindowInteractor > interactor_
The render window interactor.
boost::signals2::connection registerPointPickingCallback(std::function< void(const pcl::visualization::PointPickingEvent &)> cb)
Register a callback function for point picking events.
CloudActorMapPtr getCloudActorMap()
Return a pointer to the CloudActorMap this visualizer uses.
void setupInteractor(vtkRenderWindowInteractor *iren, vtkRenderWindow *win, vtkInteractorStyle *style)
Set up PCLVisualizer with custom interactor style for a given vtkRenderWindowInteractor object attach...
bool addPlane(const pcl::ModelCoefficients &coefficients, const std::string &id="plane", int viewport=0)
Add a plane from a set of given model coefficients.
bool removeCoordinateSystem(const std::string &id="reference", int viewport=0)
Removes a previously added 3D axes (coordinate system)
vtkSmartPointer< vtkRendererCollection > getRendererCollection()
Return a pointer to the underlying VTK Renderer Collection.
bool updatePolygonMesh(const pcl::PolygonMesh &polymesh, const std::string &id="polygon")
Update a PolygonMesh object on screen.
void saveCameraParameters(const std::string &file)
Save the camera parameters to disk, as a .cam file.
void addCoordinateSystem(double scale, const Eigen::Affine3f &t, const std::string &id="reference", int viewport=0)
Adds 3D axes describing a coordinate system to screen at x, y, z, Roll,Pitch,Yaw.
bool updateColorHandlerIndex(const std::string &id, int index)
Update/set the color index of a rendered PointCloud based on its ID.
void setBackgroundColor(const double &r, const double &g, const double &b, int viewport=0)
Set the viewport's background color.
bool addText(const std::string &text, int xpos, int ypos, double r, double g, double b, const std::string &id="", int viewport=0)
Add a text to screen.
virtual ~PCLVisualizer()
PCL Visualizer destructor.
bool updateShapePose(const std::string &id, const Eigen::Affine3f &pose)
Set the pose of an existing shape.
void setRepresentationToSurfaceForAllActors()
Changes the visual representation for all actors to surface representation.
void setRepresentationToWireframeForAllActors()
Changes the visual representation for all actors to wireframe representation.
bool removeAllCoordinateSystems(int viewport=0)
Removes all existing 3D axes (coordinate systems)
bool addPointCloud(const pcl::PointCloud< pcl::PointXYZL >::ConstPtr &cloud, const std::string &id="cloud", int viewport=0)
Add a PointXYZL Point Cloud to screen.
void addCoordinateSystem(double scale=1.0, const std::string &id="reference", int viewport=0)
Adds 3D axes describing a coordinate system to screen at 0,0,0.
boost::signals2::connection registerKeyboardCallback(void(T::*callback)(const pcl::visualization::KeyboardEvent &, void *), T &instance, void *cookie=nullptr)
Register a callback function for keyboard events.
bool updatePointCloudPose(const std::string &id, const Eigen::Affine3f &pose)
Set the pose of an existing point cloud.
bool setPointCloudSelected(const bool selected, const std::string &id="cloud")
Set whether the point cloud is selected or not.
bool cameraParamsSet() const
Checks whether the camera parameters were manually loaded.
bool updateText(const std::string &text, int xpos, int ypos, const std::string &id="")
Update a text to screen.
void resetCameraViewpoint(const std::string &id="cloud")
Reset the camera direction from {0, 0, 0} to the center_{x, y, z} of a given dataset.
bool addModelFromPolyData(vtkSmartPointer< vtkPolyData > polydata, const std::string &id="PolyData", int viewport=0)
Add a vtkPolydata as a mesh.
bool updatePointCloud(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &cloud, const std::string &id="cloud")
Updates the XYZ data for an existing cloud object id on screen.
bool addText(const std::string &text, int xpos, int ypos, const std::string &id="", int viewport=0)
Add a text to screen.
boost::signals2::connection registerAreaPickingCallback(void(T::*callback)(const pcl::visualization::AreaPickingEvent &, void *), T &instance, void *cookie=nullptr)
Register a callback function for area picking events.
bool addLine(const pcl::ModelCoefficients &coefficients, const std::string &id="line", int viewport=0)
Add a line from a set of given model coefficients.
bool addCircle(const pcl::ModelCoefficients &coefficients, const std::string &id="circle", int viewport=0)
Add a circle from a set of given model coefficients.
PCLVisualizer(vtkSmartPointer< vtkRenderer > ren, vtkSmartPointer< vtkRenderWindow > wind, const std::string &name="", const bool create_interactor=true)
PCL Visualizer constructor.
bool addModelFromPLYFile(const std::string &filename, vtkSmartPointer< vtkTransform > transform, const std::string &id="PLYModel", int viewport=0)
Add a PLYmodel as a mesh and applies given transformation.
bool cameraFileLoaded() const
Checks whether a camera file were automatically loaded.
void createViewPortCamera(const int viewport)
Create a new separate camera for the given viewport.
void getCameras(std::vector< Camera > &cameras)
Get the current camera parameters.
std::string getCameraFile() const
Get camera file for camera parameter saving/restoring.
bool addCube(float x_min, float x_max, float y_min, float y_max, float z_min, float z_max, double r=1.0, double g=1.0, double b=1.0, const std::string &id="cube", int viewport=0)
Add a cube.
bool addCube(const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth, const std::string &id="cube", int viewport=0)
Add a cube from a set of given model coefficients.
ShapeActorMapPtr getShapeActorMap()
Return a pointer to the ShapeActorMap this visualizer uses.
GeometryHandler::ConstPtr GeometryHandlerConstPtr
void setFullScreen(bool mode)
Enables/Disabled the underlying window mode to full screen.
static void convertToVtkMatrix(const Eigen::Vector4f &origin, const Eigen::Quaternion< float > &orientation, vtkSmartPointer< vtkMatrix4x4 > &vtk_matrix)
Convert origin and orientation to vtkMatrix4x4.
bool wasStopped() const
Returns true when the user tried to close the window.
void setLookUpTableID(const std::string id)
Set the ID of a cloud or shape to be used for LUT display.
bool addPlane(const pcl::ModelCoefficients &coefficients, double x, double y, double z, const std::string &id="plane", int viewport=0)
bool updatePointCloud(const pcl::PointCloud< pcl::PointXYZRGB >::ConstPtr &cloud, const std::string &id="cloud")
Updates the XYZRGB data for an existing cloud object id on screen.
void setCameraFieldOfView(double fovy, int viewport=0)
Set the camera vertical field of view.
void removeOrientationMarkerWidgetAxes()
Disables the Orientatation Marker Widget so it is removed from the renderer.
void renderView(int xres, int yres, pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud)
Renders a virtual scene as seen from the camera viewpoint and returns the rendered point cloud.
bool addCone(const pcl::ModelCoefficients &coefficients, const std::string &id="cone", int viewport=0)
Add a cone from a set of given model coefficients.
int getGeometryHandlerIndex(const std::string &id)
Get the geometry handler index of a rendered PointCloud based on its ID.
void enableEDLRendering(int viewport=0)
Eye-Dome Lighting makes dark areas to improve depth perception See https://www.kitware....
void spinOnce(int time=1, bool force_redraw=false)
Spin once method.
PCLVisualizer(const std::string &name="", const bool create_interactor=true)
PCL Visualizer constructor.
void setSize(int xw, int yw)
Set the window size in screen coordinates.
bool updateText(const std::string &text, int xpos, int ypos, int fontsize, double r, double g, double b, const std::string &id="")
Update a text to screen.
bool removeAllPointClouds(int viewport=0)
Remove all point cloud data on screen from the given viewport.
ColorHandler::ConstPtr ColorHandlerConstPtr
bool addPointCloud(const pcl::PCLPointCloud2::ConstPtr &cloud, const ColorHandlerConstPtr &color_handler, const Eigen::Vector4f &sensor_origin, const Eigen::Quaternion< float > &sensor_orientation, const std::string &id="cloud", int viewport=0)
Add a binary blob Point Cloud to screen.
bool addModelFromPLYFile(const std::string &filename, const std::string &id="PLYModel", int viewport=0)
Add a PLYmodel as a mesh.
void setCameraParameters(const Camera &camera, int viewport=0)
Set the camera parameters by given a full camera data structure.
boost::signals2::connection registerPointPickingCallback(void(T::*callback)(const pcl::visualization::PointPickingEvent &, void *), T &instance, void *cookie=nullptr)
Register a callback function for point picking events.
bool addText(const std::string &text, int xpos, int ypos, int fontsize, double r, double g, double b, const std::string &id="", int viewport=0)
Add a text to screen.
void setUseVbos(bool use_vbos)
Use Vertex Buffer Objects renderers.
bool loadCameraParameters(const std::string &file)
Load camera parameters from a camera parameters file.
void setShowFPS(bool show_fps)
Sets whether the 2D overlay text showing the framerate of the window is displayed or not.
bool getCameraParameters(int argc, char **argv)
Search for camera parameters at the command line and set them internally.
int getColorHandlerIndex(const std::string &id)
Get the color handler index of a rendered PointCloud based on its ID.
void setupInteractor(vtkRenderWindowInteractor *iren, vtkRenderWindow *win)
Set up our unique PCL interactor style for a given vtkRenderWindowInteractor object attached to a giv...
void setCameraClipDistances(double near, double far, int viewport=0)
Set the camera clipping distances.
void createInteractor()
Create the internal Interactor object.
bool addCube(const pcl::ModelCoefficients &coefficients, const std::string &id="cube", int viewport=0)
Add a cube from a set of given model coefficients.
bool removeAllShapes(int viewport=0)
Remove all 3D shape data on screen from the given viewport.
float getFPS() const
Get the current rendering framerate.
bool addPointCloudPrincipalCurvatures(const typename pcl::PointCloud< PointNT >::ConstPtr &cloud, const typename pcl::PointCloud< pcl::PrincipalCurvatures >::ConstPtr &pcs, int level=100, float scale=1.0f, const std::string &id="cloud", int viewport=0)
Add the estimated principal curvatures of a Point Cloud to screen.
boost::signals2::connection registerKeyboardCallback(void(*callback)(const pcl::visualization::KeyboardEvent &, void *), void *cookie=nullptr)
Register a callback function for keyboard events.
bool setShapeRenderingProperties(int property, double value, const std::string &id, int viewport=0)
Set the rendering properties of a shape.
void initCameraParameters()
Initialize camera parameters with some default values.
vtkSmartPointer< vtkRenderWindow > getRenderWindow()
Return a pointer to the underlying VTK Render Window used.
PCLVisualizer(int &argc, char **argv, const std::string &name="", PCLVisualizerInteractorStyle *style=PCLVisualizerInteractorStyle::New(), const bool create_interactor=true)
PCL Visualizer constructor.
void setCameraPosition(double pos_x, double pos_y, double pos_z, double up_x, double up_y, double up_z, int viewport=0)
Set the camera location and viewup according to the given arguments.
void resetCamera()
Reset camera parameters and render.
boost::signals2::connection registerMouseCallback(void(*callback)(const pcl::visualization::MouseEvent &, void *), void *cookie=nullptr)
Register a callback function for mouse events.
void addCoordinateSystem(double scale, float x, float y, float z, const std::string &id="reference", int viewport=0)
Adds 3D axes describing a coordinate system to screen at x, y, z.
bool setShapeRenderingProperties(int property, double val1, double val2, double val3, const std::string &id, int viewport=0)
Set the rendering properties of a shape (3x values - e.g., RGB)
bool removePolygonMesh(const std::string &id="polygon", int viewport=0)
Removes a PolygonMesh from screen, based on a given ID.
bool addPointCloud(const pcl::PointCloud< pcl::PointXYZRGB >::ConstPtr &cloud, const std::string &id="cloud", int viewport=0)
Add a PointXYZRGB Point Cloud to screen.
bool updateText(const std::string &text, int xpos, int ypos, double r, double g, double b, const std::string &id="")
Update a text to screen.
bool contains(const std::string &id) const
Check if the cloud, shape, or coordinate with the given id was already added to this visualizer.
void setWindowName(const std::string &name)
Set the visualizer window name.
void setWindowBorders(bool mode)
Enables or disable the underlying window borders.
boost::signals2::connection registerPointPickingCallback(void(*callback)(const pcl::visualization::PointPickingEvent &, void *), void *cookie=nullptr)
Register a callback function for point picking events.
bool updatePointCloud(const pcl::PointCloud< pcl::PointXYZL >::ConstPtr &cloud, const std::string &id="cloud")
Updates the XYZL data for an existing cloud object id on screen.
bool removeText3D(const std::string &id="cloud", int viewport=0)
Removes an added 3D text from the scene, based on a given ID.
boost::signals2::connection registerAreaPickingCallback(void(*callback)(const pcl::visualization::AreaPickingEvent &, void *), void *cookie=nullptr)
Register a callback function for area picking events.
bool setPointCloudRenderingProperties(int property, double value, const std::string &id="cloud", int viewport=0)
Set the rendering properties of a PointCloud.
bool getPointCloudRenderingProperties(RenderingProperties property, double &val1, double &val2, double &val3, const std::string &id="cloud")
Get the rendering properties of a PointCloud.
void saveScreenshot(const std::string &file)
Save the current rendered image to disk, as a PNG screenshot.
PCLVisualizer(int &argc, char **argv, vtkSmartPointer< vtkRenderer > ren, vtkSmartPointer< vtkRenderWindow > wind, const std::string &name="", PCLVisualizerInteractorStyle *style=PCLVisualizerInteractorStyle::New(), const bool create_interactor=true)
PCL Visualizer constructor.
static void convertToEigenMatrix(const vtkSmartPointer< vtkMatrix4x4 > &vtk_matrix, Eigen::Matrix4f &m)
Convert vtkMatrix4x4 to an Eigen4f.
bool addPolylineFromPolygonMesh(const pcl::PolygonMesh &polymesh, const std::string &id="polyline", int viewport=0)
Add a Polygonline from a polygonMesh object to screen.
bool getPointCloudRenderingProperties(int property, double &value, const std::string &id="cloud")
Get the rendering properties of a PointCloud.
bool updatePointCloud(const pcl::PointCloud< pcl::PointXYZRGBA >::ConstPtr &cloud, const std::string &id="cloud")
Updates the XYZRGBA data for an existing cloud object id on screen.
bool removeShape(const std::string &id="cloud", int viewport=0)
Removes an added shape from screen (line, polygon, etc.), based on a given ID.
boost::signals2::connection registerMouseCallback(std::function< void(const pcl::visualization::MouseEvent &)> cb)
Register a callback function for mouse events.
void resetStoppedFlag()
Set the stopped flag back to false.
shared_ptr< const PCLVisualizer > ConstPtr
void getCameraParameters(Camera &camera, int viewport=0) const
Get camera parameters of a given viewport (0 means default viewport).
boost::signals2::connection registerKeyboardCallback(std::function< void(const pcl::visualization::KeyboardEvent &)> cb)
Register a callback std::function for keyboard events.
Eigen::Affine3f getViewerPose(int viewport=0)
Get the current viewing pose.
bool addPointCloud(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &cloud, const std::string &id="cloud", int viewport=0)
Add a PointXYZ Point Cloud to screen.
void addOrientationMarkerWidgetAxes(vtkRenderWindowInteractor *interactor)
Adds a widget which shows an interactive axes display for orientation.
bool addEllipsoid(const Eigen::Isometry3d &transform, double radius_x, double radius_y, double radius_z, const std::string &id="ellipsoid", int viewport=0)
Add an ellipsoid from the given parameters.
bool addCylinder(const pcl::ModelCoefficients &coefficients, const std::string &id="cylinder", int viewport=0)
Add a cylinder from a set of given model coefficients.
void setRepresentationToPointsForAllActors()
Changes the visual representation for all actors to points representation.
bool setPointCloudRenderingProperties(int property, double val1, double val2, const std::string &id="cloud", int viewport=0)
Set the rendering properties of a PointCloud (2x values - e.g., LUT minmax values)
bool addLine(const pcl::ModelCoefficients &coefficients, const char *id="line", int viewport=0)
Add a line from a set of given model coefficients.
bool updateCorrespondences(const typename pcl::PointCloud< PointT >::ConstPtr &source_points, const typename pcl::PointCloud< PointT >::ConstPtr &target_points, const pcl::Correspondences &correspondences, const std::string &id="correspondences", int viewport=0)
Update the specified correspondences to the display.
void removeCorrespondences(const std::string &id="correspondences", int viewport=0)
Remove the specified correspondences from the display.
bool addModelFromPolyData(vtkSmartPointer< vtkPolyData > polydata, vtkSmartPointer< vtkTransform > transform, const std::string &id="PolyData", int viewport=0)
Add a vtkPolydata as a mesh.
void setCameraParameters(const Eigen::Matrix3f &intrinsics, const Eigen::Matrix4f &extrinsics, int viewport=0)
Set the camera parameters via an intrinsics and and extrinsics matrix.
vtkSmartPointer< PCLVisualizerInteractorStyle > getInteractorStyle()
Get a pointer to the current interactor style used.
bool addSphere(const pcl::ModelCoefficients &coefficients, const std::string &id="sphere", int viewport=0)
Add a sphere from a set of given model coefficients.
PCLVisualizerInteractorStyle defines an unique, custom VTK based interactory style for PCL Visualizer...
static PCLVisualizerInteractorStyle * New()
shared_ptr< const PointCloudColorHandler< PointCloud > > ConstPtr
Base Handler class for PointCloud colors.
shared_ptr< const PointCloudGeometryHandler< PointCloud > > ConstPtr
Base handler class for PointCloud geometry.
/brief Class representing 3D point picking events.
PCL_EXPORTS vtkIdType fillCells(std::vector< int > &lookup, const std::vector< pcl::Vertices > &vertices, vtkSmartPointer< vtkCellArray > cell_array, int max_size_of_polygon)
RenderingProperties
Set of rendering properties.
Definition: common.h:102
shared_ptr< CloudActorMap > CloudActorMapPtr
Definition: actor_map.h:97
shared_ptr< ShapeActorMap > ShapeActorMapPtr
Definition: actor_map.h:100
shared_ptr< CoordinateActorMap > CoordinateActorMapPtr
Definition: actor_map.h:103
PCL_EXPORTS void allocVtkUnstructuredGrid(vtkSmartPointer< vtkUnstructuredGrid > &polydata)
Allocate a new unstructured grid smartpointer.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
#define PCL_EXPORTS
Definition: pcl_macros.h:323
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Definition: pcl_macros.h:156
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
A point structure representing Euclidean xyz coordinates, and the RGB color.