@@ -128,6 +128,7 @@ class InsertionAlgorithm : public BaseAlgorithm
128128
129129 if (m_couplingPts.empty ())
130130 {
131+ sofa::helper::AdvancedTimer::stepBegin (" Puncture detection - " +this ->getName ());
131132 // 1. Puncture algorithm
132133 auto createTipProximity =
133134 Operations::CreateCenterProximity::Operation::get (l_tipGeom->getTypeInfo ());
@@ -177,8 +178,10 @@ class InsertionAlgorithm : public BaseAlgorithm
177178 collisionOutput.add (tipProx, surfProx);
178179 }
179180 }
181+ sofa::helper::AdvancedTimer::stepEnd (" Puncture detection - " +this ->getName ());
180182
181183 // 1.3 Collision with the shaft geometry
184+ sofa::helper::AdvancedTimer::stepBegin (" Shaft collision - " +this ->getName ());
182185 if (m_couplingPts.empty ())
183186 {
184187 auto createShaftProximity =
@@ -206,9 +209,11 @@ class InsertionAlgorithm : public BaseAlgorithm
206209 }
207210 }
208211 }
212+ sofa::helper::AdvancedTimer::stepEnd (" Shaft collision - " +this ->getName ());
209213 }
210214 else
211215 {
216+ sofa::helper::AdvancedTimer::stepBegin (" Needle insertion - " + this ->getName ());
212217 // 2. Needle insertion algorithm
213218 ElementIterator::SPtr itTip = l_tipGeom->begin ();
214219 auto createTipProximity =
@@ -298,8 +303,18 @@ class InsertionAlgorithm : public BaseAlgorithm
298303 }
299304 }
300305 }
306+ else // Don't bother with removing the point that was just added
307+ {
308+ // Remove coupling points that are ahead of the tip in the insertion direction
309+ ElementIterator::SPtr itShaft = l_shaftGeom->begin (l_shaftGeom->getSize () - 2 );
310+ auto prunePointsAheadOfTip =
311+ Operations::Needle::PrunePointsAheadOfTip::get (itShaft->getTypeInfo ());
312+ prunePointsAheadOfTip (m_couplingPts, itShaft->element ());
313+ }
314+ sofa::helper::AdvancedTimer::stepEnd (" Needle insertion - " + this ->getName ());
301315 }
302316
317+ sofa::helper::AdvancedTimer::stepBegin (" Reproject coupling points - " +this ->getName ());
303318 if (!m_couplingPts.empty ())
304319 {
305320 // 3. Re-project proximities on the shaft geometry
@@ -319,6 +334,7 @@ class InsertionAlgorithm : public BaseAlgorithm
319334 // because the needle has exited abruptly. Thus, we clear the coupling points.
320335 if (insertionOutput.size () == 0 ) m_couplingPts.clear ();
321336 }
337+ sofa::helper::AdvancedTimer::stepEnd (" Reproject coupling points - " +this ->getName ());
322338
323339 d_collisionOutput.endEdit ();
324340 d_insertionOutput.endEdit ();
0 commit comments