From 2bc737b798b64213a5bff7a1d8cdfbe776a342ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 11 May 2009 12:00:25 +0000 Subject: [PATCH] Improved reader for textureMaps. Now ignoring empty testure definitions. git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@124 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/IO/reader/OBJReader.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/OBJReader.cc b/src/OpenMesh/Core/IO/reader/OBJReader.cc index 746bd0ca..e9ae8aba 100644 --- a/src/OpenMesh/Core/IO/reader/OBJReader.cc +++ b/src/OpenMesh/Core/IO/reader/OBJReader.cc @@ -69,8 +69,8 @@ _OBJReader_& OBJReader() { return __OBJReaderInstance; } void trimString( std::string& _string) { // Trim Both leading and trailing spaces - size_t start = _string.find_first_not_of(" \t"); - size_t end = _string.find_last_not_of(" \t"); + size_t start = _string.find_first_not_of(" \t\r\n"); + size_t end = _string.find_last_not_of(" \t\r\n"); if(( std::string::npos == start ) || ( std::string::npos == end)) _string = ""; @@ -215,10 +215,12 @@ read_material(std::fstream& _in) } #endif else if (keyWrd == "map_Kd" ) { - // Get the rest of the line, removeing leading or trailing spaces + // Get the rest of the line, removing leading or trailing spaces + // This will define the filename of the texture std::getline(stream,textureName); trimString(textureName); - mat.set_map_Kd( textureName, textureId++ ); + if ( ! textureName.empty() ) + mat.set_map_Kd( textureName, textureId++ ); } else if (keyWrd == "Tr") // transparency value { @@ -316,7 +318,6 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt) } } -// mat.has_map_Kd(); } // usemtl