From 5498c575c824402dd0bb4366946d626ec205758e Mon Sep 17 00:00:00 2001 From: Xuchen Han Date: Thu, 9 Apr 2020 11:16:28 -0700 Subject: [PATCH] add guard agaist non-manifold geometry in vtk files --- .../PhysicsServerCommandProcessor.cpp | 15 +++++++++++++++ src/BulletSoftBody/btSoftBodyHelpers.cpp | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 30a318be5..e1807e354 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -8281,6 +8281,11 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo if (softWorld) { psb = btSoftBodyHelpers::CreateFromTriMesh(softWorld->getWorldInfo(), &vertices[0], &indices[0], numTris); + if (!psb) + { + printf("Load deformable failed\n"); + return false; + } } } { @@ -8288,6 +8293,11 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo if (deformWorld) { psb = btSoftBodyHelpers::CreateFromTriMesh(deformWorld->getWorldInfo(), &vertices[0], &indices[0], numTris); + if (!psb) + { + printf("Load deformable failed\n"); + return false; + } } } } @@ -8312,6 +8322,11 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo if (deformWorld) { psb = btSoftBodyHelpers::CreateFromVtkFile(deformWorld->getWorldInfo(), out_found_sim_filename.c_str()); + if (!psb) + { + printf("Load deformable failed\n"); + return false; + } btScalar corotated_mu(0.), corotated_lambda(0.); corotated_mu = deformable.m_corotatedCoefficients.mu; corotated_lambda = deformable.m_corotatedCoefficients.lambda; diff --git a/src/BulletSoftBody/btSoftBodyHelpers.cpp b/src/BulletSoftBody/btSoftBodyHelpers.cpp index adefad910..9645fbccd 100644 --- a/src/BulletSoftBody/btSoftBodyHelpers.cpp +++ b/src/BulletSoftBody/btSoftBodyHelpers.cpp @@ -1300,6 +1300,14 @@ btSoftBody* btSoftBodyHelpers::CreateFromVtkFile(btSoftBodyWorldInfo& worldInfo, } else if (reading_tets) { + int d; + ss >> d; + if (d != 4) + { + printf("Load deformable failed: Only Tetrahedra are supported in VTK file.\n"); + fs.close(); + return 0; + } ss.ignore(128, ' '); // ignore "4" Index tet; tet.resize(4);