Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_VISUALUALIZATION_PCL_PLOTTER_IMPL_H_
00039 #define PCL_VISUALUALIZATION_PCL_PLOTTER_IMPL_H_
00040
00041 template <typename PointT> bool
00042 pcl::visualization::PCLPlotter::addFeatureHistogram (
00043 const pcl::PointCloud<PointT> &cloud, int hsize,
00044 const std::string &id, int win_width, int win_height)
00045 {
00046 std::vector<double> array_x(hsize), array_y(hsize);
00047
00048
00049 for (int i = 0; i < hsize; ++i)
00050 {
00051 array_x[i] = i;
00052 array_y[i] = cloud.points[0].histogram[i];
00053 }
00054
00055 this->addPlotData(array_x, array_y, id.c_str(), vtkChart::LINE);
00056 setWindowSize (win_width, win_height);
00057 return true;
00058 }
00059
00060
00061 template <typename PointT> bool
00062 pcl::visualization::PCLPlotter::addFeatureHistogram (
00063 const pcl::PointCloud<PointT> &cloud,
00064 const std::string &field_name,
00065 const int index,
00066 const std::string &id, int win_width, int win_height)
00067 {
00068 if (index < 0 || index >= cloud.points.size ())
00069 {
00070 PCL_ERROR ("[addFeatureHistogram] Invalid point index (%d) given!\n", index);
00071 return (false);
00072 }
00073
00074
00075 std::vector<pcl::PCLPointField> fields;
00076
00077 int field_idx = pcl::getFieldIndex<PointT> (cloud, field_name, fields);
00078 if (field_idx == -1)
00079 {
00080 PCL_ERROR ("[addFeatureHistogram] The specified field <%s> does not exist!\n", field_name.c_str ());
00081 return (false);
00082 }
00083
00084 int hsize = fields[field_idx].count;
00085 std::vector<double> array_x (hsize), array_y (hsize);
00086
00087 for (int i = 0; i < hsize; ++i)
00088 {
00089 array_x[i] = i;
00090 float data;
00091
00092 memcpy (&data, reinterpret_cast<const char*> (&cloud.points[index]) + fields[field_idx].offset + i * sizeof (float), sizeof (float));
00093 array_y[i] = data;
00094 }
00095
00096 this->addPlotData(array_x, array_y, id.c_str(), vtkChart::LINE);
00097 setWindowSize (win_width, win_height);
00098 return (true);
00099 }
00100
00101 #endif
00102