@@ -188,22 +188,8 @@ class InsertionAlgorithm : public BaseAlgorithm
188188 Operations::CreateCenterProximity::Operation::get (itTip->getTypeInfo ());
189189 const BaseProximity::SPtr tipProx = createTipProximity (itTip->element ());
190190
191- ElementIterator::SPtr itShaft = l_shaftGeom->begin (l_shaftGeom->getSize () - 2 );
192- auto createShaftProximity =
193- Operations::CreateCenterProximity::Operation::get (itShaft->getTypeInfo ());
194- const BaseProximity::SPtr shaftProx = createShaftProximity (itShaft->element ());
195- const EdgeProximity::SPtr edgeProx = dynamic_pointer_cast<EdgeProximity>(shaftProx);
196- const type::Vec3 normal = (edgeProx->element ()->getP1 ()->getPosition () -
197- edgeProx->element ()->getP0 ()->getPosition ())
198- .normalized ();
199- const type::Vec3 ab = m_couplingPts.back ()->getPosition () - tipProx->getPosition ();
200- const SReal dotProd = dot (ab, normal);
201- if (dotProd > 0.0 ) {
202- m_couplingPts.pop_back ();
203- }
204-
205- const SReal dist = ab.norm ();
206- if (dist > d_tipDistThreshold.getValue ())
191+ const type::Vec3 tip2Pt = m_couplingPts.back ()->getPosition () - tipProx->getPosition ();
192+ if (tip2Pt.norm () > d_tipDistThreshold.getValue ())
207193 {
208194 auto findClosestProxOnVol =
209195 Operations::FindClosestProximity::Operation::get (l_volGeom);
@@ -216,6 +202,20 @@ class InsertionAlgorithm : public BaseAlgorithm
216202 m_couplingPts.push_back (volProx);
217203 }
218204 }
205+ else // Don't bother with removing the point that was just added
206+ {
207+ ElementIterator::SPtr itShaft = l_shaftGeom->begin (l_shaftGeom->getSize () - 2 );
208+ auto createShaftProximity =
209+ Operations::CreateCenterProximity::Operation::get (itShaft->getTypeInfo ());
210+ const BaseProximity::SPtr shaftProx = createShaftProximity (itShaft->element ());
211+ const EdgeProximity::SPtr edgeProx = dynamic_pointer_cast<EdgeProximity>(shaftProx);
212+ const type::Vec3 normal = (edgeProx->element ()->getP1 ()->getPosition () -
213+ edgeProx->element ()->getP0 ()->getPosition ())
214+ .normalized ();
215+ if (dot (tip2Pt, normal) > 0_sreal) {
216+ m_couplingPts.pop_back ();
217+ }
218+ }
219219
220220 auto findClosestProxOnShaft =
221221 Operations::FindClosestProximity::Operation::get (l_shaftGeom);
0 commit comments