Skip to content
Snippets Groups Projects
Verified Commit 88c238b8 authored by Thibault Payet's avatar Thibault Payet
Browse files

use atoi and atof to convert extracted data to integer and float

parent ae3e4393
No related branches found
No related tags found
1 merge request!2use atoi and atof to convert extracted data to integer and float
#include <cstdlib>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <ios> #include <ios>
...@@ -51,15 +52,31 @@ void txt2pcd( std::filesystem::path input, std::filesystem::path output ) ...@@ -51,15 +52,31 @@ void txt2pcd( std::filesystem::path input, std::filesystem::path output )
{ {
pcl::PointXYZRGB point; pcl::PointXYZRGB point;
inputFile >> point.x; std::string buf;
inputFile >> point.y;
inputFile >> point.z; inputFile >> buf;
point.x = std::atof( buf.c_str() );
buf.clear();
inputFile >> buf;
point.y = std::atof( buf.c_str() );
buf.clear();
inputFile >> buf;
point.z = std::atof( buf.c_str() );
buf.clear();
int r, g, b; int r, g, b;
inputFile >> r; inputFile >> buf;
inputFile >> g; r = std::atoi( buf.c_str() );
inputFile >> b; buf.clear();
inputFile >> buf;
g = std::atoi( buf.c_str() );
buf.clear();
inputFile >> buf;
b = std::atoi( buf.c_str() );
buf.clear();
point.r = static_cast<char>( r ); point.r = static_cast<char>( r );
point.g = static_cast<char>( g ); point.g = static_cast<char>( g );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment