From deaea6a3861167c15134598be17b3a2e101f69e5 Mon Sep 17 00:00:00 2001 From: Themis Skamagkis Date: Fri, 1 Aug 2025 16:47:16 +0200 Subject: [PATCH 1/2] [algorithm] Removed the needlePts variable - not needed --- .../algorithm/InsertionAlgorithm.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h b/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h index 0f83554d..82978f37 100644 --- a/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h +++ b/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h @@ -30,7 +30,7 @@ class InsertionAlgorithm : public BaseAlgorithm Data d_projective; Data d_punctureForceThreshold, d_tipDistThreshold; ConstraintSolver::SPtr m_constraintSolver; - std::vector m_needlePts, m_couplingPts; + std::vector m_couplingPts; Data d_drawCollision, d_drawPoints; Data d_drawPointsScale; @@ -57,7 +57,6 @@ class InsertionAlgorithm : public BaseAlgorithm "the last proximity detection. Once exceeded, a new " "proximity pair is added for the needle-volume coupling.")), m_constraintSolver(nullptr), - m_needlePts(), m_couplingPts(), d_drawCollision(initData(&d_drawCollision, false, "drawcollision", "Draw collision.")), d_drawPoints(initData(&d_drawPoints, false, "drawPoints", "Draw detection outputs.")), @@ -146,7 +145,6 @@ class InsertionAlgorithm : public BaseAlgorithm // EdgeNormalHandler in the Constraint classes will need this const BaseProximity::SPtr shaftProx = findClosestProxOnShaft( dpair.second, l_shaftGeom.get(), projectOnShaft, getFilterFunc()); - m_needlePts.push_back(shaftProx); m_couplingPts.push_back(dpair.second); insertionOutput.add(shaftProx, dpair.second); } @@ -185,7 +183,6 @@ class InsertionAlgorithm : public BaseAlgorithm } else { - ElementIterator::SPtr itTip = l_tipGeom->begin(); auto createTipProximity = Operations::CreateCenterProximity::Operation::get(itTip->getTypeInfo()); @@ -201,11 +198,7 @@ class InsertionAlgorithm : public BaseAlgorithm .normalized(); const type::Vec3 ab = m_couplingPts.back()->getPosition() - tipProx->getPosition(); const SReal dotProd = dot(ab, normal); - if (dotProd > 0.0) - { - m_couplingPts.pop_back(); - m_needlePts.pop_back(); - } + if (dotProd > 0.0) m_couplingPts.pop_back(); const SReal dist = ab.norm(); if (dist > d_tipDistThreshold.getValue()) @@ -219,23 +212,18 @@ class InsertionAlgorithm : public BaseAlgorithm { volProx->normalize(); m_couplingPts.push_back(volProx); - m_needlePts.push_back(m_needlePts.back()); } } auto findClosestProxOnShaft = Operations::FindClosestProximity::Operation::get(l_shaftGeom); auto projectOnShaft = Operations::Project::Operation::get(l_shaftGeom); - for (int i = 0; i < m_couplingPts.size(); i++) { const BaseProximity::SPtr shaftProx = findClosestProxOnShaft( m_couplingPts[i], l_shaftGeom.get(), projectOnShaft, getFilterFunc()); - m_needlePts[i] = shaftProx; + insertionOutput.add(shaftProx, m_couplingPts[i]); } - - for (int i = 0; i < m_couplingPts.size(); i++) - insertionOutput.add(m_needlePts[i], m_couplingPts[i]); } d_collisionOutput.endEdit(); From 72a5ff61d36ccfba5bef2a548700755d563fd96b Mon Sep 17 00:00:00 2001 From: Themis Skamagkis <70031729+th-skam@users.noreply.github.com> Date: Thu, 7 Aug 2025 16:58:06 +0200 Subject: [PATCH 2/2] apply changes Co-authored-by: erik pernod --- src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h b/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h index 82978f37..29ddcdd4 100644 --- a/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h +++ b/src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h @@ -198,7 +198,9 @@ class InsertionAlgorithm : public BaseAlgorithm .normalized(); const type::Vec3 ab = m_couplingPts.back()->getPosition() - tipProx->getPosition(); const SReal dotProd = dot(ab, normal); - if (dotProd > 0.0) m_couplingPts.pop_back(); + if (dotProd > 0.0) { + m_couplingPts.pop_back(); + } const SReal dist = ab.norm(); if (dist > d_tipDistThreshold.getValue())