pcl::PointCloud<pcl::PointXYZRGBA>::Ptr txtRead(std::string file_name)
{
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr data(new pcl::PointCloud< pcl::PointXYZRGBA>);
pcl::PointXYZRGBA f_xyz;
QString str = QString::fromStdString(file_name);
QFile file(str);
if (!file.open(QFile::ReadOnly | QIODevice::Text))
return 0;
uchar* fpr = file.map(0, file.size());
char *s = strdup((char*)fpr);
char *substr;
char *token = NULL;
char *next = NULL;
float point[3];
while (substr = strtok_s(s,"\n", &next))
{
s = next;
for (int i = 0; i < 3; i++)
{
char *lineSubStr = strtok_s(substr, " ", &token);
substr = token;
point[i] = atof(lineSubStr);
}
f_xyz.x = point[0];
f_xyz.y = point[1];
f_xyz.z = point[2];
data->points.push_back(f_xyz);
}
file.close();
data->height = data->points.size();
data->width = 1;
return data;
}