Point Cloud Library (PCL)  1.11.0
point_cloud_color_handlers.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #pragma once
39 
40 #if defined __GNUC__
41 #pragma GCC system_header
42 #endif
43 
44 // PCL includes
45 #include <pcl/pcl_macros.h>
46 #include <pcl/point_cloud.h>
47 #include <pcl/common/io.h>
48 #include <pcl/visualization/common/common.h>
49 // VTK includes
50 #include <vtkSmartPointer.h>
51 #include <vtkDataArray.h>
52 #include <vtkFloatArray.h>
53 #include <vtkUnsignedCharArray.h>
54 
55 namespace pcl
56 {
57  namespace visualization
58  {
59  //////////////////////////////////////////////////////////////////////////////////////
60  /** \brief Base Handler class for PointCloud colors.
61  * \author Radu B. Rusu
62  * \ingroup visualization
63  */
64  template <typename PointT>
66  {
67  public:
69  using PointCloudPtr = typename PointCloud::Ptr;
71 
72  using Ptr = shared_ptr<PointCloudColorHandler<PointT> >;
73  using ConstPtr = shared_ptr<const PointCloudColorHandler<PointT> >;
74 
75  /** \brief Constructor. */
77  cloud_ (), capable_ (false), field_idx_ (-1), fields_ ()
78  {}
79 
80  /** \brief Constructor. */
82  cloud_ (cloud), capable_ (false), field_idx_ (-1), fields_ ()
83  {}
84 
85  /** \brief Destructor. */
87 
88  /** \brief Check if this handler is capable of handling the input data or not. */
89  inline bool
90  isCapable () const { return (capable_); }
91 
92  /** \brief Abstract getName method. */
93  virtual std::string
94  getName () const = 0;
95 
96  /** \brief Abstract getFieldName method. */
97  virtual std::string
98  getFieldName () const = 0;
99 
100  /** Obtain the actual color for the input dataset as a VTK data array.
101  * Deriving handlers should override this method. The default implementation is
102  * provided only for backwards compatibility with handlers that were written
103  * before PCL 1.10.0 and will be removed in future.
104  * \return smart pointer to VTK array if the operation was successful (the
105  * handler is capable and the input cloud was given), a null pointer otherwise */
107  getColor () const {
109  getColor (scalars);
110  return scalars;
111  }
112 
113  /** Obtain the actual color for the input dataset as a VTK data array.
114  * This virtual method should not be overriden or used. The default implementation
115  * is provided only for backwards compatibility with handlers that were written
116  * before PCL 1.10.0 and will be removed in future. */
117  PCL_DEPRECATED(1, 12, "use getColor() without parameters instead")
118  virtual bool
119  getColor (vtkSmartPointer<vtkDataArray> &scalars) const {
120  scalars = getColor ();
121  return scalars.Get() != nullptr;
122  }
123 
124  /** \brief Set the input cloud to be used.
125  * \param[in] cloud the input cloud to be used by the handler
126  */
127  virtual void
129  {
130  cloud_ = cloud;
131  }
132 
133  protected:
134  /** \brief A pointer to the input dataset. */
136 
137  /** \brief True if this handler is capable of handling the input data, false
138  * otherwise.
139  */
140  bool capable_;
141 
142  /** \brief The index of the field holding the data that represents the color. */
144 
145  /** \brief The list of fields available for this PointCloud. */
146  std::vector<pcl::PCLPointField> fields_;
147  };
148 
149  //////////////////////////////////////////////////////////////////////////////////////
150  /** \brief Handler for random PointCloud colors (i.e., R, G, B will be randomly chosen)
151  * \author Radu B. Rusu
152  * \ingroup visualization
153  */
154  template <typename PointT>
156  {
158  using PointCloudPtr = typename PointCloud::Ptr;
159  using PointCloudConstPtr = typename PointCloud::ConstPtr;
160 
161  public:
162  using Ptr = shared_ptr<PointCloudColorHandlerRandom<PointT> >;
163  using ConstPtr = shared_ptr<const PointCloudColorHandlerRandom<PointT> >;
164 
165  /** \brief Constructor. */
168  {
169  capable_ = true;
170  }
171 
172  /** \brief Constructor. */
175  {
176  capable_ = true;
177  }
178 
179  /** \brief Abstract getName method. */
180  virtual std::string
181  getName () const { return ("PointCloudColorHandlerRandom"); }
182 
183  /** \brief Get the name of the field used. */
184  virtual std::string
185  getFieldName () const { return ("[random]"); }
186 
188  getColor () const override;
189 
191 
192  protected:
193  // Members derived from the base class
196  };
197 
198  //////////////////////////////////////////////////////////////////////////////////////
199  /** \brief Handler for predefined user colors. The color at each point will be drawn
200  * as the use given R, G, B values.
201  * \author Radu B. Rusu
202  * \ingroup visualization
203  */
204  template <typename PointT>
206  {
208  using PointCloudPtr = typename PointCloud::Ptr;
209  using PointCloudConstPtr = typename PointCloud::ConstPtr;
210 
211  public:
212  using Ptr = shared_ptr<PointCloudColorHandlerCustom<PointT> >;
213  using ConstPtr = shared_ptr<const PointCloudColorHandlerCustom<PointT> >;
214 
215  /** \brief Constructor. */
216  PointCloudColorHandlerCustom (double r, double g, double b)
218  , r_ (r)
219  , g_ (g)
220  , b_ (b)
221  {
222  capable_ = true;
223  }
224 
225  /** \brief Constructor. */
227  double r, double g, double b)
228  : PointCloudColorHandler<PointT> (cloud)
229  , r_ (r)
230  , g_ (g)
231  , b_ (b)
232  {
233  capable_ = true;
234  }
235 
236  /** \brief Destructor. */
238 
239  /** \brief Abstract getName method. */
240  virtual std::string
241  getName () const { return ("PointCloudColorHandlerCustom"); }
242 
243  /** \brief Get the name of the field used. */
244  virtual std::string
245  getFieldName () const { return (""); }
246 
248  getColor () const override;
249 
251 
252  protected:
253  // Members derived from the base class
256 
257  /** \brief Internal R, G, B holding the values given by the user. */
258  double r_, g_, b_;
259  };
260 
261  //////////////////////////////////////////////////////////////////////////////////////
262  /** \brief RGB handler class for colors. Uses the data present in the "rgb" or "rgba"
263  * fields as the color at each point.
264  * \author Radu B. Rusu
265  * \ingroup visualization
266  */
267  template <typename PointT>
269  {
271  using PointCloudPtr = typename PointCloud::Ptr;
272  using PointCloudConstPtr = typename PointCloud::ConstPtr;
273 
274  public:
275  using Ptr = shared_ptr<PointCloudColorHandlerRGBField<PointT> >;
276  using ConstPtr = shared_ptr<const PointCloudColorHandlerRGBField<PointT> >;
277 
278  /** \brief Constructor. */
280  {
281  capable_ = false;
282  }
283 
284  /** \brief Constructor. */
286  : PointCloudColorHandler<PointT> (cloud)
287  {
288  setInputCloud (cloud);
289  }
290 
291  /** \brief Destructor. */
293 
294  /** \brief Get the name of the field used. */
295  virtual std::string
296  getFieldName () const { return ("rgb"); }
297 
299  getColor () const override;
300 
302 
303  /** \brief Set the input cloud to be used.
304  * \param[in] cloud the input cloud to be used by the handler
305  */
306  virtual void
307  setInputCloud (const PointCloudConstPtr &cloud);
308 
309  protected:
310  /** \brief Class getName method. */
311  virtual std::string
312  getName () const { return ("PointCloudColorHandlerRGBField"); }
313 
314  private:
315  // Members derived from the base class
320  };
321 
322  //////////////////////////////////////////////////////////////////////////////////////
323  /** \brief HSV handler class for colors. Uses the data present in the "h", "s", "v"
324  * fields as the color at each point.
325  * \ingroup visualization
326  */
327  template <typename PointT>
329  {
331  using PointCloudPtr = typename PointCloud::Ptr;
332  using PointCloudConstPtr = typename PointCloud::ConstPtr;
333 
334  public:
335  using Ptr = shared_ptr<PointCloudColorHandlerHSVField<PointT> >;
336  using ConstPtr = shared_ptr<const PointCloudColorHandlerHSVField<PointT> >;
337 
338  /** \brief Constructor. */
340 
341  /** \brief Empty destructor */
343 
344  /** \brief Get the name of the field used. */
345  virtual std::string
346  getFieldName () const { return ("hsv"); }
347 
349  getColor () const override;
350 
352 
353  protected:
354  /** \brief Class getName method. */
355  virtual std::string
356  getName () const { return ("PointCloudColorHandlerHSVField"); }
357 
358  /** \brief The field index for "S". */
360 
361  /** \brief The field index for "V". */
363  private:
364  // Members derived from the base class
369  };
370 
371  //////////////////////////////////////////////////////////////////////////////////////
372  /** \brief Generic field handler class for colors. Uses an user given field to extract
373  * 1D data and display the color at each point using a min-max lookup table.
374  * \author Radu B. Rusu
375  * \ingroup visualization
376  */
377  template <typename PointT>
379  {
381  using PointCloudPtr = typename PointCloud::Ptr;
382  using PointCloudConstPtr = typename PointCloud::ConstPtr;
383 
384  public:
385  using Ptr = shared_ptr<PointCloudColorHandlerGenericField<PointT> >;
386  using ConstPtr = shared_ptr<const PointCloudColorHandlerGenericField<PointT> >;
387 
388  /** \brief Constructor. */
389  PointCloudColorHandlerGenericField (const std::string &field_name)
390  : field_name_ (field_name)
391  {
392  capable_ = false;
393  }
394 
395  /** \brief Constructor. */
397  const std::string &field_name)
398  : PointCloudColorHandler<PointT> (cloud)
399  , field_name_ (field_name)
400  {
401  setInputCloud (cloud);
402  }
403 
404  /** \brief Destructor. */
406 
407  /** \brief Get the name of the field used. */
408  virtual std::string getFieldName () const { return (field_name_); }
409 
411  getColor () const override;
412 
414 
415  /** \brief Set the input cloud to be used.
416  * \param[in] cloud the input cloud to be used by the handler
417  */
418  virtual void
419  setInputCloud (const PointCloudConstPtr &cloud);
420 
421  protected:
422  /** \brief Class getName method. */
423  virtual std::string
424  getName () const { return ("PointCloudColorHandlerGenericField"); }
425 
426  private:
431 
432  /** \brief Name of the field used to create the color handler. */
433  std::string field_name_;
434  };
435 
436 
437  //////////////////////////////////////////////////////////////////////////////////////
438  /** \brief RGBA handler class for colors. Uses the data present in the "rgba" field as
439  * the color at each point. Transparency is handled.
440  * \author Nizar Sallem
441  * \ingroup visualization
442  */
443  template <typename PointT>
445  {
447  using PointCloudPtr = typename PointCloud::Ptr;
448  using PointCloudConstPtr = typename PointCloud::ConstPtr;
449 
450  public:
451  using Ptr = shared_ptr<PointCloudColorHandlerRGBAField<PointT> >;
452  using ConstPtr = shared_ptr<const PointCloudColorHandlerRGBAField<PointT> >;
453 
454  /** \brief Constructor. */
456  {
457  capable_ = false;
458  }
459 
460  /** \brief Constructor. */
462  : PointCloudColorHandler<PointT> (cloud)
463  {
464  setInputCloud (cloud);
465  }
466 
467  /** \brief Destructor. */
469 
470  /** \brief Get the name of the field used. */
471  virtual std::string
472  getFieldName () const { return ("rgba"); }
473 
475  getColor () const override;
476 
478 
479  /** \brief Set the input cloud to be used.
480  * \param[in] cloud the input cloud to be used by the handler
481  */
482  virtual void
483  setInputCloud (const PointCloudConstPtr &cloud);
484 
485  protected:
486  /** \brief Class getName method. */
487  virtual std::string
488  getName () const { return ("PointCloudColorHandlerRGBAField"); }
489 
490  private:
491  // Members derived from the base class
496  };
497 
498  //////////////////////////////////////////////////////////////////////////////////////
499  /** \brief Label field handler class for colors. Paints the points according to their
500  * labels, assigning a unique color from a predefined color lookup table to each label.
501  * \author Sergey Alexandrov
502  * \ingroup visualization
503  */
504  template <typename PointT>
506  {
508  using PointCloudPtr = typename PointCloud::Ptr;
509  using PointCloudConstPtr = typename PointCloud::ConstPtr;
510 
511  public:
512  using Ptr = shared_ptr<PointCloudColorHandlerLabelField<PointT> >;
513  using ConstPtr = shared_ptr<const PointCloudColorHandlerLabelField<PointT> >;
514 
515  /** \brief Constructor.
516  * \param[in] static_mapping Use a static colormapping from label_id to color (default true) */
517  PointCloudColorHandlerLabelField (const bool static_mapping = true)
519  {
520  capable_ = false;
521  static_mapping_ = static_mapping;
522  }
523 
524  /** \brief Constructor.
525  * \param[in] static_mapping Use a static colormapping from label_id to color (default true) */
527  const bool static_mapping = true)
528  : PointCloudColorHandler<PointT> (cloud)
529  {
530  setInputCloud (cloud);
531  static_mapping_ = static_mapping;
532  }
533 
534  /** \brief Destructor. */
536 
537  /** \brief Get the name of the field used. */
538  virtual std::string
539  getFieldName () const { return ("label"); }
540 
542  getColor () const override;
543 
545 
546  /** \brief Set the input cloud to be used.
547  * \param[in] cloud the input cloud to be used by the handler
548  */
549  virtual void
550  setInputCloud (const PointCloudConstPtr &cloud);
551 
552  protected:
553  /** \brief Class getName method. */
554  virtual std::string
555  getName () const { return ("PointCloudColorHandlerLabelField"); }
556 
557  private:
558  // Members derived from the base class
563  bool static_mapping_;
564  };
565 
566  //////////////////////////////////////////////////////////////////////////////////////
567  /** \brief Base Handler class for PointCloud colors.
568  * \author Radu B. Rusu
569  * \ingroup visualization
570  */
571  template <>
573  {
574  public:
578 
579  using Ptr = shared_ptr<PointCloudColorHandler<PointCloud> >;
580  using ConstPtr = shared_ptr<const PointCloudColorHandler<PointCloud> >;
581 
582  /** \brief Constructor. */
584  cloud_ (cloud), capable_ (false), field_idx_ ()
585  {}
586 
587  /** \brief Destructor. */
589 
590  /** \brief Return whether this handler is capable of handling the input data or not. */
591  inline bool
592  isCapable () const { return (capable_); }
593 
594  /** \brief Abstract getName method. */
595  virtual std::string
596  getName () const = 0;
597 
598  /** \brief Abstract getFieldName method. */
599  virtual std::string
600  getFieldName () const = 0;
601 
602  /** Obtain the actual color for the input dataset as a VTK data array.
603  * Deriving handlers should override this method. The default implementation is
604  * provided only for backwards compatibility with handlers that were written
605  * before PCL 1.10.0 and will be removed in future.
606  * \return smart pointer to VTK array if the operation was successful (the
607  * handler is capable and the input cloud was given), a null pointer otherwise */
609  getColor () const {
611  getColor (scalars);
612  return scalars;
613  }
614 
615  /** Obtain the actual color for the input dataset as a VTK data array.
616  * This virtual method should not be overriden or used. The default implementation
617  * is provided only for backwards compatibility with handlers that were written
618  * before PCL 1.10.0 and will be removed in future. */
619  PCL_DEPRECATED(1, 12, "use getColor() without parameters instead")
620  virtual bool
621  getColor (vtkSmartPointer<vtkDataArray> &scalars) const {
622  scalars = getColor ();
623  return scalars.Get() != nullptr;
624  }
625 
626  /** \brief Set the input cloud to be used.
627  * \param[in] cloud the input cloud to be used by the handler
628  */
629  void
631  {
632  cloud_ = cloud;
633  }
634 
635  protected:
636  /** \brief A pointer to the input dataset. */
638 
639  /** \brief True if this handler is capable of handling the input data, false
640  * otherwise.
641  */
642  bool capable_;
643 
644  /** \brief The index of the field holding the data that represents the color. */
646  };
647 
648  //////////////////////////////////////////////////////////////////////////////////////
649  /** \brief Handler for random PointCloud colors (i.e., R, G, B will be randomly chosen)
650  * \author Radu B. Rusu
651  * \ingroup visualization
652  */
653  template <>
655  {
659 
660  public:
661  using Ptr = shared_ptr<PointCloudColorHandlerRandom<PointCloud> >;
662  using ConstPtr = shared_ptr<const PointCloudColorHandlerRandom<PointCloud> >;
663 
664  /** \brief Constructor. */
667  {
668  capable_ = true;
669  }
670 
671  /** \brief Empty destructor */
673 
674  /** \brief Get the name of the class. */
675  virtual std::string
676  getName () const { return ("PointCloudColorHandlerRandom"); }
677 
678  /** \brief Get the name of the field used. */
679  virtual std::string
680  getFieldName () const { return ("[random]"); }
681 
683  getColor () const override;
684 
686  };
687 
688  //////////////////////////////////////////////////////////////////////////////////////
689  /** \brief Handler for predefined user colors. The color at each point will be drawn
690  * as the use given R, G, B values.
691  * \author Radu B. Rusu
692  * \ingroup visualization
693  */
694  template <>
696  {
700 
701  public:
702  /** \brief Constructor. */
704  double r, double g, double b) :
706  r_ (r), g_ (g), b_ (b)
707  {
708  capable_ = true;
709  }
710 
711  /** \brief Empty destructor */
713 
714  /** \brief Get the name of the class. */
715  virtual std::string
716  getName () const { return ("PointCloudColorHandlerCustom"); }
717 
718  /** \brief Get the name of the field used. */
719  virtual std::string
720  getFieldName () const { return (""); }
721 
723  getColor () const override;
724 
726 
727  protected:
728  /** \brief Internal R, G, B holding the values given by the user. */
729  double r_, g_, b_;
730  };
731 
732  //////////////////////////////////////////////////////////////////////////////////////
733  /** \brief RGB handler class for colors. Uses the data present in the "rgb" or "rgba"
734  * fields as the color at each point.
735  * \author Radu B. Rusu
736  * \ingroup visualization
737  */
738  template <>
740  {
744 
745  public:
746  using Ptr = shared_ptr<PointCloudColorHandlerRGBField<PointCloud> >;
747  using ConstPtr = shared_ptr<const PointCloudColorHandlerRGBField<PointCloud> >;
748 
749  /** \brief Constructor. */
751 
752  /** \brief Empty destructor */
754 
756  getColor () const override;
757 
759 
760  protected:
761  /** \brief Get the name of the class. */
762  virtual std::string
763  getName () const { return ("PointCloudColorHandlerRGBField"); }
764 
765  /** \brief Get the name of the field used. */
766  virtual std::string
767  getFieldName () const { return ("rgb"); }
768  };
769 
770  //////////////////////////////////////////////////////////////////////////////////////
771  /** \brief HSV handler class for colors. Uses the data present in the "h", "s", "v"
772  * fields as the color at each point.
773  * \ingroup visualization
774  */
775  template <>
777  {
781 
782  public:
783  using Ptr = shared_ptr<PointCloudColorHandlerHSVField<PointCloud> >;
784  using ConstPtr = shared_ptr<const PointCloudColorHandlerHSVField<PointCloud> >;
785 
786  /** \brief Constructor. */
788 
789  /** \brief Empty destructor */
791 
793  getColor () const override;
794 
796 
797  protected:
798  /** \brief Get the name of the class. */
799  virtual std::string
800  getName () const { return ("PointCloudColorHandlerHSVField"); }
801 
802  /** \brief Get the name of the field used. */
803  virtual std::string
804  getFieldName () const { return ("hsv"); }
805 
806  /** \brief The field index for "S". */
808 
809  /** \brief The field index for "V". */
811  };
812 
813  //////////////////////////////////////////////////////////////////////////////////////
814  /** \brief Generic field handler class for colors. Uses an user given field to extract
815  * 1D data and display the color at each point using a min-max lookup table.
816  * \author Radu B. Rusu
817  * \ingroup visualization
818  */
819  template <>
821  {
825 
826  public:
827  using Ptr = shared_ptr<PointCloudColorHandlerGenericField<PointCloud> >;
828  using ConstPtr = shared_ptr<const PointCloudColorHandlerGenericField<PointCloud> >;
829 
830  /** \brief Constructor. */
832  const std::string &field_name);
833 
834  /** \brief Empty destructor */
836 
838  getColor () const override;
839 
841 
842  protected:
843  /** \brief Get the name of the class. */
844  virtual std::string
845  getName () const { return ("PointCloudColorHandlerGenericField"); }
846 
847  /** \brief Get the name of the field used. */
848  virtual std::string
849  getFieldName () const { return (field_name_); }
850 
851  private:
852  /** \brief Name of the field used to create the color handler. */
853  std::string field_name_;
854  };
855 
856  //////////////////////////////////////////////////////////////////////////////////////
857  /** \brief RGBA handler class for colors. Uses the data present in the "rgba" field as
858  * the color at each point. Transparency is handled.
859  * \author Nizar Sallem
860  * \ingroup visualization
861  */
862  template <>
864  {
868 
869  public:
870  using Ptr = shared_ptr<PointCloudColorHandlerRGBAField<PointCloud> >;
871  using ConstPtr = shared_ptr<const PointCloudColorHandlerRGBAField<PointCloud> >;
872 
873  /** \brief Constructor. */
875 
876  /** \brief Empty destructor */
878 
880  getColor () const override;
881 
883 
884  protected:
885  /** \brief Get the name of the class. */
886  virtual std::string
887  getName () const { return ("PointCloudColorHandlerRGBAField"); }
888 
889  /** \brief Get the name of the field used. */
890  virtual std::string
891  getFieldName () const { return ("rgba"); }
892  };
893 
894  //////////////////////////////////////////////////////////////////////////////////////
895  /** \brief Label field handler class for colors. Paints the points according to their
896  * labels, assigning a unique color from a predefined color lookup table to each label.
897  * \author Sergey Alexandrov
898  * \ingroup visualization
899  */
900  template <>
902  {
906 
907  public:
908  using Ptr = shared_ptr<PointCloudColorHandlerLabelField<PointCloud> >;
909  using ConstPtr = shared_ptr<const PointCloudColorHandlerLabelField<PointCloud> >;
910 
911  /** \brief Constructor.
912  * \param[in] static_mapping Use a static colormapping from label_id to color (default true) */
914  const bool static_mapping = true);
915 
916  /** \brief Empty destructor */
918 
920  getColor () const override;
921 
923 
924  protected:
925  /** \brief Get the name of the class. */
926  virtual std::string
927  getName () const { return ("PointCloudColorHandlerLabelField"); }
928 
929  /** \brief Get the name of the field used. */
930  virtual std::string
931  getFieldName () const { return ("label"); }
932  private:
933  bool static_mapping_;
934  };
935 
936  }
937 }
938 
939 #include <pcl/visualization/impl/point_cloud_color_handlers.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:180
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
int field_idx_
The index of the field holding the data that represents the color.
bool isCapable() const
Return whether this handler is capable of handling the input data or not.
virtual std::string getFieldName() const =0
Abstract getFieldName method.
void setInputCloud(const PointCloudConstPtr &cloud)
Set the input cloud to be used.
shared_ptr< const PointCloudColorHandler< PointCloud > > ConstPtr
virtual vtkSmartPointer< vtkDataArray > getColor() const
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getName() const =0
Abstract getName method.
bool capable_
True if this handler is capable of handling the input data, false otherwise.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getFieldName() const
Get the name of the field used.
PointCloudColorHandlerCustom(const PointCloudConstPtr &cloud, double r, double g, double b)
Constructor.
virtual std::string getFieldName() const
Get the name of the field used.
double r_
Internal R, G, B holding the values given by the user.
PointCloudColorHandlerCustom(const PointCloudConstPtr &cloud, double r, double g, double b)
Constructor.
PointCloudColorHandlerCustom(double r, double g, double b)
Constructor.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getName() const
Abstract getName method.
PointCloudColorHandlerGenericField(const PointCloudConstPtr &cloud, const std::string &field_name)
Constructor.
virtual std::string getFieldName() const
Get the name of the field used.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getFieldName() const
Get the name of the field used.
PointCloudColorHandlerGenericField(const PointCloudConstPtr &cloud, const std::string &field_name)
Constructor.
virtual std::string getName() const
Class getName method.
PointCloudColorHandlerGenericField(const std::string &field_name)
Constructor.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Set the input cloud to be used.
virtual std::string getFieldName() const
Get the name of the field used.
PointCloudColorHandlerHSVField(const PointCloudConstPtr &cloud)
Constructor.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
PointCloudColorHandlerHSVField(const PointCloudConstPtr &cloud)
Constructor.
virtual std::string getName() const
Class getName method.
virtual std::string getFieldName() const
Get the name of the field used.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
Base Handler class for PointCloud colors.
virtual vtkSmartPointer< vtkDataArray > getColor() const
Obtain the actual color for the input dataset as a VTK data array.
shared_ptr< const PointCloudColorHandler< PointT > > ConstPtr
bool capable_
True if this handler is capable of handling the input data, false otherwise.
bool isCapable() const
Check if this handler is capable of handling the input data or not.
PointCloudConstPtr cloud_
A pointer to the input dataset.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Set the input cloud to be used.
virtual std::string getName() const =0
Abstract getName method.
std::vector< pcl::PCLPointField > fields_
The list of fields available for this PointCloud.
PointCloudColorHandler(const PointCloudConstPtr &cloud)
Constructor.
shared_ptr< PointCloudColorHandler< PointT > > Ptr
virtual std::string getFieldName() const =0
Abstract getFieldName method.
int field_idx_
The index of the field holding the data that represents the color.
PointCloudColorHandlerLabelField(const PointCloudConstPtr &cloud, const bool static_mapping=true)
Constructor.
virtual std::string getFieldName() const
Get the name of the field used.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Set the input cloud to be used.
virtual std::string getName() const
Class getName method.
PointCloudColorHandlerLabelField(const PointCloudConstPtr &cloud, const bool static_mapping=true)
Constructor.
virtual std::string getFieldName() const
Get the name of the field used.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
PointCloudColorHandlerLabelField(const bool static_mapping=true)
Constructor.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getFieldName() const
Get the name of the field used.
PointCloudColorHandlerRGBAField(const PointCloudConstPtr &cloud)
Constructor.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Set the input cloud to be used.
PointCloudColorHandlerRGBAField(const PointCloudConstPtr &cloud)
Constructor.
virtual std::string getName() const
Class getName method.
virtual std::string getFieldName() const
Get the name of the field used.
virtual std::string getFieldName() const
Get the name of the field used.
PointCloudColorHandlerRGBField(const PointCloudConstPtr &cloud)
Constructor.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getFieldName() const
Get the name of the field used.
PointCloudColorHandlerRGBField(const PointCloudConstPtr &cloud)
Constructor.
virtual std::string getName() const
Class getName method.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Set the input cloud to be used.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
virtual std::string getFieldName() const
Get the name of the field used.
Handler for random PointCloud colors (i.e., R, G, B will be randomly chosen)
virtual std::string getName() const
Abstract getName method.
virtual std::string getFieldName() const
Get the name of the field used.
vtkSmartPointer< vtkDataArray > getColor() const override
Obtain the actual color for the input dataset as a VTK data array.
PointCloudColorHandlerRandom(const PointCloudConstPtr &cloud)
Constructor.
Defines all the PCL and non-PCL macros used.
#define PCL_EXPORTS
Definition: pcl_macros.h:331
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Definition: pcl_macros.h:150
A point structure representing Euclidean xyz coordinates, and the RGB color.