@@ -256,7 +256,7 @@ class InsertionAlgorithm : public BaseAlgorithm
256256
257257 const int numCPs = floor (lastCPToP1.norm () / tipDistThreshold);
258258
259- for (int idCP = 0 ; idCP < numCPs ; idCP++)
259+ for (int idCP = 0 ; idCP < numCPs; idCP++)
260260 {
261261 // Candidate coupling point along shaft segment
262262 const type::Vec3 candidateCP = lastCP + tipDistThreshold * shaftEdgeDir;
@@ -270,7 +270,7 @@ class InsertionAlgorithm : public BaseAlgorithm
270270 // Skip if candidate CP is outside current edge segment
271271 if (projPtOnEdge < 0_sreal || projPtOnEdge > edgeSegmentLength) break ;
272272
273- // Project candidate CP onto shaft geometry ...
273+ // Project candidate CP onto shaft geometry ...
274274 shaftProx = projectOnShaft (candidateCP, itShaft->element ()).prox ;
275275 if (!shaftProx) continue ;
276276
@@ -279,8 +279,8 @@ class InsertionAlgorithm : public BaseAlgorithm
279279 shaftProx, l_volGeom.get (), projectOnVol, getFilterFunc ());
280280 if (!volProx) continue ;
281281
282- // Proximity can be detected before the tip enters the tetra (e.g. near a
283- // boundary face) Only accept proximities if the tip is inside the tetra
282+ // Proximity can be detected before the tip enters the tetra (e.g. near a
283+ // boundary face) Only accept proximities if the tip is inside the tetra
284284 // during insertion
285285 if (containsPointInVol (shaftProx->getPosition (), volProx))
286286 {
@@ -291,6 +291,14 @@ class InsertionAlgorithm : public BaseAlgorithm
291291 }
292292 }
293293 }
294+ else // Don't bother with removing the point that was just added
295+ {
296+ // Remove coupling points that are ahead of the tip in the insertion direction
297+ ElementIterator::SPtr itShaft = l_shaftGeom->begin (l_shaftGeom->getSize () - 2 );
298+ auto prunePointsAheadOfTip =
299+ Operations::Needle::PrunePointsAheadOfTip::get (itShaft->getTypeInfo ());
300+ prunePointsAheadOfTip (m_couplingPts, itShaft->element ());
301+ }
294302 }
295303
296304 if (!m_couplingPts.empty ())
0 commit comments