MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / loadCloud

Function loadCloud

tools/xyz2pcd.cpp:53–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53bool
54loadCloud (const std::string &filename, PointCloud<PointXYZ> &cloud)
55{
56 std::ifstream fs;
57 fs.open (filename.c_str (), std::ios::binary);
58 if (!fs.is_open () || fs.fail ())
59 {
60 PCL_ERROR ("Could not open file '%s'! Error : %s\n", filename.c_str (), strerror (errno));
61 fs.close ();
62 return (false);
63 }
64
65 std::string line;
66 std::vector<std::string> st;
67
68 while (!fs.eof ())
69 {
70 std::getline (fs, line);
71 // Ignore empty lines
72 if (line.empty())
73 continue;
74
75 // Tokenize the line
76 boost::trim (line);
77 boost::split (st, line, boost::is_any_of ("\t\r "), boost::token_compress_on);
78
79 if (st.size () != 3)
80 continue;
81
82 cloud.push_back (PointXYZ (static_cast<float>(atof (st[0].c_str ())), static_cast<float>(atof (st[1].c_str ())), static_cast<float>(atof (st[2].c_str ()))));
83 }
84 fs.close ();
85
86 cloud.width = cloud.size (); cloud.height = 1; cloud.is_dense = true;
87 return (true);
88}
89
90/* ---[ */
91int

Callers 1

mainFunction · 0.70

Calls 7

splitFunction · 0.85
PointXYZClass · 0.50
openMethod · 0.45
closeMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected