diff --git a/Sofa/framework/Core/src/sofa/core/visual/DrawMesh.h b/Sofa/framework/Core/src/sofa/core/visual/DrawMesh.h index d08445b1fb4..36cd5aa9f8d 100644 --- a/Sofa/framework/Core/src/sofa/core/visual/DrawMesh.h +++ b/Sofa/framework/Core/src/sofa/core/visual/DrawMesh.h @@ -328,6 +328,17 @@ struct SOFA_CORE_API DrawElementMesh const auto& elements = topology->getTetrahedra(); const auto& facets = topology->getTriangles(); + if(facets.empty()) + { + static bool firstTime = true; + if (firstTime) + { + msg_error("DrawElementMesh") << "Drawing tetrahedra needs the associated triangles in the topology."; + firstTime = false; + } + return; + } + for ( auto& p : renderedPoints) { p.resize(elementIndices.size() * sofa::geometry::Triangle::NumberOfNodes); @@ -474,6 +485,17 @@ struct SOFA_CORE_API DrawElementMesh const auto& elements = topology->getHexahedra(); const auto& facets = topology->getQuads(); + if(facets.empty()) + { + static bool firstTime = true; + if (firstTime) + { + msg_error("DrawElementMesh") << "Drawing hexahedra needs the associated quads in the topology."; + firstTime = false; + } + return; + } + for ( auto& p : renderedPoints) { p.resize(elementIndices.size() * sofa::geometry::Quad::NumberOfNodes);