File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff 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 (" \n Error: 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 (" \n Error empty cloud.\n " );
127+ std::exit (-1 );
128+ }
129+ };
130+
99131} // namespace CloudParserLibrary
100132#endif
Original file line number Diff line number Diff 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 (" ." );
You can’t perform that action at this time.
0 commit comments