From 93f7d0322f012be5cdd5d70b228e4c3e17607bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 17 Apr 2009 12:35:44 +0000 Subject: [PATCH] Handle whitespace in obj files git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@95 fdac6126-5c0c-442c-9429-916003d36597 --- Core/IO/reader/OBJReader.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Core/IO/reader/OBJReader.cc b/Core/IO/reader/OBJReader.cc index d33d6fda..955869b3 100644 --- a/Core/IO/reader/OBJReader.cc +++ b/Core/IO/reader/OBJReader.cc @@ -253,6 +253,16 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt) return false; } + // Trim Both leading and trailing spaces + + size_t start = line.find_first_not_of(" \t"); + size_t end = line.find_last_not_of(" \t"); + + if(( std::string::npos == start ) || ( std::string::npos == end)) + line = ""; + else + line = line.substr( start, end-start+1 ); + // comment if ( line.size() == 0 || line[0] == '#' || isspace(line[0]) ) { continue;