Commit 6d24c351 authored by Mike Kremer's avatar Mike Kremer

Prevent crash when trying to add non-manifold vertex configurations.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12747 383ad7c9-94d9-4d36-a494-682f7c89f535
parent aa445865
......@@ -401,6 +401,11 @@ void OBJImporter::addFace(const VHandles& _indices){
}
}
if(!vertexListIsManifold(vertices)) {
std::cerr << "Face consists of multiple occurrences of the same vertex!" << std::endl;
return;
}
OpenMesh::FaceHandle fh = currentPolyMesh()->add_face( vertices );
if(!fh.is_valid()) {
......@@ -414,6 +419,19 @@ void OBJImporter::addFace(const VHandles& _indices){
//-----------------------------------------------------------------------------
bool OBJImporter::vertexListIsManifold(const std::vector<PolyMesh::VertexHandle>& _vertices) const {
std::set<PolyMesh::VertexHandle> check;
for(std::vector<PolyMesh::VertexHandle>::const_iterator v_it = _vertices.begin();
v_it != _vertices.end(); ++v_it) {
check.insert(*v_it);
}
return (check.size() == _vertices.size());
}
//-----------------------------------------------------------------------------
/// add face and texture coordinates
void OBJImporter::addFace(const VHandles& _indices, const std::vector<int>& _face_texcoords){
......
......@@ -238,6 +238,8 @@ class OBJImporter
private:
bool vertexListIsManifold(const std::vector<PolyMesh::VertexHandle>& _vertices) const;
// general data
std::vector< Vec3f > vertices_;
std::vector< Vec3f > normals_;
......
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