40 #ifndef PCL_PCL_HISTOGRAM_VISUALIZER_IMPL_H_
41 #define PCL_PCL_HISTOGRAM_VISUALIZER_IMPL_H_
44 template <
typename Po
intT>
bool
47 const std::string &
id,
int win_width,
int win_height)
49 RenWinInteractMap::iterator am_it = wins_.find (
id);
50 if (am_it != wins_.end ())
52 PCL_WARN (
"[addFeatureHistogram] A window with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
56 vtkSmartPointer<vtkDoubleArray> xy_array = vtkSmartPointer<vtkDoubleArray>::New ();
57 xy_array->SetNumberOfComponents (2);
58 xy_array->SetNumberOfTuples (hsize);
62 for (
int d = 0; d < hsize; ++d)
65 xy[1] = cloud.
points[0].histogram[d];
66 xy_array->SetTuple (d, xy);
69 createActor (xy_array, renwinint,
id, win_width, win_height);
72 wins_[id] = renwinint;
73 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
80 template <
typename Po
intT>
bool
83 const std::string &field_name,
85 const std::string &
id,
int win_width,
int win_height)
87 if (index < 0 || index >= cloud.
points.size ())
89 PCL_ERROR (
"[addFeatureHistogram] Invalid point index (%d) given!\n", index);
94 std::vector<sensor_msgs::PointField> fields;
96 int field_idx = pcl::getFieldIndex<PointT> (cloud, field_name, fields);
99 PCL_ERROR (
"[addFeatureHistogram] The specified field <%s> does not exist!\n", field_name.c_str ());
103 RenWinInteractMap::iterator am_it = wins_.find (
id);
104 if (am_it != wins_.end ())
106 PCL_WARN (
"[addFeatureHistogram] A window with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
110 vtkSmartPointer<vtkDoubleArray> xy_array = vtkSmartPointer<vtkDoubleArray>::New ();
111 xy_array->SetNumberOfComponents (2);
112 xy_array->SetNumberOfTuples (fields[field_idx].count);
116 for (
int d = 0; d < fields[field_idx].count; ++d)
121 memcpy (&data, reinterpret_cast<const char*> (&cloud.points[index]) + fields[field_idx].offset + d * sizeof (
float),
sizeof (
float));
123 xy_array->SetTuple (d, xy);
126 createActor (xy_array, renwinint,
id, win_width, win_height);
129 wins_[id] = renwinint;
130 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
137 template <
typename Po
intT>
bool
140 const std::string &
id)
142 RenWinInteractMap::iterator am_it = wins_.find (
id);
143 if (am_it == wins_.end ())
145 PCL_WARN (
"[updateFeatureHistogram] A window with id <%s> does not exists!.\n",
id.c_str ());
150 vtkSmartPointer<vtkDoubleArray> xy_array = vtkSmartPointer<vtkDoubleArray>::New ();
151 xy_array->SetNumberOfComponents (2);
152 xy_array->SetNumberOfTuples (hsize);
156 for (
int d = 0; d < hsize; ++d)
159 xy[1] = cloud.
points[0].histogram[d];
160 xy_array->SetTuple (d, xy);
162 reCreateActor (xy_array, renwinupd, hsize);
167 template <
typename Po
intT>
bool
170 const std::string &
id)
172 if (index < 0 || index >= cloud.
points.size ())
174 PCL_ERROR (
"[updateFeatureHistogram] Invalid point index (%d) given!\n", index);
179 std::vector<sensor_msgs::PointField> fields;
181 int field_idx = pcl::getFieldIndex<PointT> (cloud, field_name, fields);
184 PCL_ERROR (
"[updateFeatureHistogram] The specified field <%s> does not exist!\n", field_name.c_str ());
188 RenWinInteractMap::iterator am_it = wins_.find (
id);
189 if (am_it == wins_.end ())
191 PCL_WARN (
"[updateFeatureHistogram] A window with id <%s> does not exists!.\n",
id.c_str ());
196 vtkSmartPointer<vtkDoubleArray> xy_array = vtkSmartPointer<vtkDoubleArray>::New ();
197 xy_array->SetNumberOfComponents (2);
198 xy_array->SetNumberOfTuples (fields[field_idx].count);
202 for (
int d = 0; d < fields[field_idx].count; ++d)
207 memcpy (&data, reinterpret_cast<const char*> (&cloud.points[index]) + fields[field_idx].offset + d * sizeof (
float),
sizeof (
float));
209 xy_array->SetTuple (d, xy);
212 reCreateActor (xy_array, renwinupd, cloud.fields[field_idx].count - 1);