Skip to content

Commit 96184f0

Browse files
author
Daniel Tobon
committed
added support for XYZ files
1 parent 21aba0b commit 96184f0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

parser/include/modern/concrete_parses.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,37 @@ class ParserTXT : public InterfaceParser {
9696
std::exit(-1);
9797
}
9898
};
99+
100+
class ParserXYZ : public InterfaceParser {
101+
public:
102+
std::string parser_name = "ParserXYZ";
103+
void load_cloudfile(std::string filename, pcl::PointCloud<pcl::PointXYZRGB>::Ptr& cloud) {
104+
std::ifstream file(filename, std::ifstream::in);
105+
if (!file.is_open()) {
106+
pcl::console::print_error("\nError: Could not find %s\n", filename);
107+
std::exit(-1);
108+
}
109+
110+
double x_, y_, z_;
111+
112+
while (file >> x_ >> y_ >> z_) {
113+
pcl::PointXYZRGB pt;
114+
pt.x = x_;
115+
pt.y = y_;
116+
pt.z = z_;
117+
118+
cloud->points.push_back(pt);
119+
}
120+
121+
file.close();
122+
if (cloud_is_good(cloud)) {
123+
return;
124+
}
125+
126+
pcl::console::print_error("\nError empty cloud.\n");
127+
std::exit(-1);
128+
}
129+
};
130+
99131
} // namespace CloudParserLibrary
100132
#endif

parser/include/modern/parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ParserCloudFile {
3636
parser_factory.register_format("PCD", new ParserPCD());
3737
parser_factory.register_format("PLY", new ParserPLY());
3838
parser_factory.register_format("TXT", new ParserTXT());
39+
parser_factory.register_format("XYZ", new ParserXYZ());
3940
}
4041
void load_cloudfile(std::string filename, pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud) {
4142
int position = filename.find_last_of(".");

0 commit comments

Comments
 (0)