23 #pragma warning(disable : 4267) // for VS-2015
26 #include <pcl/io/ascii_io.h>
27 #include <pcl/io/pcd_io.h>
28 #include <pcl/io/ply_io.h>
30 #include <pcl/pcl_config.h>
51 std::ifstream in(filename);
54 throw std::invalid_argument(
"read_mesh() error: can not open file " +
59 std::string line, word;
65 std::getline(in, line);
66 std::istringstream line_ss(line);
70 if(word ==
"property")
79 else if(word ==
"red")
85 while(word !=
"end_header");
96 std::ifstream in(filename);
99 throw std::invalid_argument(
"read_mesh() error: can not open file " +
104 std::string line, word;
110 std::getline(in, line);
111 std::istringstream line_ss(line);
117 while(line_ss >> word)
119 if(word ==
"normal_x")
142 std::ifstream in(filename);
145 throw std::invalid_argument(
"read_mesh() error: can not open file " +
149 std::string line, word;
153 std::getline(in, line);
154 std::istringstream line_ss(line);
157 unsigned int val_nbr = 0;
158 while(line_ss >> word)
168 else if(val_nbr == 6)
172 throw std::invalid_argument(
"read_mesh() error: unsupported XYZ format in file " +
197 const std::string &filename,
203 bool success =
false;
204 bool has_normal =
false;
205 bool has_color =
false;
213 pcl::ASCIIReader reader;
214 reader.setExtension(
".xyz");
242 std::vector<pcl::PCLPointField> fields;
243 #if PCL_VERSION_COMPARE(<, 1, 10, 0)
244 pcl::getFields< pcl::PointNormal >(fields);
246 fields = pcl::getFields< pcl::PointNormal >();
250 reader.setInputFields(fields);
253 reader.setInputFields< pcl::PointXYZ >();
256 success = (reader.read(filename, g) >= 0);
264 success = (pcl::io::loadPCDFile(filename, g) >= 0);
272 success = (pcl::io::loadPLYFile(filename, g) >= 0);
292 throw std::invalid_argument(
"read_mesh() error: can not read file " +