From 6d217a3d1431d5c724e0b8bc4aed382a74f7d4ce Mon Sep 17 00:00:00 2001 From: Fedr Date: Fri, 21 Oct 2022 14:18:27 +0300 Subject: [PATCH] fromSceneObjFile: show errors if a face has less or more than 3 vertices --- source/MRMesh/MRMeshLoadObj.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/MRMesh/MRMeshLoadObj.cpp b/source/MRMesh/MRMeshLoadObj.cpp index dbe7f618d70e..564096f8b3aa 100644 --- a/source/MRMesh/MRMeshLoadObj.cpp +++ b/source/MRMesh/MRMeshLoadObj.cpp @@ -100,7 +100,15 @@ tl::expected, std::string> fromSceneObjFile( std::istream int a = readVert(); int b = readVert(); int c = readVert(); + if ( !in ) + return tl::make_unexpected( std::string( "Face with less than 3 vertices in OBJ-file" ) ); t.push_back( { VertId( a-1 ), VertId( b-1 ), VertId( c-1 ) } ); + + readVert(); + if ( !in.fail() ) + return tl::make_unexpected( std::string( "Face with more than 3 vertices in OBJ-file" ) ); + if ( !in.bad() && !in.eof() ) + in.clear(); } else if ( ch == 'o' ) {