Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/visualization/include/pcl/visualization/pcl_visualizer.h
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  */
00038 #ifndef PCL_PCL_VISUALIZER_H_
00039 #define PCL_PCL_VISUALIZER_H_
00040 
00041 // PCL includes
00042 #include <pcl/correspondence.h>
00043 #include <pcl/ModelCoefficients.h>
00044 #include <pcl/PolygonMesh.h>
00045 //
00046 #include <pcl/console/print.h>
00047 #include <pcl/visualization/common/actor_map.h>
00048 #include <pcl/visualization/common/common.h>
00049 #include <pcl/visualization/point_cloud_geometry_handlers.h>
00050 #include <pcl/visualization/point_cloud_color_handlers.h>
00051 #include <pcl/visualization/point_picking_event.h>
00052 #include <pcl/visualization/area_picking_event.h>
00053 #include <pcl/visualization/interactor_style.h>
00054 
00055 // VTK includes
00056 class vtkPolyData;
00057 class vtkTextActor;
00058 class vtkRenderWindow;
00059 class vtkOrientationMarkerWidget;
00060 class vtkAppendPolyData;
00061 class vtkRenderWindow;
00062 class vtkRenderWindowInteractor;
00063 class vtkTransform;
00064 class vtkInteractorStyle;
00065 class vtkLODActor;
00066 class vtkProp;
00067 class vtkActor;
00068 class vtkDataSet;
00069 class vtkUnstructuredGrid;
00070 
00071 namespace pcl
00072 {
00073   template <typename T> class PointCloud;
00074   template <typename T> class PlanarPolygon;
00075 
00076   namespace visualization
00077   {
00078     /** \brief PCL Visualizer main class.
00079       * \author Radu B. Rusu
00080       * \ingroup visualization
00081       * \note This class can NOT be used across multiple threads. Only call functions of objects of this class
00082       * from the same thread that they were created in! Some methods, e.g. addPointCloud, will crash if called
00083       * from other threads.
00084       */
00085     class PCL_EXPORTS PCLVisualizer
00086     {
00087       public:
00088         typedef boost::shared_ptr<PCLVisualizer> Ptr;
00089         typedef boost::shared_ptr<const PCLVisualizer> ConstPtr;
00090 
00091         typedef PointCloudGeometryHandler<pcl::PCLPointCloud2> GeometryHandler;
00092         typedef GeometryHandler::Ptr GeometryHandlerPtr;
00093         typedef GeometryHandler::ConstPtr GeometryHandlerConstPtr;
00094 
00095         typedef PointCloudColorHandler<pcl::PCLPointCloud2> ColorHandler;
00096         typedef ColorHandler::Ptr ColorHandlerPtr;
00097         typedef ColorHandler::ConstPtr ColorHandlerConstPtr;
00098 
00099         /** \brief PCL Visualizer constructor.
00100           * \param[in] name the window name (empty by default)
00101           * \param[in] create_interactor if true (default), create an interactor, false otherwise
00102           */
00103         PCLVisualizer (const std::string &name = "", const bool create_interactor = true);
00104 
00105         /** \brief PCL Visualizer constructor.
00106           * \param[in] argc
00107           * \param[in] argv
00108           * \param[in] name the window name (empty by default)
00109           * \param[in] style interactor style (defaults to PCLVisualizerInteractorStyle)
00110           * \param[in] create_interactor if true (default), create an interactor, false otherwise
00111           */
00112         PCLVisualizer (int &argc, char **argv, const std::string &name = "",
00113             PCLVisualizerInteractorStyle* style = PCLVisualizerInteractorStyle::New (), const bool create_interactor = true);
00114 
00115         /** \brief PCL Visualizer destructor. */
00116         virtual ~PCLVisualizer ();
00117 
00118         /** \brief Enables/Disabled the underlying window mode to full screen.
00119           * \note This might or might not work, depending on your window manager.
00120           * See the VTK documentation for additional details.
00121           * \param[in] mode true for full screen, false otherwise
00122           */
00123         void
00124         setFullScreen (bool mode);
00125 
00126         /** \brief Set the visualizer window name.
00127           * \param[in] name the name of the window
00128           */
00129         void
00130         setWindowName (const std::string &name);
00131 
00132         /** \brief Enables or disable the underlying window borders.
00133           * \note This might or might not work, depending on your window manager.
00134           * See the VTK documentation for additional details.
00135           * \param[in] mode true for borders, false otherwise
00136           */
00137         void
00138         setWindowBorders (bool mode);
00139 
00140         /** \brief Register a callback boost::function for keyboard events
00141           * \param[in] cb a boost function that will be registered as a callback for a keyboard event
00142           * \return a connection object that allows to disconnect the callback function.
00143           */
00144         boost::signals2::connection
00145         registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> cb);
00146 
00147         /** \brief Register a callback function for keyboard events
00148           * \param[in] callback  the function that will be registered as a callback for a keyboard event
00149           * \param[in] cookie    user data that is passed to the callback
00150           * \return a connection object that allows to disconnect the callback function.
00151           */
00152         inline boost::signals2::connection
00153         registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = NULL)
00154         {
00155           return (registerKeyboardCallback (boost::bind (callback, _1, cookie)));
00156         }
00157 
00158         /** \brief Register a callback function for keyboard events
00159           * \param[in] callback  the member function that will be registered as a callback for a keyboard event
00160           * \param[in] instance  instance to the class that implements the callback function
00161           * \param[in] cookie    user data that is passed to the callback
00162           * \return a connection object that allows to disconnect the callback function.
00163           */
00164         template<typename T> inline boost::signals2::connection
00165         registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = NULL)
00166         {
00167           return (registerKeyboardCallback (boost::bind (callback,  boost::ref (instance), _1, cookie)));
00168         }
00169 
00170         /** \brief Register a callback function for mouse events
00171           * \param[in] cb a boost function that will be registered as a callback for a mouse event
00172           * \return a connection object that allows to disconnect the callback function.
00173           */
00174         boost::signals2::connection
00175         registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> cb);
00176 
00177         /** \brief Register a callback function for mouse events
00178           * \param[in] callback  the function that will be registered as a callback for a mouse event
00179           * \param[in] cookie    user data that is passed to the callback
00180           * \return a connection object that allows to disconnect the callback function.
00181           */
00182         inline boost::signals2::connection
00183         registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = NULL)
00184         {
00185           return (registerMouseCallback (boost::bind (callback, _1, cookie)));
00186         }
00187 
00188         /** \brief Register a callback function for mouse events
00189           * \param[in] callback  the member function that will be registered as a callback for a mouse event
00190           * \param[in] instance  instance to the class that implements the callback function
00191           * \param[in] cookie    user data that is passed to the callback
00192           * \return a connection object that allows to disconnect the callback function.
00193           */
00194         template<typename T> inline boost::signals2::connection
00195         registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = NULL)
00196         {
00197           return (registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
00198         }
00199 
00200         /** \brief Register a callback function for point picking events
00201           * \param[in] cb a boost function that will be registered as a callback for a point picking event
00202           * \return a connection object that allows to disconnect the callback function.
00203           */
00204         boost::signals2::connection
00205         registerPointPickingCallback (boost::function<void (const pcl::visualization::PointPickingEvent&)> cb);
00206 
00207         /** \brief Register a callback function for point picking events
00208           * \param[in] callback  the function that will be registered as a callback for a point picking event
00209           * \param[in] cookie    user data that is passed to the callback
00210           * \return a connection object that allows to disconnect the callback function.
00211           */
00212         boost::signals2::connection
00213         registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = NULL);
00214 
00215         /** \brief Register a callback function for point picking events
00216           * \param[in] callback  the member function that will be registered as a callback for a point picking event
00217           * \param[in] instance  instance to the class that implements the callback function
00218           * \param[in] cookie    user data that is passed to the callback
00219           * \return a connection object that allows to disconnect the callback function.
00220           */
00221         template<typename T> inline boost::signals2::connection
00222         registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = NULL)
00223         {
00224           return (registerPointPickingCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
00225         }
00226 
00227         /** \brief Register a callback function for area picking events
00228           * \param[in] cb a boost function that will be registered as a callback for an area picking event
00229           * \return a connection object that allows to disconnect the callback function.
00230           */
00231         boost::signals2::connection
00232         registerAreaPickingCallback (boost::function<void (const pcl::visualization::AreaPickingEvent&)> cb);
00233 
00234         /** \brief Register a callback function for area picking events
00235           * \param[in] callback  the function that will be registered as a callback for an area picking event
00236           * \param[in] cookie    user data that is passed to the callback
00237           * \return a connection object that allows to disconnect the callback function.
00238           */
00239         boost::signals2::connection
00240         registerAreaPickingCallback (void (*callback) (const pcl::visualization::AreaPickingEvent&, void*), void* cookie = NULL);
00241 
00242         /** \brief Register a callback function for area picking events
00243           * \param[in] callback  the member function that will be registered as a callback for an area picking event
00244           * \param[in] instance  instance to the class that implements the callback function
00245           * \param[in] cookie    user data that is passed to the callback
00246           * \return a connection object that allows to disconnect the callback function.
00247           */
00248         template<typename T> inline boost::signals2::connection
00249         registerAreaPickingCallback (void (T::*callback) (const pcl::visualization::AreaPickingEvent&, void*), T& instance, void* cookie = NULL)
00250         {
00251           return (registerAreaPickingCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
00252         }
00253 
00254         /** \brief Spin method. Calls the interactor and runs an internal loop. */
00255         void
00256         spin ();
00257 
00258         /** \brief Spin once method. Calls the interactor and updates the screen once.
00259           *  \param[in] time - How long (in ms) should the visualization loop be allowed to run.
00260           *  \param[in] force_redraw - if false it might return without doing anything if the
00261           *  interactor's framerate does not require a redraw yet.
00262           */
00263         void
00264         spinOnce (int time = 1, bool force_redraw = false);
00265 
00266         /** \brief Adds a widget which shows an interactive axes display for orientation
00267          *  \param[in] interactor - Pointer to the vtk interactor object used by the PCLVisualizer window 
00268          */
00269         void
00270         addOrientationMarkerWidgetAxes (vtkRenderWindowInteractor* interactor);
00271         
00272         /** \brief Disables the Orientatation Marker Widget so it is removed from the renderer */
00273         void
00274         removeOrientationMarkerWidgetAxes ();
00275         
00276         /** \brief Adds 3D axes describing a coordinate system to screen at 0,0,0.
00277           * \param[in] scale the scale of the axes (default: 1)
00278           * \param[in] viewport the view port where the 3D axes should be added (default: all)
00279           */
00280         void
00281         addCoordinateSystem (double scale = 1.0, int viewport = 0);
00282 
00283         /** \brief Adds 3D axes describing a coordinate system to screen at x, y, z
00284           * \param[in] scale the scale of the axes (default: 1)
00285           * \param[in] x the X position of the axes
00286           * \param[in] y the Y position of the axes
00287           * \param[in] z the Z position of the axes
00288           * \param[in] viewport the view port where the 3D axes should be added (default: all)
00289           */
00290         void
00291         addCoordinateSystem (double scale, float x, float y, float z, int viewport = 0);
00292 
00293          /** \brief Adds 3D axes describing a coordinate system to screen at x, y, z, Roll,Pitch,Yaw
00294            *
00295            * \param[in] scale the scale of the axes (default: 1)
00296            * \param[in] t transformation matrix
00297            * \param[in] viewport the view port where the 3D axes should be added (default: all)
00298            *
00299            * RPY Angles
00300            * Rotate the reference frame by the angle roll about axis x
00301            * Rotate the reference frame by the angle pitch about axis y
00302            * Rotate the reference frame by the angle yaw about axis z
00303            *
00304            * Description:
00305            * Sets the orientation of the Prop3D.  Orientation is specified as
00306            * X,Y and Z rotations in that order, but they are performed as
00307            * RotateZ, RotateX, and finally RotateY.
00308            *
00309            * All axies use right hand rule. x=red axis, y=green axis, z=blue axis
00310            * z direction is point into the screen.
00311            *     z
00312            *      \
00313            *       \
00314            *        \
00315            *         -----------> x
00316            *         |
00317            *         |
00318            *         |
00319            *         |
00320            *         |
00321            *         |
00322            *         y
00323            */
00324         void
00325         addCoordinateSystem (double scale, const Eigen::Affine3f& t, int viewport = 0);
00326 
00327         /** \brief Removes a previously added 3D axes (coordinate system)
00328           * \param[in] viewport view port where the 3D axes should be removed from (default: all)
00329           */
00330         bool
00331         removeCoordinateSystem (int viewport = 0);
00332 
00333         /** \brief Removes a Point Cloud from screen, based on a given ID.
00334           * \param[in] id the point cloud object id (i.e., given on \a addPointCloud)
00335           * \param[in] viewport view port from where the Point Cloud should be removed (default: all)
00336           * \return true if the point cloud is successfully removed and false if the point cloud is
00337           * not actually displayed
00338           */
00339         bool
00340         removePointCloud (const std::string &id = "cloud", int viewport = 0);
00341 
00342         /** \brief Removes a PolygonMesh from screen, based on a given ID.
00343           * \param[in] id the polygon object id (i.e., given on \a addPolygonMesh)
00344           * \param[in] viewport view port from where the PolygonMesh should be removed (default: all)
00345           */
00346         inline bool
00347         removePolygonMesh (const std::string &id = "polygon", int viewport = 0)
00348         {
00349           // Polygon Meshes are represented internally as point clouds with special cell array structures since 1.4
00350           return (removePointCloud (id, viewport));
00351         }
00352 
00353         /** \brief Removes an added shape from screen (line, polygon, etc.), based on a given ID
00354           * \note This methods also removes PolygonMesh objects and PointClouds, if they match the ID
00355           * \param[in] id the shape object id (i.e., given on \a addLine etc.)
00356           * \param[in] viewport view port from where the Point Cloud should be removed (default: all)
00357           */
00358         bool
00359         removeShape (const std::string &id = "cloud", int viewport = 0);
00360 
00361         /** \brief Removes an added 3D text from the scene, based on a given ID
00362           * \param[in] id the 3D text id (i.e., given on \a addText3D etc.)
00363           * \param[in] viewport view port from where the 3D text should be removed (default: all)
00364           */
00365         bool
00366         removeText3D (const std::string &id = "cloud", int viewport = 0);
00367 
00368         /** \brief Remove all point cloud data on screen from the given viewport.
00369           * \param[in] viewport view port from where the clouds should be removed (default: all)
00370           */
00371         bool
00372         removeAllPointClouds (int viewport = 0);
00373 
00374         /** \brief Remove all 3D shape data on screen from the given viewport.
00375           * \param[in] viewport view port from where the shapes should be removed (default: all)
00376           */
00377         bool
00378         removeAllShapes (int viewport = 0);
00379 
00380         /** \brief Set the viewport's background color.
00381           * \param[in] r the red component of the RGB color
00382           * \param[in] g the green component of the RGB color
00383           * \param[in] b the blue component of the RGB color
00384           * \param[in] viewport the view port (default: all)
00385           */
00386         void
00387         setBackgroundColor (const double &r, const double &g, const double &b, int viewport = 0);
00388 
00389         /** \brief Add a text to screen
00390           * \param[in] text the text to add
00391           * \param[in] xpos the X position on screen where the text should be added
00392           * \param[in] ypos the Y position on screen where the text should be added
00393           * \param[in] id the text object id (default: equal to the "text" parameter)
00394           * \param[in] viewport the view port (default: all)
00395           */
00396         bool
00397         addText (const std::string &text,
00398                  int xpos, int ypos,
00399                  const std::string &id = "", int viewport = 0);
00400 
00401         /** \brief Add a text to screen
00402           * \param[in] text the text to add
00403           * \param[in] xpos the X position on screen where the text should be added
00404           * \param[in] ypos the Y position on screen where the text should be added
00405           * \param[in] r the red color value
00406           * \param[in] g the green color value
00407           * \param[in] b the blue color vlaue
00408           * \param[in] id the text object id (default: equal to the "text" parameter)
00409           * \param[in] viewport the view port (default: all)
00410           */
00411         bool
00412         addText (const std::string &text, int xpos, int ypos, double r, double g, double b,
00413                  const std::string &id = "", int viewport = 0);
00414 
00415         /** \brief Add a text to screen
00416           * \param[in] text the text to add
00417           * \param[in] xpos the X position on screen where the text should be added
00418           * \param[in] ypos the Y position on screen where the text should be added
00419           * \param[in] fontsize the fontsize of the text
00420           * \param[in] r the red color value
00421           * \param[in] g the green color value
00422           * \param[in] b the blue color vlaue
00423           * \param[in] id the text object id (default: equal to the "text" parameter)
00424           * \param[in] viewport the view port (default: all)
00425           */
00426         bool
00427         addText (const std::string &text, int xpos, int ypos, int fontsize, double r, double g, double b,
00428                  const std::string &id = "", int viewport = 0);
00429 
00430 
00431         /** \brief Update a text to screen
00432           * \param[in] text the text to update
00433           * \param[in] xpos the new X position on screen
00434           * \param[in] ypos the new Y position on screen 
00435           * \param[in] id the text object id (default: equal to the "text" parameter)
00436           */
00437         bool
00438         updateText (const std::string &text,
00439                     int xpos, int ypos,
00440                     const std::string &id = "");
00441 
00442         /** \brief Update a text to screen
00443           * \param[in] text the text to update
00444           * \param[in] xpos the new X position on screen
00445           * \param[in] ypos the new Y position on screen 
00446           * \param[in] r the red color value
00447           * \param[in] g the green color value
00448           * \param[in] b the blue color vlaue
00449           * \param[in] id the text object id (default: equal to the "text" parameter)
00450           */
00451         bool
00452         updateText (const std::string &text, 
00453                     int xpos, int ypos, double r, double g, double b,
00454                     const std::string &id = "");
00455 
00456         /** \brief Update a text to screen
00457           * \param[in] text the text to update
00458           * \param[in] xpos the new X position on screen
00459           * \param[in] ypos the new Y position on screen 
00460           * \param[in] fontsize the fontsize of the text
00461           * \param[in] r the red color value
00462           * \param[in] g the green color value
00463           * \param[in] b the blue color vlaue
00464           * \param[in] id the text object id (default: equal to the "text" parameter)
00465           */
00466         bool
00467         updateText (const std::string &text, 
00468                     int xpos, int ypos, int fontsize, double r, double g, double b,
00469                     const std::string &id = "");
00470 
00471         /** \brief Set the pose of an existing shape. 
00472           * 
00473           * Returns false if the shape doesn't exist, true if the pose was succesfully 
00474           * updated.
00475           *
00476           * \param[in] id the shape or cloud object id (i.e., given on \a addLine etc.)
00477           * \param[in] pose the new pose
00478           * \return false if no shape or cloud with the specified ID was found
00479           */
00480         bool
00481         updateShapePose (const std::string &id, const Eigen::Affine3f& pose);
00482 
00483         /** \brief Set the pose of an existing point cloud.
00484           *
00485           * Returns false if the point cloud doesn't exist, true if the pose was succesfully
00486           * updated.
00487           *
00488           * \param[in] id the point cloud object id (i.e., given on \a addPointCloud etc.)
00489           * \param[in] pose the new pose
00490           * \return false if no point cloud with the specified ID was found
00491           */
00492         bool
00493         updatePointCloudPose (const std::string &id, const Eigen::Affine3f& pose);
00494 
00495         /** \brief Add a 3d text to the scene
00496           * \param[in] text the text to add
00497           * \param[in] position the world position where the text should be added
00498           * \param[in] textScale the scale of the text to render
00499           * \param[in] r the red color value
00500           * \param[in] g the green color value
00501           * \param[in] b the blue color value
00502           * \param[in] id the text object id (default: equal to the "text" parameter)
00503           * \param[in] viewport the view port (default: all)
00504           */
00505         template <typename PointT> bool
00506         addText3D (const std::string &text,
00507                    const PointT &position,
00508                    double textScale = 1.0,
00509                    double r = 1.0, double g = 1.0, double b = 1.0,
00510                    const std::string &id = "", int viewport = 0);
00511 
00512         /** \brief Add the estimated surface normals of a Point Cloud to screen.
00513           * \param[in] cloud the input point cloud dataset containing XYZ data and normals
00514           * \param[in] level display only every level'th point (default: 100)
00515           * \param[in] scale the normal arrow scale (default: 0.02m)
00516           * \param[in] id the point cloud object id (default: cloud)
00517           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00518           */
00519         template <typename PointNT> bool
00520         addPointCloudNormals (const typename pcl::PointCloud<PointNT>::ConstPtr &cloud,
00521                               int level = 100, float scale = 0.02f,
00522                               const std::string &id = "cloud", int viewport = 0);
00523 
00524         /** \brief Add the estimated surface normals of a Point Cloud to screen.
00525           * \param[in] cloud the input point cloud dataset containing the XYZ data
00526           * \param[in] normals the input point cloud dataset containing the normal data
00527           * \param[in] level display only every level'th point (default: 100)
00528           * \param[in] scale the normal arrow scale (default: 0.02m)
00529           * \param[in] id the point cloud object id (default: cloud)
00530           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00531           */
00532         template <typename PointT, typename PointNT> bool
00533         addPointCloudNormals (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00534                               const typename pcl::PointCloud<PointNT>::ConstPtr &normals,
00535                               int level = 100, float scale = 0.02f,
00536                               const std::string &id = "cloud", int viewport = 0);
00537 
00538         /** \brief Add the estimated principal curvatures of a Point Cloud to screen.
00539           * \param[in] cloud the input point cloud dataset containing the XYZ data
00540           * \param[in] normals the input point cloud dataset containing the normal data
00541           * \param[in] pcs the input point cloud dataset containing the principal curvatures data
00542           * \param[in] level display only every level'th point. Default: 100
00543           * \param[in] scale the normal arrow scale. Default: 1.0
00544           * \param[in] id the point cloud object id. Default: "cloud"
00545           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00546           */
00547         bool
00548         addPointCloudPrincipalCurvatures (
00549             const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud,
00550             const pcl::PointCloud<pcl::Normal>::ConstPtr &normals,
00551             const pcl::PointCloud<pcl::PrincipalCurvatures>::ConstPtr &pcs,
00552             int level = 100, float scale = 1.0f,
00553             const std::string &id = "cloud", int viewport = 0);
00554 
00555         /** \brief Add the estimated surface intensity gradients of a Point Cloud to screen.
00556           * \param[in] cloud the input point cloud dataset containing the XYZ data
00557           * \param[in] gradients the input point cloud dataset containing the intensity gradient data
00558           * \param[in] level display only every level'th point (default: 100)
00559           * \param[in] scale the intensity gradient arrow scale (default: 1e-6m)
00560           * \param[in] id the point cloud object id (default: cloud)
00561           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00562           */
00563         template <typename PointT, typename GradientT> bool
00564         addPointCloudIntensityGradients (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00565                                          const typename pcl::PointCloud<GradientT>::ConstPtr &gradients,
00566                                          int level = 100, double scale = 1e-6,
00567                                          const std::string &id = "cloud", int viewport = 0);
00568 
00569         /** \brief Add a Point Cloud (templated) to screen.
00570           * \param[in] cloud the input point cloud dataset
00571           * \param[in] id the point cloud object id (default: cloud)
00572           * \param viewport the view port where the Point Cloud should be added (default: all)
00573           */
00574         template <typename PointT> bool
00575         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00576                        const std::string &id = "cloud", int viewport = 0);
00577 
00578         /** \brief Updates the XYZ data for an existing cloud object id on screen.
00579           * \param[in] cloud the input point cloud dataset
00580           * \param[in] id the point cloud object id to update (default: cloud)
00581           * \return false if no cloud with the specified ID was found
00582           */
00583         template <typename PointT> bool
00584         updatePointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00585                           const std::string &id = "cloud");
00586 
00587          /** \brief Updates the XYZ data for an existing cloud object id on screen.
00588            * \param[in] cloud the input point cloud dataset
00589            * \param[in] geometry_handler the geometry handler to use
00590            * \param[in] id the point cloud object id to update (default: cloud)
00591            * \return false if no cloud with the specified ID was found
00592            */
00593         template <typename PointT> bool
00594         updatePointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00595                           const PointCloudGeometryHandler<PointT> &geometry_handler,
00596                           const std::string &id = "cloud");
00597 
00598          /** \brief Updates the XYZ data for an existing cloud object id on screen.
00599            * \param[in] cloud the input point cloud dataset
00600            * \param[in] color_handler the color handler to use
00601            * \param[in] id the point cloud object id to update (default: cloud)
00602            * \return false if no cloud with the specified ID was found
00603            */
00604         template <typename PointT> bool
00605         updatePointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00606                           const PointCloudColorHandler<PointT> &color_handler,
00607                           const std::string &id = "cloud");
00608 
00609         /** \brief Add a Point Cloud (templated) to screen.
00610           * \param[in] cloud the input point cloud dataset
00611           * \param[in] geometry_handler use a geometry handler object to extract the XYZ data
00612           * \param[in] id the point cloud object id (default: cloud)
00613           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00614           */
00615         template <typename PointT> bool
00616         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00617                        const PointCloudGeometryHandler<PointT> &geometry_handler,
00618                        const std::string &id = "cloud", int viewport = 0);
00619 
00620         /** \brief Add a Point Cloud (templated) to screen.
00621           *
00622           * Because the geometry handler is given as a pointer, it will be pushed back to the list of available
00623           * handlers, rather than replacing the current active geometric handler. This makes it possible to
00624           * switch between different geometric handlers 'on-the-fly' at runtime, from the PCLVisualizer
00625           * interactor interface (using Alt+0..9).
00626           *
00627           * \param[in] cloud the input point cloud dataset
00628           * \param[in] geometry_handler use a geometry handler object to extract the XYZ data
00629           * \param[in] id the point cloud object id (default: cloud)
00630           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00631           */
00632         template <typename PointT> bool
00633         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00634                        const GeometryHandlerConstPtr &geometry_handler,
00635                        const std::string &id = "cloud", int viewport = 0);
00636 
00637         /** \brief Add a Point Cloud (templated) to screen.
00638           * \param[in] cloud the input point cloud dataset
00639           * \param[in] color_handler a specific PointCloud visualizer handler for colors
00640           * \param[in] id the point cloud object id (default: cloud)
00641           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00642           */
00643         template <typename PointT> bool
00644         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00645                        const PointCloudColorHandler<PointT> &color_handler,
00646                        const std::string &id = "cloud", int viewport = 0);
00647 
00648         /** \brief Add a Point Cloud (templated) to screen.
00649           *
00650           * Because the color handler is given as a pointer, it will be pushed back to the list of available
00651           * handlers, rather than replacing the current active color handler. This makes it possible to
00652           * switch between different color handlers 'on-the-fly' at runtime, from the PCLVisualizer
00653           * interactor interface (using 0..9).
00654           *
00655           * \param[in] cloud the input point cloud dataset
00656           * \param[in] color_handler a specific PointCloud visualizer handler for colors
00657           * \param[in] id the point cloud object id (default: cloud)
00658           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00659           */
00660         template <typename PointT> bool
00661         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00662                        const ColorHandlerConstPtr &color_handler,
00663                        const std::string &id = "cloud", int viewport = 0);
00664 
00665         /** \brief Add a Point Cloud (templated) to screen.
00666           *
00667           * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
00668           * available handlers, rather than replacing the current active handler. This makes it possible to
00669           * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
00670           * interface (using [Alt+]0..9).
00671           *
00672           * \param[in] cloud the input point cloud dataset
00673           * \param[in] geometry_handler a specific PointCloud visualizer handler for geometry
00674           * \param[in] color_handler a specific PointCloud visualizer handler for colors
00675           * \param[in] id the point cloud object id (default: cloud)
00676           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00677           */
00678         template <typename PointT> bool
00679         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00680                        const GeometryHandlerConstPtr &geometry_handler,
00681                        const ColorHandlerConstPtr &color_handler,
00682                        const std::string &id = "cloud", int viewport = 0);
00683 
00684         /** \brief Add a binary blob Point Cloud to screen.
00685           *
00686           * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
00687           * available handlers, rather than replacing the current active handler. This makes it possible to
00688           * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
00689           * interface (using [Alt+]0..9).
00690           *
00691           * \param[in] cloud the input point cloud dataset
00692           * \param[in] geometry_handler a specific PointCloud visualizer handler for geometry
00693           * \param[in] color_handler a specific PointCloud visualizer handler for colors
00694           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
00695           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
00696           * \param[in] id the point cloud object id (default: cloud)
00697           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00698           */
00699         bool
00700         addPointCloud (const pcl::PCLPointCloud2::ConstPtr &cloud,
00701                        const GeometryHandlerConstPtr &geometry_handler,
00702                        const ColorHandlerConstPtr &color_handler,
00703                        const Eigen::Vector4f& sensor_origin,
00704                        const Eigen::Quaternion<float>& sensor_orientation,
00705                        const std::string &id = "cloud", int viewport = 0);
00706 
00707         /** \brief Add a binary blob Point Cloud to screen.
00708           *
00709           * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
00710           * available handlers, rather than replacing the current active handler. This makes it possible to
00711           * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
00712           * interface (using [Alt+]0..9).
00713           *
00714           * \param[in] cloud the input point cloud dataset
00715           * \param[in] geometry_handler a specific PointCloud visualizer handler for geometry
00716           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
00717           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
00718           * \param[in] id the point cloud object id (default: cloud)
00719           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00720           */
00721         bool
00722         addPointCloud (const pcl::PCLPointCloud2::ConstPtr &cloud,
00723                        const GeometryHandlerConstPtr &geometry_handler,
00724                        const Eigen::Vector4f& sensor_origin,
00725                        const Eigen::Quaternion<float>& sensor_orientation,
00726                        const std::string &id = "cloud", int viewport = 0);
00727 
00728         /** \brief Add a binary blob Point Cloud to screen.
00729           *
00730           * Because the geometry/color handler is given as a pointer, it will be pushed back to the list of
00731           * available handlers, rather than replacing the current active handler. This makes it possible to
00732           * switch between different handlers 'on-the-fly' at runtime, from the PCLVisualizer interactor
00733           * interface (using [Alt+]0..9).
00734           *
00735           * \param[in] cloud the input point cloud dataset
00736           * \param[in] color_handler a specific PointCloud visualizer handler for colors
00737           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
00738           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
00739           * \param[in] id the point cloud object id (default: cloud)
00740           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00741           */
00742         bool
00743         addPointCloud (const pcl::PCLPointCloud2::ConstPtr &cloud,
00744                        const ColorHandlerConstPtr &color_handler,
00745                        const Eigen::Vector4f& sensor_origin,
00746                        const Eigen::Quaternion<float>& sensor_orientation,
00747                        const std::string &id = "cloud", int viewport = 0);
00748 
00749         /** \brief Add a Point Cloud (templated) to screen.
00750           * \param[in] cloud the input point cloud dataset
00751           * \param[in] color_handler a specific PointCloud visualizer handler for colors
00752           * \param[in] geometry_handler use a geometry handler object to extract the XYZ data
00753           * \param[in] id the point cloud object id (default: cloud)
00754           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00755           */
00756         template <typename PointT> bool
00757         addPointCloud (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00758                        const PointCloudColorHandler<PointT> &color_handler,
00759                        const PointCloudGeometryHandler<PointT> &geometry_handler,
00760                        const std::string &id = "cloud", int viewport = 0);
00761 
00762         /** \brief Add a PointXYZ Point Cloud to screen.
00763           * \param[in] cloud the input point cloud dataset
00764           * \param[in] id the point cloud object id (default: cloud)
00765           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00766           */
00767         inline bool
00768         addPointCloud (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud,
00769                        const std::string &id = "cloud", int viewport = 0)
00770         {
00771           return (addPointCloud<pcl::PointXYZ> (cloud, id, viewport));
00772         }
00773 
00774 
00775         /** \brief Add a PointXYZRGB Point Cloud to screen.
00776           * \param[in] cloud the input point cloud dataset
00777           * \param[in] id the point cloud object id (default: cloud)
00778           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00779           */
00780         inline bool
00781         addPointCloud (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud,
00782                        const std::string &id = "cloud", int viewport = 0)
00783         {
00784           pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> color_handler (cloud);
00785           return (addPointCloud<pcl::PointXYZRGB> (cloud, color_handler, id, viewport));
00786         }
00787 
00788         /** \brief Add a PointXYZRGBA Point Cloud to screen.
00789           * \param[in] cloud the input point cloud dataset
00790           * \param[in] id the point cloud object id (default: cloud)
00791           * \param[in] viewport the view port where the Point Cloud should be added (default: all)
00792           */
00793         inline bool
00794         addPointCloud (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud,
00795                        const std::string &id = "cloud", int viewport = 0)
00796         {
00797           pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA> color_handler (cloud);
00798           return (addPointCloud<pcl::PointXYZRGBA> (cloud, color_handler, id, viewport));
00799         }
00800 
00801         /** \brief Updates the XYZ data for an existing cloud object id on screen.
00802           * \param[in] cloud the input point cloud dataset
00803           * \param[in] id the point cloud object id to update (default: cloud)
00804           * \return false if no cloud with the specified ID was found
00805           */
00806         inline bool
00807         updatePointCloud (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud,
00808                           const std::string &id = "cloud")
00809         {
00810           return (updatePointCloud<pcl::PointXYZ> (cloud, id));
00811         }
00812 
00813         /** \brief Updates the XYZRGB data for an existing cloud object id on screen.
00814           * \param[in] cloud the input point cloud dataset
00815           * \param[in] id the point cloud object id to update (default: cloud)
00816           * \return false if no cloud with the specified ID was found
00817           */
00818         inline bool
00819         updatePointCloud (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud,
00820                           const std::string &id = "cloud")
00821         {
00822           pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> color_handler (cloud);
00823           return (updatePointCloud<pcl::PointXYZRGB> (cloud, color_handler, id));
00824         }
00825 
00826         /** \brief Updates the XYZRGBA data for an existing cloud object id on screen.
00827           * \param[in] cloud the input point cloud dataset
00828           * \param[in] id the point cloud object id to update (default: cloud)
00829           * \return false if no cloud with the specified ID was found
00830           */
00831         inline bool
00832         updatePointCloud (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud,
00833                           const std::string &id = "cloud")
00834         {
00835           pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA> color_handler (cloud);
00836           return (updatePointCloud<pcl::PointXYZRGBA> (cloud, color_handler, id));
00837         }
00838 
00839         /** \brief Add a PolygonMesh object to screen
00840           * \param[in] polymesh the polygonal mesh
00841           * \param[in] id the polygon object id (default: "polygon")
00842           * \param[in] viewport the view port where the PolygonMesh should be added (default: all)
00843           */
00844         bool
00845         addPolygonMesh (const pcl::PolygonMesh &polymesh,
00846                         const std::string &id = "polygon",
00847                         int viewport = 0);
00848 
00849         /** \brief Add a PolygonMesh object to screen
00850           * \param[in] cloud the polygonal mesh point cloud
00851           * \param[in] vertices the polygonal mesh vertices
00852           * \param[in] id the polygon object id (default: "polygon")
00853           * \param[in] viewport the view port where the PolygonMesh should be added (default: all)
00854           */
00855         template <typename PointT> bool
00856         addPolygonMesh (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00857                         const std::vector<pcl::Vertices> &vertices,
00858                         const std::string &id = "polygon",
00859                         int viewport = 0);
00860 
00861         /** \brief Update a PolygonMesh object on screen
00862           * \param[in] cloud the polygonal mesh point cloud
00863           * \param[in] vertices the polygonal mesh vertices
00864           * \param[in] id the polygon object id (default: "polygon")
00865           * \return false if no polygonmesh with the specified ID was found
00866           */
00867         template <typename PointT> bool
00868         updatePolygonMesh (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
00869                            const std::vector<pcl::Vertices> &vertices,
00870                            const std::string &id = "polygon");
00871 
00872         /** \brief Update a PolygonMesh object on screen
00873           * \param[in] polymesh the polygonal mesh
00874           * \param[in] id the polygon object id (default: "polygon")
00875           * \return false if no polygonmesh with the specified ID was found
00876           */
00877         bool
00878         updatePolygonMesh (const pcl::PolygonMesh &polymesh,
00879                            const std::string &id = "polygon");
00880 
00881         /** \brief Add a Polygonline from a polygonMesh object to screen
00882           * \param[in] polymesh the polygonal mesh from where the polylines will be extracted
00883           * \param[in] id the polygon object id (default: "polygon")
00884           * \param[in] viewport the view port where the PolygonMesh should be added (default: all)
00885           */
00886         bool
00887         addPolylineFromPolygonMesh (const pcl::PolygonMesh &polymesh,
00888                                     const std::string &id = "polyline",
00889                                     int viewport = 0);
00890 
00891         /** \brief Add the specified correspondences to the display.
00892           * \param[in] source_points The source points
00893           * \param[in] target_points The target points
00894           * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
00895           * \param[in] id the polygon object id (default: "correspondences")
00896           * \param[in] viewport the view port where the correspondences should be added (default: all)
00897           */
00898         template <typename PointT> bool
00899         addCorrespondences (const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
00900                             const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
00901                             const std::vector<int> & correspondences,
00902                             const std::string &id = "correspondences",
00903                             int viewport = 0);
00904 
00905         /** \brief Add the specified correspondences to the display.
00906           * \param[in] source_points The source points
00907           * \param[in] target_points The target points
00908           * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
00909           * \param[in] nth display only the Nth correspondence (e.g., skip the rest)
00910           * \param[in] id the polygon object id (default: "correspondences")
00911           * \param[in] viewport the view port where the correspondences should be added (default: all)
00912           */
00913         template <typename PointT> bool
00914         addCorrespondences (const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
00915                             const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
00916                             const pcl::Correspondences &correspondences,
00917                             int nth,
00918                             const std::string &id = "correspondences",
00919                             int viewport = 0);
00920 
00921         /** \brief Add the specified correspondences to the display.
00922           * \param[in] source_points The source points
00923           * \param[in] target_points The target points
00924           * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
00925           * \param[in] id the polygon object id (default: "correspondences")
00926           * \param[in] viewport the view port where the correspondences should be added (default: all)
00927           */
00928         template <typename PointT> bool
00929         addCorrespondences (const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
00930                             const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
00931                             const pcl::Correspondences &correspondences,
00932                             const std::string &id = "correspondences",
00933                             int viewport = 0)
00934         {
00935           // If Nth not given, display all correspondences
00936           return (addCorrespondences<PointT> (source_points, target_points, 
00937                                               correspondences, 1, id, viewport));
00938         }
00939 
00940         /** \brief Update the specified correspondences to the display.
00941           * \param[in] source_points The source points
00942           * \param[in] target_points The target points
00943           * \param[in] correspondences The mapping from source points to target points. Each element must be an index into target_points
00944           * \param[in] nth display only the Nth correspondence (e.g., skip the rest)
00945           * \param[in] id the polygon object id (default: "correspondences")
00946           */
00947         template <typename PointT> bool
00948         updateCorrespondences (
00949             const typename pcl::PointCloud<PointT>::ConstPtr &source_points,
00950             const typename pcl::PointCloud<PointT>::ConstPtr &target_points,
00951             const pcl::Correspondences &correspondences,
00952             int nth,
00953             const std::string &id = "correspondences");
00954 
00955         /** \brief Remove the specified correspondences from the display.
00956           * \param[in] id the polygon correspondences object id (i.e., given on \ref addCorrespondences)
00957           * \param[in] viewport view port from where the correspondences should be removed (default: all)
00958           */
00959         void
00960         removeCorrespondences (const std::string &id = "correspondences", int viewport = 0);
00961 
00962         /** \brief Get the color handler index of a rendered PointCloud based on its ID
00963           * \param[in] id the point cloud object id
00964           */
00965         int
00966         getColorHandlerIndex (const std::string &id);
00967 
00968         /** \brief Get the geometry handler index of a rendered PointCloud based on its ID
00969           * \param[in] id the point cloud object id
00970           */
00971         int
00972         getGeometryHandlerIndex (const std::string &id);
00973 
00974         /** \brief Update/set the color index of a renderered PointCloud based on its ID
00975           * \param[in] id the point cloud object id
00976           * \param[in] index the color handler index to use
00977           */
00978         bool
00979         updateColorHandlerIndex (const std::string &id, int index);
00980 
00981         /** \brief Set the rendering properties of a PointCloud (3x values - e.g., RGB)
00982           * \param[in] property the property type
00983           * \param[in] val1 the first value to be set
00984           * \param[in] val2 the second value to be set
00985           * \param[in] val3 the third value to be set
00986           * \param[in] id the point cloud object id (default: cloud)
00987           * \param[in] viewport the view port where the Point Cloud's rendering properties should be modified (default: all)
00988           */
00989         bool
00990         setPointCloudRenderingProperties (int property, double val1, double val2, double val3,
00991                                           const std::string &id = "cloud", int viewport = 0);
00992 
00993        /** \brief Set the rendering properties of a PointCloud
00994          * \param[in] property the property type
00995          * \param[in] value the value to be set
00996          * \param[in] id the point cloud object id (default: cloud)
00997          * \param[in] viewport the view port where the Point Cloud's rendering properties should be modified (default: all)
00998          */
00999         bool
01000         setPointCloudRenderingProperties (int property, double value,
01001                                           const std::string &id = "cloud", int viewport = 0);
01002 
01003        /** \brief Get the rendering properties of a PointCloud
01004          * \param[in] property the property type
01005          * \param[in] value the resultant property value
01006          * \param[in] id the point cloud object id (default: cloud)
01007          */
01008         bool
01009         getPointCloudRenderingProperties (int property, double &value,
01010                                           const std::string &id = "cloud");
01011         
01012         /** \brief Set whether the point cloud is selected or not 
01013          *  \param[in] selected whether the cloud is selected or not (true = selected)
01014          *  \param[in] id the point cloud object id (default: cloud)
01015          */
01016         bool
01017         setPointCloudSelected (const bool selected, const std::string &id = "cloud" );
01018         
01019        /** \brief Set the rendering properties of a shape
01020          * \param[in] property the property type
01021          * \param[in] value the value to be set
01022          * \param[in] id the shape object id
01023          * \param[in] viewport the view port where the shape's properties should be modified (default: all)
01024          */
01025         bool
01026         setShapeRenderingProperties (int property, double value,
01027                                      const std::string &id, int viewport = 0);
01028 
01029         /** \brief Set the rendering properties of a shape (3x values - e.g., RGB)
01030           * \param[in] property the property type
01031           * \param[in] val1 the first value to be set
01032           * \param[in] val2 the second value to be set
01033           * \param[in] val3 the third value to be set
01034           * \param[in] id the shape object id
01035           * \param[in] viewport the view port where the shape's properties should be modified (default: all)
01036           */
01037          bool
01038          setShapeRenderingProperties (int property, double val1, double val2, double val3,
01039                                       const std::string &id, int viewport = 0);
01040 
01041         /** \brief Returns true when the user tried to close the window */
01042         bool
01043         wasStopped () const;
01044 
01045         /** \brief Set the stopped flag back to false */
01046         void
01047         resetStoppedFlag ();
01048 
01049         /** \brief Stop the interaction and close the visualizaton window. */
01050         void
01051         close ();
01052 
01053         /** \brief Create a new viewport from [xmin,ymin] -> [xmax,ymax].
01054           * \param[in] xmin the minimum X coordinate for the viewport (0.0 <= 1.0)
01055           * \param[in] ymin the minimum Y coordinate for the viewport (0.0 <= 1.0)
01056           * \param[in] xmax the maximum X coordinate for the viewport (0.0 <= 1.0)
01057           * \param[in] ymax the maximum Y coordinate for the viewport (0.0 <= 1.0)
01058           * \param[in] viewport the id of the new viewport
01059           *
01060           * \note If no renderer for the current window exists, one will be created, and 
01061           * the viewport will be set to 0 ('all'). In case one or multiple renderers do 
01062           * exist, the viewport ID will be set to the total number of renderers - 1.
01063           */
01064         void
01065         createViewPort (double xmin, double ymin, double xmax, double ymax, int &viewport);
01066 
01067         /** \brief Create a new separate camera for the given viewport.
01068           * \param[in] viewport the viewport to create a new camera for.
01069           */
01070         void
01071         createViewPortCamera (const int viewport);
01072 
01073         /** \brief Add a polygon (polyline) that represents the input point cloud (connects all
01074           * points in order)
01075           * \param[in] cloud the point cloud dataset representing the polygon
01076           * \param[in] r the red channel of the color that the polygon should be rendered with
01077           * \param[in] g the green channel of the color that the polygon should be rendered with
01078           * \param[in] b the blue channel of the color that the polygon should be rendered with
01079           * \param[in] id (optional) the polygon id/name (default: "polygon")
01080           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01081           */
01082         template <typename PointT> bool
01083         addPolygon (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
01084                     double r, double g, double b,
01085                     const std::string &id = "polygon", int viewport = 0);
01086 
01087         /** \brief Add a polygon (polyline) that represents the input point cloud (connects all
01088           * points in order)
01089           * \param[in] cloud the point cloud dataset representing the polygon
01090           * \param[in] id the polygon id/name (default: "polygon")
01091           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01092           */
01093         template <typename PointT> bool
01094         addPolygon (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
01095                     const std::string &id = "polygon",
01096                     int viewport = 0);
01097 
01098         /** \brief Add a planar polygon that represents the input point cloud (connects all points in order)
01099           * \param[in] polygon the polygon to draw
01100           * \param[in] r the red channel of the color that the polygon should be rendered with
01101           * \param[in] g the green channel of the color that the polygon should be rendered with
01102           * \param[in] b the blue channel of the color that the polygon should be rendered with
01103           * \param[in] id the polygon id/name (default: "polygon")
01104           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01105           */
01106         template <typename PointT> bool
01107         addPolygon (const pcl::PlanarPolygon<PointT> &polygon,
01108                     double r, double g, double b,
01109                     const std::string &id = "polygon",
01110                     int viewport = 0);
01111 
01112         /** \brief Add a line segment from two points
01113           * \param[in] pt1 the first (start) point on the line
01114           * \param[in] pt2 the second (end) point on the line
01115           * \param[in] id the line id/name (default: "line")
01116           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01117           */
01118         template <typename P1, typename P2> bool
01119         addLine (const P1 &pt1, const P2 &pt2, const std::string &id = "line",
01120                  int viewport = 0);
01121 
01122         /** \brief Add a line segment from two points
01123           * \param[in] pt1 the first (start) point on the line
01124           * \param[in] pt2 the second (end) point on the line
01125           * \param[in] r the red channel of the color that the line should be rendered with
01126           * \param[in] g the green channel of the color that the line should be rendered with
01127           * \param[in] b the blue channel of the color that the line should be rendered with
01128           * \param[in] id the line id/name (default: "line")
01129           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01130           */
01131         template <typename P1, typename P2> bool
01132         addLine (const P1 &pt1, const P2 &pt2, double r, double g, double b,
01133                  const std::string &id = "line", int viewport = 0);
01134 
01135         /** \brief Add a line arrow segment between two points, and display the distance between them
01136           * \param[in] pt1 the first (start) point on the line
01137           * \param[in] pt2 the second (end) point on the line
01138           * \param[in] r the red channel of the color that the line should be rendered with
01139           * \param[in] g the green channel of the color that the line should be rendered with
01140           * \param[in] b the blue channel of the color that the line should be rendered with
01141           * \param[in] id the arrow id/name (default: "arrow")
01142           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01143           */
01144         template <typename P1, typename P2> bool
01145         addArrow (const P1 &pt1, const P2 &pt2, double r, double g, double b,
01146                   const std::string &id = "arrow", int viewport = 0);
01147 
01148         /** \brief Add a line arrow segment between two points, and display the distance between them
01149           * \param[in] pt1 the first (start) point on the line
01150           * \param[in] pt2 the second (end) point on the line
01151           * \param[in] r the red channel of the color that the line should be rendered with
01152           * \param[in] g the green channel of the color that the line should be rendered with
01153           * \param[in] b the blue channel of the color that the line should be rendered with
01154           * \param[in] display_length true if the length should be displayed on the arrow as text
01155           * \param[in] id the line id/name (default: "arrow")
01156           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01157           */
01158         template <typename P1, typename P2> bool
01159         addArrow (const P1 &pt1, const P2 &pt2, double r, double g, double b, bool display_length,
01160                   const std::string &id = "arrow", int viewport = 0);
01161 
01162         /** \brief Add a line arrow segment between two points, and display the distance between them in a given color
01163           * \param[in] pt1 the first (start) point on the line
01164           * \param[in] pt2 the second (end) point on the line
01165           * \param[in] r_line the red channel of the color that the line should be rendered with
01166           * \param[in] g_line the green channel of the color that the line should be rendered with
01167           * \param[in] b_line the blue channel of the color that the line should be rendered with
01168           * \param[in] r_text the red channel of the color that the text should be rendered with
01169           * \param[in] g_text the green channel of the color that the text should be rendered with
01170           * \param[in] b_text the blue channel of the color that the text should be rendered with
01171           * \param[in] id the line id/name (default: "arrow")
01172           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01173           */
01174         template <typename P1, typename P2> bool
01175         addArrow (const P1 &pt1, const P2 &pt2,
01176                   double r_line, double g_line, double b_line,
01177                   double r_text, double g_text, double b_text,
01178                   const std::string &id = "arrow", int viewport = 0);
01179 
01180 
01181         /** \brief Add a sphere shape from a point and a radius
01182           * \param[in] center the center of the sphere
01183           * \param[in] radius the radius of the sphere
01184           * \param[in] id the sphere id/name (default: "sphere")
01185           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01186           */
01187         template <typename PointT> bool
01188         addSphere (const PointT &center, double radius, const std::string &id = "sphere",
01189                    int viewport = 0);
01190 
01191         /** \brief Add a sphere shape from a point and a radius
01192           * \param[in] center the center of the sphere
01193           * \param[in] radius the radius of the sphere
01194           * \param[in] r the red channel of the color that the sphere should be rendered with
01195           * \param[in] g the green channel of the color that the sphere should be rendered with
01196           * \param[in] b the blue channel of the color that the sphere should be rendered with
01197           * \param[in] id the sphere id/name (default: "sphere")
01198           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01199           */
01200         template <typename PointT> bool
01201         addSphere (const PointT &center, double radius, double r, double g, double b,
01202                    const std::string &id = "sphere", int viewport = 0);
01203 
01204         /** \brief Update an existing sphere shape from a point and a radius
01205           * \param[in] center the center of the sphere
01206           * \param[in] radius the radius of the sphere
01207           * \param[in] r the red channel of the color that the sphere should be rendered with
01208           * \param[in] g the green channel of the color that the sphere should be rendered with
01209           * \param[in] b the blue channel of the color that the sphere should be rendered with
01210           * \param[in] id the sphere id/name (default: "sphere")
01211           */
01212         template <typename PointT> bool
01213         updateSphere (const PointT &center, double radius, double r, double g, double b,
01214                       const std::string &id = "sphere");
01215 
01216          /** \brief Add a vtkPolydata as a mesh
01217           * \param[in] polydata vtkPolyData
01218           * \param[in] id the model id/name (default: "PolyData")
01219           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01220           */
01221         bool
01222         addModelFromPolyData (vtkSmartPointer<vtkPolyData> polydata,
01223                               const std::string & id = "PolyData",
01224                               int viewport = 0);
01225 
01226         /** \brief Add a vtkPolydata as a mesh
01227           * \param[in] polydata vtkPolyData
01228           * \param[in] transform transformation to apply
01229           * \param[in] id the model id/name (default: "PolyData")
01230           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01231           */
01232         bool
01233         addModelFromPolyData (vtkSmartPointer<vtkPolyData> polydata,
01234                               vtkSmartPointer<vtkTransform> transform,
01235                               const std::string &id = "PolyData",
01236                               int viewport = 0);
01237 
01238         /** \brief Add a PLYmodel as a mesh
01239           * \param[in] filename of the ply file
01240           * \param[in] id the model id/name (default: "PLYModel")
01241           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01242           */
01243         bool
01244         addModelFromPLYFile (const std::string &filename,
01245                              const std::string &id = "PLYModel",
01246                              int viewport = 0);
01247 
01248         /** \brief Add a PLYmodel as a mesh and applies given transformation
01249           * \param[in] filename of the ply file
01250           * \param[in] transform transformation to apply
01251           * \param[in] id the model id/name (default: "PLYModel")
01252           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01253           */
01254         bool
01255         addModelFromPLYFile (const std::string &filename,
01256                              vtkSmartPointer<vtkTransform> transform,
01257                              const std::string &id = "PLYModel",
01258                              int viewport = 0);
01259 
01260         /** \brief Add a cylinder from a set of given model coefficients
01261           * \param[in] coefficients the model coefficients (point_on_axis, axis_direction, radius)
01262           * \param[in] id the cylinder id/name (default: "cylinder")
01263           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01264           *
01265           * \code
01266           * // The following are given (or computed using sample consensus techniques)
01267           * // See SampleConsensusModelCylinder for more information.
01268           * // Eigen::Vector3f pt_on_axis, axis_direction;
01269           * // float radius;
01270           *
01271           * pcl::ModelCoefficients cylinder_coeff;
01272           * cylinder_coeff.values.resize (7);    // We need 7 values
01273           * cylinder_coeff.values[0] = pt_on_axis.x ();
01274           * cylinder_coeff.values[1] = pt_on_axis.y ();
01275           * cylinder_coeff.values[2] = pt_on_axis.z ();
01276           *
01277           * cylinder_coeff.values[3] = axis_direction.x ();
01278           * cylinder_coeff.values[4] = axis_direction.y ();
01279           * cylinder_coeff.values[5] = axis_direction.z ();
01280           *
01281           * cylinder_coeff.values[6] = radius;
01282           *
01283           * addCylinder (cylinder_coeff);
01284           * \endcode
01285           */
01286         bool
01287         addCylinder (const pcl::ModelCoefficients &coefficients,
01288                      const std::string &id = "cylinder",
01289                      int viewport = 0);
01290 
01291         /** \brief Add a sphere from a set of given model coefficients
01292           * \param[in] coefficients the model coefficients (sphere center, radius)
01293           * \param[in] id the sphere id/name (default: "sphere")
01294           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01295           *
01296           * \code
01297           * // The following are given (or computed using sample consensus techniques)
01298           * // See SampleConsensusModelSphere for more information
01299           * // Eigen::Vector3f sphere_center;
01300           * // float radius;
01301           *
01302           * pcl::ModelCoefficients sphere_coeff;
01303           * sphere_coeff.values.resize (4);    // We need 4 values
01304           * sphere_coeff.values[0] = sphere_center.x ();
01305           * sphere_coeff.values[1] = sphere_center.y ();
01306           * sphere_coeff.values[2] = sphere_center.z ();
01307           *
01308           * sphere_coeff.values[3] = radius;
01309           *
01310           * addSphere (sphere_coeff);
01311           * \endcode
01312           */
01313         bool
01314         addSphere (const pcl::ModelCoefficients &coefficients,
01315                    const std::string &id = "sphere",
01316                    int viewport = 0);
01317 
01318         /** \brief Add a line from a set of given model coefficients
01319           * \param[in] coefficients the model coefficients (point_on_line, direction)
01320           * \param[in] id the line id/name (default: "line")
01321           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01322           *
01323           * \code
01324           * // The following are given (or computed using sample consensus techniques)
01325           * // See SampleConsensusModelLine for more information
01326           * // Eigen::Vector3f point_on_line, line_direction;
01327           *
01328           * pcl::ModelCoefficients line_coeff;
01329           * line_coeff.values.resize (6);    // We need 6 values
01330           * line_coeff.values[0] = point_on_line.x ();
01331           * line_coeff.values[1] = point_on_line.y ();
01332           * line_coeff.values[2] = point_on_line.z ();
01333           *
01334           * line_coeff.values[3] = line_direction.x ();
01335           * line_coeff.values[4] = line_direction.y ();
01336           * line_coeff.values[5] = line_direction.z ();
01337           *
01338           * addLine (line_coeff);
01339           * \endcode
01340           */
01341         bool
01342         addLine (const pcl::ModelCoefficients &coefficients,
01343                  const std::string &id = "line",
01344                  int viewport = 0);
01345 
01346         /** \brief Add a plane from a set of given model coefficients
01347           * \param[in] coefficients the model coefficients (a, b, c, d with ax+by+cz+d=0)
01348           * \param[in] id the plane id/name (default: "plane")
01349           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01350           *
01351           * \code
01352           * // The following are given (or computed using sample consensus techniques)
01353           * // See SampleConsensusModelPlane for more information
01354           * // Eigen::Vector4f plane_parameters;
01355           *
01356           * pcl::ModelCoefficients plane_coeff;
01357           * plane_coeff.values.resize (4);    // We need 4 values
01358           * plane_coeff.values[0] = plane_parameters.x ();
01359           * plane_coeff.values[1] = plane_parameters.y ();
01360           * plane_coeff.values[2] = plane_parameters.z ();
01361           * plane_coeff.values[3] = plane_parameters.w ();
01362           *
01363           * addPlane (plane_coeff);
01364           * \endcode
01365           */
01366         bool
01367         addPlane (const pcl::ModelCoefficients &coefficients,
01368                   const std::string &id = "plane",
01369                   int viewport = 0);
01370 
01371         bool
01372         addPlane (const pcl::ModelCoefficients &coefficients, double x, double y, double z,
01373                   const std::string &id = "plane",
01374                   int viewport = 0);
01375         /** \brief Add a circle from a set of given model coefficients
01376           * \param[in] coefficients the model coefficients (x, y, radius)
01377           * \param[in] id the circle id/name (default: "circle")
01378           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01379           *
01380           * \code
01381           * // The following are given (or computed using sample consensus techniques)
01382           * // See SampleConsensusModelCircle2D for more information
01383           * // float x, y, radius;
01384           *
01385           * pcl::ModelCoefficients circle_coeff;
01386           * circle_coeff.values.resize (3);    // We need 3 values
01387           * circle_coeff.values[0] = x;
01388           * circle_coeff.values[1] = y;
01389           * circle_coeff.values[2] = radius;
01390           *
01391           * vtkSmartPointer<vtkDataSet> data = pcl::visualization::create2DCircle (circle_coeff, z);
01392           * \endcode
01393            */
01394         bool
01395         addCircle (const pcl::ModelCoefficients &coefficients,
01396                    const std::string &id = "circle",
01397                    int viewport = 0);
01398 
01399         /** \brief Add a cone from a set of given model coefficients
01400           * \param[in] coefficients the model coefficients (point_on_axis, axis_direction, radiu)
01401           * \param[in] id the cone id/name (default: "cone")
01402           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01403           */
01404         bool
01405         addCone (const pcl::ModelCoefficients &coefficients,
01406                  const std::string &id = "cone",
01407                  int viewport = 0);
01408 
01409         /** \brief Add a cube from a set of given model coefficients
01410           * \param[in] coefficients the model coefficients (Tx, Ty, Tz, Qx, Qy, Qz, Qw, width, height, depth)
01411           * \param[in] id the cube id/name (default: "cube")
01412           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01413           */
01414         bool
01415         addCube (const pcl::ModelCoefficients &coefficients,
01416                  const std::string &id = "cube",
01417                  int viewport = 0);
01418 
01419         /** \brief Add a cube from a set of given model coefficients
01420           * \param[in] translation a translation to apply to the cube from 0,0,0
01421           * \param[in] rotation a quaternion-based rotation to apply to the cube
01422           * \param[in] width the cube's width
01423           * \param[in] height the cube's height
01424           * \param[in] depth the cube's depth
01425           * \param[in] id the cube id/name (default: "cube")
01426           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01427           */
01428         bool
01429         addCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation,
01430                  double width, double height, double depth,
01431                  const std::string &id = "cube",
01432                  int viewport = 0);
01433 
01434         /** \brief Add a cube
01435           * \param[in] x_min the min X coordinate
01436           * \param[in] x_max the max X coordinate
01437           * \param[in] y_min the min Y coordinate
01438           * \param[in] y_max the max Y coordinate
01439           * \param[in] z_min the min Z coordinate
01440           * \param[in] z_max the max Z coordinate
01441           * \param[in] r how much red (0.0 -> 1.0)
01442           * \param[in] g how much green (0.0 -> 1.0)
01443           * \param[in] b how much blue (0.0 -> 1.0)
01444           * \param[in] id the cube id/name (default: "cube")
01445           * \param[in] viewport (optional) the id of the new viewport (default: 0)
01446           */
01447         bool
01448         addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max,
01449                  double r = 1.0, double g = 1.0, double b = 1.0, const std::string &id = "cube", int viewport = 0);
01450 
01451         /** \brief Changes the visual representation for all actors to surface representation. */
01452         void
01453         setRepresentationToSurfaceForAllActors ();
01454 
01455         /** \brief Changes the visual representation for all actors to points representation. */
01456         void
01457         setRepresentationToPointsForAllActors ();
01458 
01459         /** \brief Changes the visual representation for all actors to wireframe representation. */
01460         void
01461         setRepresentationToWireframeForAllActors ();
01462 
01463         /** \brief Sets whether the 2D overlay text showing the framerate of the window is displayed or not.
01464           * \param[in] show_fps determines whether the fps text will be shown or not.
01465           */
01466         void
01467         setShowFPS (bool show_fps);
01468 
01469         /** \brief Renders a virtual scene as seen from the camera viewpoint and returns the rendered point cloud.
01470           * ATT: This method will only render the scene if only on viewport exists. Otherwise, returns an empty
01471           * point cloud and exits immediately.
01472           * \param[in] xres is the size of the window (X) used to render the scene
01473           * \param[in] yres is the size of the window (Y) used to render the scene
01474           * \param[in] cloud is the rendered point cloud
01475           */
01476         void
01477         renderView (int xres, int yres, pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud);
01478 
01479         /** \brief The purpose of this method is to render a CAD model added to the visualizer from different viewpoints
01480           * in order to simulate partial views of model. The viewpoint locations are the vertices of a tesselated sphere
01481           * build from an icosaheadron. The tesselation paremeter controls how many times the triangles of the original
01482           * icosahedron are divided to approximate the sphere and thus the number of partial view generated for a model,
01483           * with a tesselation_level of 0, 12 views are generated if use_vertices=true and 20 views if use_vertices=false
01484           *
01485           * \param[in] xres the size of the window (X) used to render the partial view of the object
01486           * \param[in] yres the size of the window (Y) used to render the partial view of the object
01487           * \param[in] cloud is a vector of pointcloud with XYZ information that represent the model as seen from the respective viewpoints.
01488           * \param[out] poses represent the transformation from object coordinates to camera coordinates for the respective viewpoint.
01489           * \param[out] enthropies are values between 0 and 1 representing which percentage of the model is seen from the respective viewpoint.
01490           * \param[in] tesselation_level represents the number of subdivisions applied to the triangles of original icosahedron.
01491           * \param[in] view_angle field of view of the virtual camera. Default: 45
01492           * \param[in] radius_sphere the tesselated sphere radius. Default: 1
01493           * \param[in] use_vertices if true, use the vertices of tesselated icosahedron (12,42,...) or if false, use the faces of tesselated
01494           * icosahedron (20,80,...). Default: true
01495           */
01496         void
01497         renderViewTesselatedSphere (
01498             int xres, int yres,
01499             pcl::PointCloud<pcl::PointXYZ>::CloudVectorType & cloud,
01500             std::vector<Eigen::Matrix4f,Eigen::aligned_allocator< Eigen::Matrix4f > > & poses, std::vector<float> & enthropies, int tesselation_level,
01501             float view_angle = 45, float radius_sphere = 1, bool use_vertices = true);
01502 
01503 
01504         /** \brief Initialize camera parameters with some default values. */
01505         void
01506         initCameraParameters ();
01507 
01508         /** \brief Search for camera parameters at the command line and set them internally.
01509           * \param[in] argc
01510           * \param[in] argv
01511           */
01512         bool
01513         getCameraParameters (int argc, char **argv);
01514 
01515         /** \brief Checks whether the camera parameters were manually loaded from file.*/
01516         bool
01517         cameraParamsSet () const;
01518 
01519         /** \brief Update camera parameters and render. */
01520         void
01521         updateCamera ();
01522 
01523         /** \brief Reset camera parameters and render. */
01524         void
01525         resetCamera ();
01526 
01527         /** \brief Reset the camera direction from {0, 0, 0} to the center_{x, y, z} of a given dataset.
01528           * \param[in] id the point cloud object id (default: cloud)
01529           */
01530         void
01531         resetCameraViewpoint (const std::string &id = "cloud");
01532 
01533         /** \brief Set the camera pose given by position, viewpoint and up vector
01534           * \param[in] pos_x the x coordinate of the camera location
01535           * \param[in] pos_y the y coordinate of the camera location
01536           * \param[in] pos_z the z coordinate of the camera location
01537           * \param[in] view_x the x component of the view point of the camera
01538           * \param[in] view_y the y component of the view point of the camera
01539           * \param[in] view_z the z component of the view point of the camera
01540           * \param[in] up_x the x component of the view up direction of the camera
01541           * \param[in] up_y the y component of the view up direction of the camera
01542           * \param[in] up_z the y component of the view up direction of the camera
01543           * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
01544           */
01545         void
01546         setCameraPosition (double pos_x, double pos_y, double pos_z,
01547                            double view_x, double view_y, double view_z,
01548                            double up_x, double up_y, double up_z, int viewport = 0);
01549 
01550         /** \brief Set the camera location and viewup according to the given arguments
01551           * \param[in] pos_x the x coordinate of the camera location
01552           * \param[in] pos_y the y coordinate of the camera location
01553           * \param[in] pos_z the z coordinate of the camera location
01554           * \param[in] up_x the x component of the view up direction of the camera
01555           * \param[in] up_y the y component of the view up direction of the camera
01556           * \param[in] up_z the z component of the view up direction of the camera
01557           * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
01558           */
01559         void
01560         setCameraPosition (double pos_x, double pos_y, double pos_z,
01561                            double up_x, double up_y, double up_z, int viewport = 0);
01562 
01563         /** \brief Set the camera parameters via an intrinsics and and extrinsics matrix
01564           * \note This assumes that the pixels are square and that the center of the image is at the center of the sensor.
01565           * \param[in] intrinsics the intrinsics that will be used to compute the VTK camera parameters
01566           * \param[in] extrinsics the extrinsics that will be used to compute the VTK camera parameters
01567           * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
01568           */
01569         void
01570         setCameraParameters (const Eigen::Matrix3f &intrinsics, const Eigen::Matrix4f &extrinsics, int viewport = 0);
01571 
01572         /** \brief Set the camera parameters by given a full camera data structure.
01573           * \param[in] camera camera structure containing all the camera parameters.
01574           * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
01575           */
01576         void
01577         setCameraParameters (const Camera &camera, int viewport = 0);
01578 
01579         /** \brief Set the camera clipping distances.
01580           * \param[in] near the near clipping distance (no objects closer than this to the camera will be drawn)
01581           * \param[in] far the far clipping distance (no objects further away than this to the camera will be drawn)
01582           */
01583         void
01584         setCameraClipDistances (double near, double far, int viewport = 0);
01585 
01586         /** \brief Set the camera vertical field of view.
01587           * \param[in] fovy vertical field of view in radians
01588           * \param[in] viewport the viewport to modify camera of (0 modifies all cameras)
01589           */
01590         void
01591         setCameraFieldOfView (double fovy, int viewport = 0);
01592 
01593         /** \brief Get the current camera parameters. */
01594         void
01595         getCameras (std::vector<Camera>& cameras);
01596 
01597 
01598         /** \brief Get the current viewing pose. */
01599         Eigen::Affine3f
01600         getViewerPose (int viewport = 0);
01601 
01602         /** \brief Save the current rendered image to disk, as a PNG screenshot.
01603           * \param[in] file the name of the PNG file
01604           */
01605         void
01606         saveScreenshot (const std::string &file);
01607 
01608         /** \brief Return a pointer to the underlying VTK Render Window used. */
01609         vtkSmartPointer<vtkRenderWindow>
01610         getRenderWindow ()
01611         {
01612           return (win_);
01613         }
01614         
01615         /** \brief Return a pointer to the underlying VTK Renderer Collection. */
01616         vtkSmartPointer<vtkRendererCollection>
01617         getRendererCollection ()
01618         {
01619           return (rens_);
01620         }
01621         
01622         /** \brief Return a pointer to the CloudActorMap this visualizer uses. */
01623         CloudActorMapPtr
01624         getCloudActorMap ()
01625         {
01626           return (cloud_actor_map_);
01627         }
01628         
01629 
01630         /** \brief Set the position in screen coordinates.
01631           * \param[in] x where to move the window to (X)
01632           * \param[in] y where to move the window to (Y)
01633           */
01634         void
01635         setPosition (int x, int y);
01636 
01637         /** \brief Set the window size in screen coordinates.
01638           * \param[in] xw window size in horizontal (pixels)
01639           * \param[in] yw window size in vertical (pixels)
01640           */
01641         void
01642         setSize (int xw, int yw);
01643 
01644         /** \brief Use Vertex Buffer Objects renderers.
01645           * \param[in] use_vbos set to true to use VBOs 
01646           */
01647         void
01648         setUseVbos (bool use_vbos);
01649 
01650         /** \brief Create the internal Interactor object. */
01651         void
01652         createInteractor ();
01653 
01654         /** \brief Set up our unique PCL interactor style for a given vtkRenderWindowInteractor object
01655           * attached to a given vtkRenderWindow
01656           * \param[in,out] iren the vtkRenderWindowInteractor object to set up
01657           * \param[in,out] win a vtkRenderWindow object that the interactor is attached to
01658           */
01659         void
01660         setupInteractor (vtkRenderWindowInteractor *iren,
01661                          vtkRenderWindow *win);
01662 
01663         /** \brief Set up PCLVisualizer with custom interactor style for a given vtkRenderWindowInteractor object
01664           * attached to a given vtkRenderWindow
01665           * \param[in,out] iren the vtkRenderWindowInteractor object to set up
01666           * \param[in,out] win a vtkRenderWindow object that the interactor is attached to
01667           * \param[in,out] style a vtkInteractorStyle object 
01668           */
01669         void
01670         setupInteractor (vtkRenderWindowInteractor *iren,
01671                          vtkRenderWindow *win,
01672                          vtkInteractorStyle *style);
01673         
01674         /** \brief Get a pointer to the current interactor style used. */
01675         inline vtkSmartPointer<PCLVisualizerInteractorStyle>
01676         getInteractorStyle ()
01677         {
01678           return (style_);
01679         }
01680       protected:
01681         /** \brief The render window interactor. */
01682 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
01683         vtkSmartPointer<PCLVisualizerInteractor> interactor_;
01684 #else
01685         vtkSmartPointer<vtkRenderWindowInteractor> interactor_;
01686 #endif
01687       private:
01688         struct ExitMainLoopTimerCallback : public vtkCommand
01689         {
01690           static ExitMainLoopTimerCallback* New ()
01691           {
01692             return (new ExitMainLoopTimerCallback);
01693           }
01694           virtual void 
01695           Execute (vtkObject*, unsigned long event_id, void*);
01696 
01697           int right_timer_id;
01698           PCLVisualizer* pcl_visualizer;
01699         };
01700 
01701         struct ExitCallback : public vtkCommand
01702         {
01703           static ExitCallback* New ()
01704           {
01705             return (new ExitCallback);
01706           }
01707           virtual void 
01708           Execute (vtkObject*, unsigned long event_id, void*);
01709 
01710           PCLVisualizer* pcl_visualizer;
01711         };
01712 
01713         //////////////////////////////////////////////////////////////////////////////////////////////
01714         struct FPSCallback : public vtkCommand
01715         {
01716           static FPSCallback *New () { return (new FPSCallback); }
01717 
01718           FPSCallback () : actor (), pcl_visualizer (), decimated () {}
01719           FPSCallback (const FPSCallback& src) : vtkCommand (), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated) {}
01720           FPSCallback& operator = (const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; return (*this); }
01721 
01722           virtual void 
01723           Execute (vtkObject*, unsigned long event_id, void*);
01724             
01725           vtkTextActor *actor;
01726           PCLVisualizer* pcl_visualizer;
01727           bool decimated;
01728         };
01729 
01730         /** \brief The FPSCallback object for the current visualizer. */
01731         vtkSmartPointer<FPSCallback> update_fps_;
01732 
01733 #if !((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
01734         /** \brief Set to false if the interaction loop is running. */
01735         bool stopped_;
01736 
01737         /** \brief Global timer ID. Used in destructor only. */
01738         int timer_id_;
01739 #endif
01740         /** \brief Callback object enabling us to leave the main loop, when a timer fires. */
01741         vtkSmartPointer<ExitMainLoopTimerCallback> exit_main_loop_timer_callback_;
01742         vtkSmartPointer<ExitCallback> exit_callback_;
01743 
01744         /** \brief The collection of renderers used. */
01745         vtkSmartPointer<vtkRendererCollection> rens_;
01746 
01747         /** \brief The render window. */
01748         vtkSmartPointer<vtkRenderWindow> win_;
01749 
01750         /** \brief The render window interactor style. */
01751         vtkSmartPointer<PCLVisualizerInteractorStyle> style_;
01752 
01753         /** \brief Internal list with actor pointers and name IDs for point clouds. */
01754         CloudActorMapPtr cloud_actor_map_;
01755 
01756         /** \brief Internal list with actor pointers and name IDs for shapes. */
01757         ShapeActorMapPtr shape_actor_map_;
01758 
01759         /** \brief Internal list with actor pointers and viewpoint for coordinates. */
01760         CoordinateActorMap coordinate_actor_map_;
01761 
01762         /** \brief Internal pointer to widget which contains a set of axes */
01763         vtkSmartPointer<vtkOrientationMarkerWidget> axes_widget_;
01764         
01765         /** \brief Boolean that holds whether or not the camera parameters were manually initialized*/
01766         bool camera_set_;
01767 
01768         /** \brief Boolean that holds whether or not to use the vtkVertexBufferObjectMapper*/
01769         bool use_vbos_;
01770 
01771         /** \brief Internal method. Removes a vtk actor from the screen.
01772           * \param[in] actor a pointer to the vtk actor object
01773           * \param[in] viewport the view port where the actor should be removed from (default: all)
01774           */
01775         bool
01776         removeActorFromRenderer (const vtkSmartPointer<vtkLODActor> &actor,
01777                                  int viewport = 0);
01778 
01779         /** \brief Internal method. Removes a vtk actor from the screen.
01780           * \param[in] actor a pointer to the vtk actor object
01781           * \param[in] viewport the view port where the actor should be removed from (default: all)
01782           */
01783         bool
01784         removeActorFromRenderer (const vtkSmartPointer<vtkActor> &actor,
01785                                  int viewport = 0);
01786 
01787         /** \brief Internal method. Adds a vtk actor to screen.
01788           * \param[in] actor a pointer to the vtk actor object
01789           * \param[in] viewport port where the actor should be added to (default: 0/all)
01790           *
01791           * \note If viewport is set to 0, the actor will be added to all existing 
01792           * renders. To select a specific viewport use an integer between 1 and N.
01793           */
01794         void
01795         addActorToRenderer (const vtkSmartPointer<vtkProp> &actor,
01796                             int viewport = 0);
01797 
01798         /** \brief Internal method. Adds a vtk actor to screen.
01799           * \param[in] actor a pointer to the vtk actor object
01800           * \param[in] viewport the view port where the actor should be added to (default: all)
01801           */
01802         bool
01803         removeActorFromRenderer (const vtkSmartPointer<vtkProp> &actor,
01804                                  int viewport = 0);
01805 
01806         /** \brief Internal method. Creates a vtk actor from a vtk polydata object.
01807           * \param[in] data the vtk polydata object to create an actor for
01808           * \param[out] actor the resultant vtk actor object
01809           * \param[in] use_scalars set scalar properties to the mapper if it exists in the data. Default: true.
01810           */
01811         void
01812         createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
01813                                    vtkSmartPointer<vtkActor> &actor,
01814                                    bool use_scalars = true);
01815 
01816         /** \brief Internal method. Creates a vtk actor from a vtk polydata object.
01817           * \param[in] data the vtk polydata object to create an actor for
01818           * \param[out] actor the resultant vtk actor object
01819           * \param[in] use_scalars set scalar properties to the mapper if it exists in the data. Default: true.
01820           */
01821         void
01822         createActorFromVTKDataSet (const vtkSmartPointer<vtkDataSet> &data,
01823                                    vtkSmartPointer<vtkLODActor> &actor,
01824                                    bool use_scalars = true);
01825 
01826         /** \brief Converts a PCL templated PointCloud object to a vtk polydata object.
01827           * \param[in] cloud the input PCL PointCloud dataset
01828           * \param[out] polydata the resultant polydata containing the cloud
01829           * \param[out] initcells a list of cell indices used for the conversion. This can be set once and then passed
01830           * around to speed up the conversion.
01831           */
01832         template <typename PointT> void
01833         convertPointCloudToVTKPolyData (const typename pcl::PointCloud<PointT>::ConstPtr &cloud,
01834                                         vtkSmartPointer<vtkPolyData> &polydata,
01835                                         vtkSmartPointer<vtkIdTypeArray> &initcells);
01836 
01837         /** \brief Converts a PCL templated PointCloud object to a vtk polydata object.
01838           * \param[in] geometry_handler the geometry handler object used to extract the XYZ data
01839           * \param[out] polydata the resultant polydata containing the cloud
01840           * \param[out] initcells a list of cell indices used for the conversion. This can be set once and then passed
01841           * around to speed up the conversion.
01842           */
01843         template <typename PointT> void
01844         convertPointCloudToVTKPolyData (const PointCloudGeometryHandler<PointT> &geometry_handler,
01845                                         vtkSmartPointer<vtkPolyData> &polydata,
01846                                         vtkSmartPointer<vtkIdTypeArray> &initcells);
01847 
01848         /** \brief Converts a PCL templated PointCloud object to a vtk polydata object.
01849           * \param[in] geometry_handler the geometry handler object used to extract the XYZ data
01850           * \param[out] polydata the resultant polydata containing the cloud
01851           * \param[out] initcells a list of cell indices used for the conversion. This can be set once and then passed
01852           * around to speed up the conversion.
01853           */
01854         void
01855         convertPointCloudToVTKPolyData (const GeometryHandlerConstPtr &geometry_handler,
01856                                         vtkSmartPointer<vtkPolyData> &polydata,
01857                                         vtkSmartPointer<vtkIdTypeArray> &initcells);
01858 
01859         /** \brief Updates a set of cells (vtkIdTypeArray) if the number of points in a cloud changes
01860           * \param[out] cells the vtkIdTypeArray object (set of cells) to update
01861           * \param[out] initcells a previously saved set of cells. If the number of points in the current cloud is
01862           * higher than the number of cells in \a cells, and initcells contains enough data, then a copy from it
01863           * will be made instead of regenerating the entire array.
01864           * \param[in] nr_points the number of points in the new cloud. This dictates how many cells we need to
01865           * generate
01866           */
01867         void
01868         updateCells (vtkSmartPointer<vtkIdTypeArray> &cells,
01869                      vtkSmartPointer<vtkIdTypeArray> &initcells,
01870                      vtkIdType nr_points);
01871 
01872         /** \brief Internal function which converts the information present in the geometric
01873           * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
01874           * all the required information to the internal cloud_actor_map_ object.
01875           * \param[in] geometry_handler the geometric handler that contains the XYZ data
01876           * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
01877           * \param[in] id the point cloud object id
01878           * \param[in] viewport the view port where the Point Cloud should be added
01879           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
01880           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
01881           */
01882         template <typename PointT> bool
01883         fromHandlersToScreen (const PointCloudGeometryHandler<PointT> &geometry_handler,
01884                               const PointCloudColorHandler<PointT> &color_handler,
01885                               const std::string &id,
01886                               int viewport,
01887                               const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
01888                               const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
01889 
01890         /** \brief Internal function which converts the information present in the geometric
01891           * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
01892           * all the required information to the internal cloud_actor_map_ object.
01893           * \param[in] geometry_handler the geometric handler that contains the XYZ data
01894           * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
01895           * \param[in] id the point cloud object id
01896           * \param[in] viewport the view port where the Point Cloud should be added
01897           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
01898           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
01899           */
01900         template <typename PointT> bool
01901         fromHandlersToScreen (const PointCloudGeometryHandler<PointT> &geometry_handler,
01902                               const ColorHandlerConstPtr &color_handler,
01903                               const std::string &id,
01904                               int viewport,
01905                               const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
01906                               const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
01907 
01908         /** \brief Internal function which converts the information present in the geometric
01909           * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
01910           * all the required information to the internal cloud_actor_map_ object.
01911           * \param[in] geometry_handler the geometric handler that contains the XYZ data
01912           * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
01913           * \param[in] id the point cloud object id
01914           * \param[in] viewport the view port where the Point Cloud should be added
01915           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
01916           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
01917           */
01918         bool
01919         fromHandlersToScreen (const GeometryHandlerConstPtr &geometry_handler,
01920                               const ColorHandlerConstPtr &color_handler,
01921                               const std::string &id,
01922                               int viewport,
01923                               const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
01924                               const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
01925 
01926         /** \brief Internal function which converts the information present in the geometric
01927           * and color handlers into VTK PolyData+Scalars, constructs a vtkActor object, and adds
01928           * all the required information to the internal cloud_actor_map_ object.
01929           * \param[in] geometry_handler the geometric handler that contains the XYZ data
01930           * \param[in] color_handler the color handler that contains the "RGB" (scalar) data
01931           * \param[in] id the point cloud object id
01932           * \param[in] viewport the view port where the Point Cloud should be added
01933           * \param[in] sensor_origin the origin of the cloud data in global coordinates (defaults to 0,0,0)
01934           * \param[in] sensor_orientation the orientation of the cloud data in global coordinates (defaults to 1,0,0,0)
01935           */
01936         template <typename PointT> bool
01937         fromHandlersToScreen (const GeometryHandlerConstPtr &geometry_handler,
01938                               const PointCloudColorHandler<PointT> &color_handler,
01939                               const std::string &id,
01940                               int viewport,
01941                               const Eigen::Vector4f& sensor_origin = Eigen::Vector4f (0, 0, 0, 0),
01942                               const Eigen::Quaternion<float>& sensor_orientation = Eigen::Quaternion<float> (1, 0, 0 ,0));
01943 
01944         /** \brief Allocate a new polydata smartpointer. Internal
01945           * \param[out] polydata the resultant poly data
01946           */
01947         void
01948         allocVtkPolyData (vtkSmartPointer<vtkAppendPolyData> &polydata);
01949 
01950         /** \brief Allocate a new polydata smartpointer. Internal
01951           * \param[out] polydata the resultant poly data
01952           */
01953         void
01954         allocVtkPolyData (vtkSmartPointer<vtkPolyData> &polydata);
01955 
01956         /** \brief Allocate a new unstructured grid smartpointer. Internal
01957           * \param[out] polydata the resultant poly data
01958           */
01959         void
01960         allocVtkUnstructuredGrid (vtkSmartPointer<vtkUnstructuredGrid> &polydata);
01961 
01962         /** \brief Transform the point cloud viewpoint to a transformation matrix
01963           * \param[in] origin the camera origin
01964           * \param[in] orientation the camera orientation
01965           * \param[out] transformation the camera transformation matrix
01966           */
01967         void
01968         getTransformationMatrix (const Eigen::Vector4f &origin,
01969                                  const Eigen::Quaternion<float> &orientation,
01970                                  Eigen::Matrix4f &transformation);
01971 
01972         //There's no reason these conversion functions shouldn't be public and static so others can use them.
01973       public:
01974         /** \brief Convert Eigen::Matrix4f to vtkMatrix4x4
01975           * \param[in] m the input Eigen matrix
01976           * \param[out] vtk_matrix the resultant VTK matrix
01977           */
01978         static void
01979         convertToVtkMatrix (const Eigen::Matrix4f &m,
01980                             vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
01981 
01982         /** \brief Convert origin and orientation to vtkMatrix4x4
01983           * \param[in] origin the point cloud origin
01984           * \param[in] orientation the point cloud orientation
01985           * \param[out] vtk_matrix the resultant VTK 4x4 matrix
01986           */
01987         static void
01988         convertToVtkMatrix (const Eigen::Vector4f &origin,
01989                             const Eigen::Quaternion<float> &orientation,
01990                             vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
01991         
01992         /** \brief Convert vtkMatrix4x4 to an Eigen4f
01993           * \param[in] vtk_matrix the original VTK 4x4 matrix
01994           * \param[out] m the resultant Eigen 4x4 matrix
01995           */
01996         static void
01997         convertToEigenMatrix (const vtkSmartPointer<vtkMatrix4x4> &vtk_matrix,
01998                               Eigen::Matrix4f &m);
01999 
02000     };
02001   }
02002 }
02003 
02004 #include <pcl/visualization/impl/pcl_visualizer.hpp>
02005 
02006 #endif
02007