From 2003f2a95e29fbf4cf9cbdc4a75c64f4b8c86dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 12 May 2009 14:58:21 +0000 Subject: [PATCH] OBJ Reader: catch invalid face handle when setting textures Dont add path to texture names/parameters string git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@125 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/IO/reader/OBJReader.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/OBJReader.cc b/src/OpenMesh/Core/IO/reader/OBJReader.cc index e9ae8aba..22e47f28 100644 --- a/src/OpenMesh/Core/IO/reader/OBJReader.cc +++ b/src/OpenMesh/Core/IO/reader/OBJReader.cc @@ -290,7 +290,10 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt) { std::string matFile; - stream >> matFile; + // Get the rest of the line, removing leading or trailing spaces + // This will define the filename of the texture + std::getline(stream,matFile); + trimString(matFile); matFile = path_ + matFile; @@ -311,11 +314,9 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt) for ( MaterialList::iterator material = materials_.begin(); material != materials_.end(); material++ ) { - - if ( (*material).second.has_map_Kd() ) { - std::string filename = path_ + (*material).second.map_Kd(); - _bi.add_texture_information( (*material).second.map_Kd_index() , filename ); - } + // Save the texture information in a property + if ( (*material).second.has_map_Kd() ) + _bi.add_texture_information( (*material).second.map_Kd_index() , (*material).second.map_Kd() ); } } @@ -488,7 +489,7 @@ read(std::fstream& _in, BaseImporter& _bi, Options& _opt) size_t n_faces = _bi.n_faces(); FaceHandle fh = _bi.add_face(vhandles); - if( !vhandles.empty() ) + if( !vhandles.empty() && fh.is_valid() ) _bi.add_face_texcoords( fh, vhandles[0], face_texcoords ); if ( !matname.empty() )