42 #include <pcl/ml/kmeans.h>
50 template <
typename Po
intT>
54 template <
typename Po
intT>
58 template <
typename Po
intT>
63 template <
typename Po
intT>
67 if (!initCompute() || (input_ != 0 && input_->points.empty()) ||
68 (indices_ != 0 && indices_->empty())) {
74 std::vector<pcl::PCLPointField> fields;
77 if (strcmp(cluster_field_name_.c_str(),
"") == 0) {
81 x_index = pcl::getFieldIndex<PointT>(
"x", fields);
83 y_index = pcl::getFieldIndex<PointT>(
"y", fields);
85 z_index = pcl::getFieldIndex<PointT>(
"z", fields);
87 if (x_index == -1 && y_index == -1 && z_index == -1) {
88 PCL_ERROR(
"Failed to find match for field 'x y z'\n");
92 PCL_INFO(
"Use X Y Z as input data\n");
105 std::cout <<
"x index: " << x_index << std::endl;
108 memcpy(&x, &input_->points[0] + fields[x_index].offset,
sizeof(
float));
110 std::cout <<
"xxx: " << x << std::endl;
123 int user_index = pcl::getFieldIndex<PointT>(cluster_field_name_.c_str(), fields);
125 if (user_index == -1) {
126 PCL_ERROR(
"Failed to find match for field '%s'\n", cluster_field_name_.c_str());
166 #define PCL_INSTANTIATE_Kmeans(T) template class PCL_EXPORTS pcl::Kmeans<T>;