39 #ifndef PCL_PCL_HISTOGRAM_VISUALIZER_IMPL_H_
40 #define PCL_PCL_HISTOGRAM_VISUALIZER_IMPL_H_
42 #include <vtkDoubleArray.h>
45 template <
typename Po
intT>
bool
48 const std::string &
id,
int win_width,
int win_height)
50 RenWinInteractMap::iterator am_it = wins_.find (
id);
51 if (am_it != wins_.end ())
53 PCL_WARN (
"[addFeatureHistogram] A window with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
58 xy_array->SetNumberOfComponents (2);
59 xy_array->SetNumberOfTuples (hsize);
63 for (
int d = 0; d < hsize; ++d)
66 xy[1] = cloud.
points[0].histogram[d];
67 xy_array->SetTuple (d, xy);
70 createActor (xy_array, renwinint,
id, win_width, win_height);
73 wins_[id] = renwinint;
74 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
81 template <
typename Po
intT>
bool
84 const std::string &field_name,
86 const std::string &
id,
int win_width,
int win_height)
88 if (index < 0 || index >= cloud.
points.size ())
90 PCL_ERROR (
"[addFeatureHistogram] Invalid point index (%d) given!\n", index);
95 std::vector<pcl::PCLPointField> fields;
97 int field_idx = pcl::getFieldIndex<PointT> (cloud, field_name, fields);
100 PCL_ERROR (
"[addFeatureHistogram] The specified field <%s> does not exist!\n", field_name.c_str ());
104 RenWinInteractMap::iterator am_it = wins_.find (
id);
105 if (am_it != wins_.end ())
107 PCL_WARN (
"[addFeatureHistogram] A window with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
112 xy_array->SetNumberOfComponents (2);
113 xy_array->SetNumberOfTuples (fields[field_idx].count);
117 for (uint32_t d = 0; d < fields[field_idx].count; ++d)
122 memcpy (&data, reinterpret_cast<const char*> (&cloud.points[index]) + fields[field_idx].offset + d * sizeof (
float),
sizeof (
float));
124 xy_array->SetTuple (d, xy);
127 createActor (xy_array, renwinint,
id, win_width, win_height);
130 wins_[id] = renwinint;
131 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
138 template <
typename Po
intT>
bool
141 const std::string &
id)
143 RenWinInteractMap::iterator am_it = wins_.find (
id);
144 if (am_it == wins_.end ())
146 PCL_WARN (
"[updateFeatureHistogram] A window with id <%s> does not exists!.\n",
id.c_str ());
152 xy_array->SetNumberOfComponents (2);
153 xy_array->SetNumberOfTuples (hsize);
157 for (
int d = 0; d < hsize; ++d)
160 xy[1] = cloud.
points[0].histogram[d];
161 xy_array->SetTuple (d, xy);
163 reCreateActor (xy_array, renwinupd, hsize);
168 template <
typename Po
intT>
bool
171 const std::string &
id)
173 if (index < 0 || index >= cloud.
points.size ())
175 PCL_ERROR (
"[updateFeatureHistogram] Invalid point index (%d) given!\n", index);
180 std::vector<pcl::PCLPointField> fields;
182 int field_idx = pcl::getFieldIndex<PointT> (cloud, field_name, fields);
185 PCL_ERROR (
"[updateFeatureHistogram] The specified field <%s> does not exist!\n", field_name.c_str ());
189 RenWinInteractMap::iterator am_it = wins_.find (
id);
190 if (am_it == wins_.end ())
192 PCL_WARN (
"[updateFeatureHistogram] A window with id <%s> does not exists!.\n",
id.c_str ());
198 xy_array->SetNumberOfComponents (2);
199 xy_array->SetNumberOfTuples (fields[field_idx].count);
203 for (uint32_t d = 0; d < fields[field_idx].count; ++d)
208 memcpy (&data, reinterpret_cast<const char*> (&cloud.points[index]) + fields[field_idx].offset + d * sizeof (
float),
sizeof (
float));
210 xy_array->SetTuple (d, xy);
213 reCreateActor (xy_array, renwinupd, cloud.fields[field_idx].count - 1);
bool updateFeatureHistogram(const pcl::PointCloud< PointT > &cloud, int hsize, const std::string &id="cloud")
Update a histogram feature that is already on screen, with a cloud containing a single histogram...
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void createActor(const vtkSmartPointer< vtkDoubleArray > &xy_array, RenWinInteract &renwinint, const std::string &id, const int win_width, const int win_height)
Create a 2D actor from the given vtkDoubleArray histogram and add it to the screen.
bool addFeatureHistogram(const pcl::PointCloud< PointT > &cloud, int hsize, const std::string &id="cloud", int win_width=640, int win_height=200)
Add a histogram feature to screen as a separate window, from a cloud containing a single histogram...