From 88c238b89781e988204ad39251d3dd9b014cd773 Mon Sep 17 00:00:00 2001
From: Thibault Payet <monwarez@gmail.com>
Date: Fri, 8 May 2020 20:52:09 +0200
Subject: [PATCH] use atoi and atof to convert extracted data to integer and
 float

---
 main.cpp | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/main.cpp b/main.cpp
index ccf9284..a322c47 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,3 +1,4 @@
+#include <cstdlib>
 #include <filesystem>
 #include <fstream>
 #include <ios>
@@ -51,15 +52,31 @@ void txt2pcd( std::filesystem::path input, std::filesystem::path output )
             {
                 pcl::PointXYZRGB point;
 
-                inputFile >> point.x;
-                inputFile >> point.y;
-                inputFile >> point.z;
+                std::string buf;
+
+                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;
 
-                inputFile >> r;
-                inputFile >> g;
-                inputFile >> b;
+                inputFile >> buf;
+                r = std::atoi( buf.c_str() );
+                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.g = static_cast<char>( g );
-- 
GitLab