From 02bd5b1cb4b19a6659dd5f2b69e43711ff590097 Mon Sep 17 00:00:00 2001 From: epernod Date: Thu, 28 May 2026 11:56:25 +0200 Subject: [PATCH 1/2] [src] Add option to get the tip dof id of a beam/wire --- src/BeamAdapter/component/BaseBeamInterpolation.h | 3 +++ src/BeamAdapter/component/BaseBeamInterpolation.inl | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/BeamAdapter/component/BaseBeamInterpolation.h b/src/BeamAdapter/component/BaseBeamInterpolation.h index 4d91ae1a1..a76f85b03 100644 --- a/src/BeamAdapter/component/BaseBeamInterpolation.h +++ b/src/BeamAdapter/component/BaseBeamInterpolation.h @@ -231,6 +231,9 @@ class BaseBeamInterpolation : public sofa::core::behavior::SingleStateAccessor > d_beamCollision; Data d_dofsAndBeamsAligned; + + /// index of the beam extremity that is considered as the tip of the wire + Data d_wireTipIndex; /// link to the (edge) topology SingleLink, BaseMeshTopology, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK> l_topology; diff --git a/src/BeamAdapter/component/BaseBeamInterpolation.inl b/src/BeamAdapter/component/BaseBeamInterpolation.inl index d87ae05d8..d2264b3bd 100644 --- a/src/BeamAdapter/component/BaseBeamInterpolation.inl +++ b/src/BeamAdapter/component/BaseBeamInterpolation.inl @@ -107,6 +107,7 @@ BaseBeamInterpolation::BaseBeamInterpolation() , d_beamCollision(initData(&d_beamCollision, "beamCollision", "list of beam (in edgeList) that needs to be considered for collision")) , d_dofsAndBeamsAligned(initData(&d_dofsAndBeamsAligned, true, "dofsAndBeamsAligned", "if false, a transformation for each beam is computed between the DOF and the beam nodes")) + , d_wireTipIndex(initData(&d_wireTipIndex, (sofa::Index)0, "wireTipIndex", "index of the beam extremity that is considered as the tip of the wire")) , l_topology(initLink("topology", "link to the topology (must contain edges)")) { @@ -186,6 +187,9 @@ void BaseBeamInterpolation::addBeam(const EdgeID eID, const Real leng d_dofsAndBeamsAligned.setValue(false); DOF0TransformNode0.push_back(Transform(Vec3(0, 0, 0), QuatX)); DOF1TransformNode1.push_back(Transform(Vec3(0, 0, 0), QuatX)); + + const BaseMeshTopology::Edge& edge = l_topology->getEdge(eID); + d_wireTipIndex.setValue(edge[1]); } @@ -392,6 +396,7 @@ void BaseBeamInterpolation::getTangent(Vec3& t, const Real baryCoord, } +// TODO check why this method is called in continue template int BaseBeamInterpolation::getNodeIndices(const EdgeID edgeInList, unsigned int& node0Idx, From b3ddf3238c0d86fd4bb328a556e645c7b6e5ded7 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Mon, 28 Sep 2026 22:00:06 +0200 Subject: [PATCH 2/2] Add null check for l_topology in BaseBeamInterpolation Add null check for l_topology before accessing edge. --- src/BeamAdapter/component/BaseBeamInterpolation.inl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BeamAdapter/component/BaseBeamInterpolation.inl b/src/BeamAdapter/component/BaseBeamInterpolation.inl index d2264b3bd..2951a8518 100644 --- a/src/BeamAdapter/component/BaseBeamInterpolation.inl +++ b/src/BeamAdapter/component/BaseBeamInterpolation.inl @@ -188,8 +188,11 @@ void BaseBeamInterpolation::addBeam(const EdgeID eID, const Real leng DOF0TransformNode0.push_back(Transform(Vec3(0, 0, 0), QuatX)); DOF1TransformNode1.push_back(Transform(Vec3(0, 0, 0), QuatX)); - const BaseMeshTopology::Edge& edge = l_topology->getEdge(eID); - d_wireTipIndex.setValue(edge[1]); + if (l_topology) + { + const BaseMeshTopology::Edge& edge = l_topology->getEdge(eID); + d_wireTipIndex.setValue(edge[1]); + } }