| 51 | } |
| 52 | |
| 53 | bool |
| 54 | loadCloud (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 | /* ---[ */ |
| 91 | int |