point_cloud_handlers.h
Go to the documentation of this file.
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  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * $Id: point_cloud_handlers.h 5162 2012-03-17 22:30:39Z rusu $
00037  *
00038  */
00039 #ifndef PCL_POINT_CLOUD_HANDLERS_H_
00040 #define PCL_POINT_CLOUD_HANDLERS_H_
00041 
00042 #include <pcl/visualization/common/common.h>
00043 // PCL includes
00044 #include <pcl/point_types.h>
00045 #include <pcl/point_cloud.h>
00046 #include <pcl/common/io.h>
00047 // VTK includes
00048 #include <pcl/visualization/vtk.h>
00049 
00050 namespace pcl
00051 {
00052   namespace visualization
00053   {
00057     template <typename PointT>
00058     class PointCloudGeometryHandler
00059     {
00060       public:
00061         typedef pcl::PointCloud<PointT> PointCloud;
00062         typedef typename PointCloud::Ptr PointCloudPtr;
00063         typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00064 
00065         typedef typename boost::shared_ptr<PointCloudGeometryHandler<PointT> > Ptr;
00066         typedef typename boost::shared_ptr<const PointCloudGeometryHandler<PointT> > ConstPtr;
00067 
00069         PointCloudGeometryHandler (const PointCloudConstPtr &cloud) :
00070           cloud_ (cloud), capable_ (false),
00071           field_x_idx_ (-1), field_y_idx_ (-1), field_z_idx_ (-1),
00072           fields_ ()
00073         {}
00074 
00076         virtual ~PointCloudGeometryHandler () {}
00077 
00081         virtual std::string
00082         getName () const = 0;
00083 
00085         virtual std::string
00086         getFieldName () const  = 0;
00087 
00089         inline bool
00090         isCapable () const { return (capable_); }
00091 
00095         virtual void
00096         getGeometry (vtkSmartPointer<vtkPoints> &points) const = 0;
00097 
00098       protected:
00100         PointCloudConstPtr cloud_;
00101 
00105         bool capable_;
00106 
00108         int field_x_idx_;
00109 
00111         int field_y_idx_;
00112 
00114         int field_z_idx_;
00115 
00117         std::vector<sensor_msgs::PointField> fields_;
00118     };
00119 
00121 
00125     template <typename PointT>
00126     class PointCloudGeometryHandlerXYZ : public PointCloudGeometryHandler<PointT>
00127     {
00128       public:
00129         typedef typename PointCloudGeometryHandler<PointT>::PointCloud PointCloud;
00130         typedef typename PointCloud::Ptr PointCloudPtr;
00131         typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00132 
00133         typedef typename boost::shared_ptr<PointCloudGeometryHandlerXYZ<PointT> > Ptr;
00134         typedef typename boost::shared_ptr<const PointCloudGeometryHandlerXYZ<PointT> > ConstPtr;
00135 
00137         PointCloudGeometryHandlerXYZ (const PointCloudConstPtr &cloud);
00138 
00140         virtual ~PointCloudGeometryHandlerXYZ () {};
00141 
00143         virtual inline std::string
00144         getName () const { return ("PointCloudGeometryHandlerXYZ"); }
00145 
00147         virtual std::string
00148         getFieldName () const { return ("xyz"); }
00149 
00153         virtual void
00154         getGeometry (vtkSmartPointer<vtkPoints> &points) const;
00155 
00156       private:
00157         // Members derived from the base class
00158         using PointCloudGeometryHandler<PointT>::cloud_;
00159         using PointCloudGeometryHandler<PointT>::capable_;
00160         using PointCloudGeometryHandler<PointT>::field_x_idx_;
00161         using PointCloudGeometryHandler<PointT>::field_y_idx_;
00162         using PointCloudGeometryHandler<PointT>::field_z_idx_;
00163         using PointCloudGeometryHandler<PointT>::fields_;
00164     };
00165 
00167 
00172     template <typename PointT>
00173     class PointCloudGeometryHandlerSurfaceNormal : public PointCloudGeometryHandler<PointT>
00174     {
00175       public:
00176         typedef typename PointCloudGeometryHandler<PointT>::PointCloud PointCloud;
00177         typedef typename PointCloud::Ptr PointCloudPtr;
00178         typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00179 
00180         typedef typename boost::shared_ptr<PointCloudGeometryHandlerSurfaceNormal<PointT> > Ptr;
00181         typedef typename boost::shared_ptr<const PointCloudGeometryHandlerSurfaceNormal<PointT> > ConstPtr;
00182 
00184         PointCloudGeometryHandlerSurfaceNormal (const PointCloudConstPtr &cloud);
00185 
00187         virtual inline std::string
00188         getName () const { return ("PointCloudGeometryHandlerSurfaceNormal"); }
00189 
00191         virtual std::string
00192         getFieldName () const { return ("normal_xyz"); }
00193 
00197         virtual void
00198         getGeometry (vtkSmartPointer<vtkPoints> &points) const;
00199 
00200       private:
00201         // Members derived from the base class
00202         using PointCloudGeometryHandler<PointT>::cloud_;
00203         using PointCloudGeometryHandler<PointT>::capable_;
00204         using PointCloudGeometryHandler<PointT>::field_x_idx_;
00205         using PointCloudGeometryHandler<PointT>::field_y_idx_;
00206         using PointCloudGeometryHandler<PointT>::field_z_idx_;
00207         using PointCloudGeometryHandler<PointT>::fields_;
00208     };
00209 
00211 
00216     template <typename PointT>
00217     class PointCloudGeometryHandlerCustom : public PointCloudGeometryHandler<PointT>
00218     {
00219       public:
00220         typedef typename PointCloudGeometryHandler<PointT>::PointCloud PointCloud;
00221         typedef typename PointCloud::Ptr PointCloudPtr;
00222         typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00223 
00224         typedef typename boost::shared_ptr<PointCloudGeometryHandlerCustom<PointT> > Ptr;
00225         typedef typename boost::shared_ptr<const PointCloudGeometryHandlerCustom<PointT> > ConstPtr;
00226 
00228         PointCloudGeometryHandlerCustom (const PointCloudConstPtr &cloud,
00229                                          const std::string &x_field_name,
00230                                          const std::string &y_field_name,
00231                                          const std::string &z_field_name);
00232 
00234         virtual inline std::string
00235         getName () const { return ("PointCloudGeometryHandlerCustom"); }
00236 
00238         virtual std::string
00239         getFieldName () const { return (field_name_); }
00240 
00244         virtual void
00245         getGeometry (vtkSmartPointer<vtkPoints> &points) const;
00246 
00247       private:
00248         // Members derived from the base class
00249         using PointCloudGeometryHandler<PointT>::cloud_;
00250         using PointCloudGeometryHandler<PointT>::capable_;
00251         using PointCloudGeometryHandler<PointT>::field_x_idx_;
00252         using PointCloudGeometryHandler<PointT>::field_y_idx_;
00253         using PointCloudGeometryHandler<PointT>::field_z_idx_;
00254         using PointCloudGeometryHandler<PointT>::fields_;
00255 
00257         std::string field_name_;
00258     };
00259 
00261 
00264     template <>
00265     class PCL_EXPORTS PointCloudGeometryHandler<sensor_msgs::PointCloud2>
00266     {
00267       public:
00268         typedef sensor_msgs::PointCloud2 PointCloud;
00269         typedef PointCloud::Ptr PointCloudPtr;
00270         typedef PointCloud::ConstPtr PointCloudConstPtr;
00271 
00272         typedef boost::shared_ptr<PointCloudGeometryHandler<PointCloud> > Ptr;
00273         typedef boost::shared_ptr<const PointCloudGeometryHandler<PointCloud> > ConstPtr;
00274 
00276         PointCloudGeometryHandler (const PointCloudConstPtr &cloud, const Eigen::Vector4f &sensor_origin = Eigen::Vector4f::Zero ())
00277         : cloud_ (cloud)
00278         , capable_ (false)
00279         {
00280           fields_ = cloud_->fields;
00281         }
00282 
00284         virtual std::string
00285         getName () const = 0;
00286 
00288         virtual std::string
00289         getFieldName () const  = 0;
00290 
00292         inline bool
00293         isCapable () const { return (capable_); }
00294 
00298         virtual void
00299         getGeometry (vtkSmartPointer<vtkPoints> &points) const;
00300 
00301       protected:
00303         PointCloudConstPtr cloud_;
00304 
00308         bool capable_;
00309 
00311         int field_x_idx_;
00312 
00314         int field_y_idx_;
00315 
00317         int field_z_idx_;
00318 
00320         std::vector<sensor_msgs::PointField> fields_;
00321     };
00322 
00324 
00328     template <>
00329     class PCL_EXPORTS PointCloudGeometryHandlerXYZ<sensor_msgs::PointCloud2> : public PointCloudGeometryHandler<sensor_msgs::PointCloud2>
00330     {
00331       public:
00332         typedef PointCloudGeometryHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00333         typedef PointCloud::Ptr PointCloudPtr;
00334         typedef PointCloud::ConstPtr PointCloudConstPtr;
00335 
00336         typedef boost::shared_ptr<PointCloudGeometryHandlerXYZ<PointCloud> > Ptr;
00337         typedef boost::shared_ptr<const PointCloudGeometryHandlerXYZ<PointCloud> > ConstPtr;
00338 
00340         PointCloudGeometryHandlerXYZ (const PointCloudConstPtr &cloud);
00341 
00343         virtual ~PointCloudGeometryHandlerXYZ () {}
00344 
00346         virtual inline
00347         std::string getName () const { return ("PointCloudGeometryHandlerXYZ"); }
00348 
00350         virtual std::string
00351         getFieldName () const { return ("xyz"); }
00352     };
00353 
00355 
00360     template <>
00361     class PCL_EXPORTS PointCloudGeometryHandlerSurfaceNormal<sensor_msgs::PointCloud2> : public PointCloudGeometryHandler<sensor_msgs::PointCloud2>
00362     {
00363       public:
00364         typedef PointCloudGeometryHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00365         typedef PointCloud::Ptr PointCloudPtr;
00366         typedef PointCloud::ConstPtr PointCloudConstPtr;
00367 
00368         typedef boost::shared_ptr<PointCloudGeometryHandlerSurfaceNormal<PointCloud> > Ptr;
00369         typedef boost::shared_ptr<const PointCloudGeometryHandlerSurfaceNormal<PointCloud> > ConstPtr;
00370 
00372         PointCloudGeometryHandlerSurfaceNormal (const PointCloudConstPtr &cloud);
00373 
00375         virtual inline std::string
00376         getName () const { return ("PointCloudGeometryHandlerSurfaceNormal"); }
00377 
00379         virtual std::string
00380         getFieldName () const { return ("normal_xyz"); }
00381     };
00382 
00384 
00389     template <>
00390     class PCL_EXPORTS PointCloudGeometryHandlerCustom<sensor_msgs::PointCloud2> : public PointCloudGeometryHandler<sensor_msgs::PointCloud2>
00391     {
00392       public:
00393         typedef PointCloudGeometryHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00394         typedef PointCloud::Ptr PointCloudPtr;
00395         typedef PointCloud::ConstPtr PointCloudConstPtr;
00396 
00398         PointCloudGeometryHandlerCustom (const PointCloudConstPtr &cloud,
00399                                          const std::string &x_field_name,
00400                                          const std::string &y_field_name,
00401                                          const std::string &z_field_name);
00402 
00404         virtual ~PointCloudGeometryHandlerCustom () {}
00405 
00407         virtual inline std::string
00408         getName () const { return ("PointCloudGeometryHandlerCustom"); }
00409 
00411         virtual std::string
00412         getFieldName () const { return (field_name_); }
00413 
00414       private:
00416         std::string field_name_;
00417     };
00418 
00420 
00423     template <typename PointT>
00424     class PointCloudColorHandler
00425     {
00426       public:
00427         typedef pcl::PointCloud<PointT> PointCloud;
00428         typedef typename PointCloud::Ptr PointCloudPtr;
00429         typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00430 
00431         typedef boost::shared_ptr<PointCloudColorHandler<PointT> > Ptr;
00432         typedef boost::shared_ptr<const PointCloudColorHandler<PointT> > ConstPtr;
00433 
00435         PointCloudColorHandler (const PointCloudConstPtr &cloud) :
00436           cloud_ (cloud), capable_ (false), field_idx_ (-1), fields_ ()
00437         {}
00438 
00440         virtual ~PointCloudColorHandler () {}
00441 
00443         inline bool
00444         isCapable () const { return (capable_); }
00445 
00447         virtual std::string
00448         getName () const = 0;
00449 
00451         virtual std::string
00452         getFieldName () const = 0;
00453 
00457         virtual void
00458         getColor (vtkSmartPointer<vtkDataArray> &scalars) const = 0;
00459 
00460       protected:
00462         PointCloudConstPtr cloud_;
00463 
00467         bool capable_;
00468 
00470         int field_idx_;
00471 
00473         std::vector<sensor_msgs::PointField> fields_;
00474     };
00475 
00477 
00480     template <typename PointT>
00481     class PointCloudColorHandlerRandom : public PointCloudColorHandler<PointT>
00482     {
00483       typedef typename PointCloudColorHandler<PointT>::PointCloud PointCloud;
00484       typedef typename PointCloud::Ptr PointCloudPtr;
00485       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00486 
00487       public:
00488         typedef boost::shared_ptr<PointCloudColorHandlerRandom<PointT> > Ptr;
00489         typedef boost::shared_ptr<const PointCloudColorHandlerRandom<PointT> > ConstPtr;
00490 
00492         PointCloudColorHandlerRandom (const PointCloudConstPtr &cloud) :
00493           PointCloudColorHandler<PointT> (cloud)
00494         {
00495           capable_ = true;
00496         }
00497 
00499         virtual inline std::string
00500         getName () const { return ("PointCloudColorHandlerRandom"); }
00501 
00503         virtual std::string
00504         getFieldName () const { return ("[random]"); }
00505 
00509         virtual void
00510         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00511 
00512       protected:
00513         // Members derived from the base class
00514         using PointCloudColorHandler<PointT>::cloud_;
00515         using PointCloudColorHandler<PointT>::capable_;
00516     };
00517 
00519 
00523     template <typename PointT>
00524     class PointCloudColorHandlerCustom : public PointCloudColorHandler<PointT>
00525     {
00526       typedef typename PointCloudColorHandler<PointT>::PointCloud PointCloud;
00527       typedef typename PointCloud::Ptr PointCloudPtr;
00528       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00529 
00530       public:
00531         typedef boost::shared_ptr<PointCloudColorHandlerCustom<PointT> > Ptr;
00532         typedef boost::shared_ptr<const PointCloudColorHandlerCustom<PointT> > ConstPtr;
00533 
00535         PointCloudColorHandlerCustom (const PointCloudConstPtr &cloud,
00536                                       double r, double g, double b)
00537           : PointCloudColorHandler<PointT> (cloud)
00538           , r_ (r)
00539           , g_ (g)
00540           , b_ (b)
00541         {
00542           capable_ = true;
00543         }
00544 
00546         virtual ~PointCloudColorHandlerCustom () {};
00547 
00549         virtual inline std::string
00550         getName () const { return ("PointCloudColorHandlerCustom"); }
00551 
00553         virtual std::string
00554         getFieldName () const { return (""); }
00555 
00559         virtual void
00560         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00561 
00562       protected:
00563         // Members derived from the base class
00564         using PointCloudColorHandler<PointT>::cloud_;
00565         using PointCloudColorHandler<PointT>::capable_;
00566 
00568         double r_, g_, b_;
00569     };
00570 
00572 
00576     template <typename PointT>
00577     class PointCloudColorHandlerRGBField : public PointCloudColorHandler<PointT>
00578     {
00579       typedef typename PointCloudColorHandler<PointT>::PointCloud PointCloud;
00580       typedef typename PointCloud::Ptr PointCloudPtr;
00581       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00582 
00583       public:
00584         typedef boost::shared_ptr<PointCloudColorHandlerRGBField<PointT> > Ptr;
00585         typedef boost::shared_ptr<const PointCloudColorHandlerRGBField<PointT> > ConstPtr;
00586 
00588         PointCloudColorHandlerRGBField (const PointCloudConstPtr &cloud);
00589 
00591         virtual ~PointCloudColorHandlerRGBField () {}
00592 
00594         virtual std::string
00595         getFieldName () const { return ("rgb"); }
00596 
00600         virtual void
00601         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00602 
00603       protected:
00605         virtual inline std::string
00606         getName () const { return ("PointCloudColorHandlerRGBField"); }
00607 
00608       private:
00609         // Members derived from the base class
00610         using PointCloudColorHandler<PointT>::cloud_;
00611         using PointCloudColorHandler<PointT>::capable_;
00612         using PointCloudColorHandler<PointT>::field_idx_;
00613         using PointCloudColorHandler<PointT>::fields_;
00614     };
00615 
00617 
00621     template <typename PointT>
00622     class PointCloudColorHandlerHSVField : public PointCloudColorHandler<PointT>
00623     {
00624       typedef typename PointCloudColorHandler<PointT>::PointCloud PointCloud;
00625       typedef typename PointCloud::Ptr PointCloudPtr;
00626       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00627 
00628       public:
00629         typedef boost::shared_ptr<PointCloudColorHandlerHSVField<PointT> > Ptr;
00630         typedef boost::shared_ptr<const PointCloudColorHandlerHSVField<PointT> > ConstPtr;
00631 
00633         PointCloudColorHandlerHSVField (const PointCloudConstPtr &cloud);
00634 
00636         virtual std::string
00637         getFieldName () const { return ("hsv"); }
00638 
00642         virtual void
00643         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00644 
00645       protected:
00647         virtual inline std::string
00648         getName () const { return ("PointCloudColorHandlerHSVField"); }
00649 
00651         int s_field_idx_;
00652 
00654         int v_field_idx_;
00655       private:
00656         // Members derived from the base class
00657         using PointCloudColorHandler<PointT>::cloud_;
00658         using PointCloudColorHandler<PointT>::capable_;
00659         using PointCloudColorHandler<PointT>::field_idx_;
00660         using PointCloudColorHandler<PointT>::fields_;
00661     };
00662 
00664 
00668     template <typename PointT>
00669     class PointCloudColorHandlerGenericField : public PointCloudColorHandler<PointT>
00670     {
00671       typedef typename PointCloudColorHandler<PointT>::PointCloud PointCloud;
00672       typedef typename PointCloud::Ptr PointCloudPtr;
00673       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00674 
00675       public:
00676         typedef boost::shared_ptr<PointCloudColorHandlerGenericField<PointT> > Ptr;
00677         typedef boost::shared_ptr<const PointCloudColorHandlerGenericField<PointT> > ConstPtr;
00678 
00680         PointCloudColorHandlerGenericField (const PointCloudConstPtr &cloud,
00681                                             const std::string &field_name);
00682 
00684         virtual ~PointCloudColorHandlerGenericField () {}
00685 
00687         virtual std::string getFieldName () const { return (field_name_); }
00688 
00692         virtual void
00693         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00694 
00695       protected:
00697         virtual inline std::string
00698         getName () const { return ("PointCloudColorHandlerGenericField"); }
00699 
00700       private:
00701         using PointCloudColorHandler<PointT>::cloud_;
00702         using PointCloudColorHandler<PointT>::capable_;
00703         using PointCloudColorHandler<PointT>::field_idx_;
00704         using PointCloudColorHandler<PointT>::fields_;
00705 
00707         std::string field_name_;
00708     };
00709 
00711 
00714     template <>
00715     class PCL_EXPORTS PointCloudColorHandler<sensor_msgs::PointCloud2>
00716     {
00717       public:
00718         typedef sensor_msgs::PointCloud2 PointCloud;
00719         typedef PointCloud::Ptr PointCloudPtr;
00720         typedef PointCloud::ConstPtr PointCloudConstPtr;
00721 
00722         typedef boost::shared_ptr<PointCloudColorHandler<PointCloud> > Ptr;
00723         typedef boost::shared_ptr<const PointCloudColorHandler<PointCloud> > ConstPtr;
00724 
00726         PointCloudColorHandler (const PointCloudConstPtr &cloud) :
00727           cloud_ (cloud), capable_ (false), field_idx_ ()
00728         {}
00729         
00731         virtual ~PointCloudColorHandler () {}
00732 
00734         inline bool
00735         isCapable () const { return (capable_); }
00736 
00738         virtual std::string
00739         getName () const = 0;
00740 
00742         virtual std::string
00743         getFieldName () const = 0;
00744 
00748         virtual void
00749         getColor (vtkSmartPointer<vtkDataArray> &scalars) const = 0;
00750 
00751       protected:
00753         PointCloudConstPtr cloud_;
00754 
00758         bool capable_;
00759 
00761         int field_idx_;
00762     };
00763 
00765 
00768     template <>
00769     class PCL_EXPORTS PointCloudColorHandlerRandom<sensor_msgs::PointCloud2> : public PointCloudColorHandler<sensor_msgs::PointCloud2>
00770     {
00771       typedef PointCloudColorHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00772       typedef PointCloud::Ptr PointCloudPtr;
00773       typedef PointCloud::ConstPtr PointCloudConstPtr;
00774 
00775       public:
00776         typedef boost::shared_ptr<PointCloudColorHandlerRandom<PointCloud> > Ptr;
00777         typedef boost::shared_ptr<const PointCloudColorHandlerRandom<PointCloud> > ConstPtr;
00778 
00780         PointCloudColorHandlerRandom (const PointCloudConstPtr &cloud) :
00781           PointCloudColorHandler<sensor_msgs::PointCloud2> (cloud)
00782         {
00783           capable_ = true;
00784         }
00785 
00787         virtual inline std::string
00788         getName () const { return ("PointCloudColorHandlerRandom"); }
00789 
00791         virtual std::string
00792         getFieldName () const { return ("[random]"); }
00793 
00797         virtual void
00798         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00799     };
00800 
00802 
00806     template <>
00807     class PCL_EXPORTS PointCloudColorHandlerCustom<sensor_msgs::PointCloud2> : public PointCloudColorHandler<sensor_msgs::PointCloud2>
00808     {
00809       typedef PointCloudColorHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00810       typedef PointCloud::Ptr PointCloudPtr;
00811       typedef PointCloud::ConstPtr PointCloudConstPtr;
00812 
00813       public:
00815         PointCloudColorHandlerCustom (const PointCloudConstPtr &cloud,
00816                                       double r, double g, double b) :
00817           PointCloudColorHandler<sensor_msgs::PointCloud2> (cloud),
00818           r_ (r), g_ (g), b_ (b)
00819         {
00820           capable_ = true;
00821         }
00822 
00824         virtual inline std::string
00825         getName () const { return ("PointCloudColorHandlerCustom"); }
00826 
00828         virtual std::string
00829         getFieldName () const { return (""); }
00830 
00834         virtual void
00835         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00836 
00837       protected:
00839         double r_, g_, b_;
00840     };
00841 
00843 
00847     template <>
00848     class PCL_EXPORTS PointCloudColorHandlerRGBField<sensor_msgs::PointCloud2> : public PointCloudColorHandler<sensor_msgs::PointCloud2>
00849     {
00850       typedef PointCloudColorHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00851       typedef PointCloud::Ptr PointCloudPtr;
00852       typedef PointCloud::ConstPtr PointCloudConstPtr;
00853 
00854       public:
00855         typedef boost::shared_ptr<PointCloudColorHandlerRGBField<PointCloud> > Ptr;
00856         typedef boost::shared_ptr<const PointCloudColorHandlerRGBField<PointCloud> > ConstPtr;
00857 
00859         PointCloudColorHandlerRGBField (const PointCloudConstPtr &cloud);
00860 
00864         virtual void
00865         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00866 
00867       protected:
00869         virtual inline std::string
00870         getName () const { return ("PointCloudColorHandlerRGBField"); }
00871 
00873         virtual std::string
00874         getFieldName () const { return ("rgb"); }
00875     };
00876 
00878 
00882     template <>
00883     class PCL_EXPORTS PointCloudColorHandlerHSVField<sensor_msgs::PointCloud2> : public PointCloudColorHandler<sensor_msgs::PointCloud2>
00884     {
00885       typedef PointCloudColorHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00886       typedef PointCloud::Ptr PointCloudPtr;
00887       typedef PointCloud::ConstPtr PointCloudConstPtr;
00888 
00889       public:
00890         typedef boost::shared_ptr<PointCloudColorHandlerHSVField<PointCloud> > Ptr;
00891         typedef boost::shared_ptr<const PointCloudColorHandlerHSVField<PointCloud> > ConstPtr;
00892 
00894         PointCloudColorHandlerHSVField (const PointCloudConstPtr &cloud);
00895 
00899         virtual void
00900         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00901 
00902       protected:
00904         virtual inline std::string
00905         getName () const { return ("PointCloudColorHandlerHSVField"); }
00906 
00908         virtual std::string
00909         getFieldName () const { return ("hsv"); }
00910 
00912         int s_field_idx_;
00913 
00915         int v_field_idx_;
00916      };
00917 
00919 
00923     template <>
00924     class PCL_EXPORTS PointCloudColorHandlerGenericField<sensor_msgs::PointCloud2> : public PointCloudColorHandler<sensor_msgs::PointCloud2>
00925     {
00926       typedef PointCloudColorHandler<sensor_msgs::PointCloud2>::PointCloud PointCloud;
00927       typedef PointCloud::Ptr PointCloudPtr;
00928       typedef PointCloud::ConstPtr PointCloudConstPtr;
00929 
00930       public:
00931         typedef boost::shared_ptr<PointCloudColorHandlerGenericField<PointCloud> > Ptr;
00932         typedef boost::shared_ptr<const PointCloudColorHandlerGenericField<PointCloud> > ConstPtr;
00933 
00935         PointCloudColorHandlerGenericField (const PointCloudConstPtr &cloud,
00936                                             const std::string &field_name);
00937 
00941         virtual void
00942         getColor (vtkSmartPointer<vtkDataArray> &scalars) const;
00943 
00944       protected:
00946         virtual inline std::string
00947         getName () const { return ("PointCloudColorHandlerGenericField"); }
00948 
00950         virtual std::string
00951         getFieldName () const { return (field_name_); }
00952 
00953       private:
00955         std::string field_name_;
00956     };
00957 
00958   }
00959 }
00960 
00961 #include <pcl/visualization/impl/point_cloud_handlers.hpp>
00962 
00963 #endif


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:17:19