Skip to content

Commit c3a179b

Browse files
committed
[algorithm] Fix crash in case coupling points are all removed and vector is emptied
1 parent 4e64e68 commit c3a179b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,13 @@ class InsertionAlgorithm : public BaseAlgorithm
216216
const BaseProximity::SPtr tipProx = createTipProximity(itTip->element());
217217
if (!tipProx) return;
218218

219-
// Remove coupling points that are ahead of the tip in the insertion direction
220-
ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2);
221-
auto prunePointsAheadOfTip =
222-
Operations::Needle::PrunePointsAheadOfTip::get(itShaft->getTypeInfo());
223-
prunePointsAheadOfTip(m_couplingPts, itShaft->element());
219+
// Remove coupling points that are ahead of the tip in the insertion direction
220+
ElementIterator::SPtr itShaft = l_shaftGeom->begin(l_shaftGeom->getSize() - 2);
221+
auto prunePointsAheadOfTip =
222+
Operations::Needle::PrunePointsAheadOfTip::get(itShaft->getTypeInfo());
223+
prunePointsAheadOfTip(m_couplingPts, itShaft->element());
224+
225+
if (m_couplingPts.empty()) return;
224226

225227
// 2.1 Check whether coupling point should be added
226228
const type::Vec3 tip2Pt = m_couplingPts.back()->getPosition() - tipProx->getPosition();
@@ -252,9 +254,6 @@ class InsertionAlgorithm : public BaseAlgorithm
252254
}
253255
}
254256
}
255-
else // Don't bother with removing the point that was just added
256-
{
257-
}
258257
}
259258

260259
if (!m_couplingPts.empty())

0 commit comments

Comments
 (0)