Commit 4d1a626a authored by Matthias Möller's avatar Matthias Möller
Browse files

fix crash when file contains degenerated faces

refs #2382

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20291 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d380020f
......@@ -70,6 +70,32 @@
#define TYPEPOLY 2
#define TYPETRIANGLE 3
//-----------------------------------------------------------------------------
// help functions
namespace{
template<typename T>
class HasSeen : public std::unary_function <T, bool>
{
public:
HasSeen () : seen_ () { }
bool operator ()(const T& i) const
{
return (!seen_.insert(i).second);
}
private:
mutable std::set<T> seen_;
};
}
void remove_duplicated_vertices(VHandles& _indices)
{
_indices.erase(std::remove_if(_indices.begin(),_indices.end(),HasSeen<int>()),_indices.end());
}
//-----------------------------------------------------------------------------
/// Constructor
FileOBJPlugin::FileOBJPlugin()
: loadOptions_(0),
......@@ -917,8 +943,11 @@ void FileOBJPlugin::readOBJFile(QString _filename, OBJImporter& _importer)
nV++;
}
// remove vertices which can lead to degenerated faces
remove_duplicated_vertices(vhandles);
if( !vhandles.empty() ){
// from spec: A minimum of three vertices are required.
if( vhandles.size() > 2 ){
if ( !face_texcoords.empty() )
//if we have texCoords add face+texCoords
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment