@@ -154,7 +154,8 @@ class InsertionAlgorithm : public BaseAlgorithm
154154 const auto & lambda =
155155 m_constraintSolver->getLambda ()[mstate.get ()].read ()->getValue ();
156156 SReal norm{0_sreal};
157- for (const auto & l : lambda) {
157+ for (const auto & l : lambda)
158+ {
158159 norm += l.norm ();
159160 }
160161 if (norm > punctureForceThreshold)
@@ -178,9 +179,9 @@ class InsertionAlgorithm : public BaseAlgorithm
178179 // 1.3 Collision with the shaft geometry
179180 if (collisionOutput.size ())
180181 {
181- auto createShaftProximity =
182- Operations::CreateCenterProximity::Operation::get (l_shaftGeom->getTypeInfo ());
183- auto projectOnShaft = Operations::Project::Operation::get (l_shaftGeom);
182+ auto createShaftProximity =
183+ Operations::CreateCenterProximity::Operation::get (l_shaftGeom->getTypeInfo ());
184+ auto projectOnShaft = Operations::Project::Operation::get (l_shaftGeom);
184185 for (auto itShaft = l_shaftGeom->begin (); itShaft != l_shaftGeom->end (); itShaft++)
185186 {
186187 BaseProximity::SPtr shaftProx = createShaftProximity (itShaft->element ());
@@ -190,11 +191,12 @@ class InsertionAlgorithm : public BaseAlgorithm
190191 if (surfProx)
191192 {
192193 surfProx->normalize ();
193-
194+
194195 // 1.2 If not, create a proximity pair for the tip-surface collision
195196 if (d_projective.getValue ())
196197 {
197- shaftProx = projectOnShaft (surfProx->getPosition (), itShaft->element ()).prox ;
198+ shaftProx =
199+ projectOnShaft (surfProx->getPosition (), itShaft->element ()).prox ;
198200 if (!shaftProx) continue ;
199201 shaftProx->normalize ();
200202 }
@@ -210,7 +212,7 @@ class InsertionAlgorithm : public BaseAlgorithm
210212 auto createTipProximity =
211213 Operations::CreateCenterProximity::Operation::get (itTip->getTypeInfo ());
212214 const BaseProximity::SPtr tipProx = createTipProximity (itTip->element ());
213- if (!tipProx) return ;
215+ if (!tipProx) return ;
214216
215217 // 2.1 Check whether coupling point should be added
216218 const type::Vec3 tip2Pt = m_couplingPts.back ()->getPosition () - tipProx->getPosition ();
@@ -227,23 +229,38 @@ class InsertionAlgorithm : public BaseAlgorithm
227229 m_couplingPts.push_back (volProx);
228230 }
229231 }
230- else // Don't bother with removing the point that was just added
232+ else // Don't bother with removing the point that was just added
231233 {
232- // 2.2. Check whether coupling point should be removed
234+ // 2.2. Check whether coupling point should be removed
233235 ElementIterator::SPtr itShaft = l_shaftGeom->begin (l_shaftGeom->getSize () - 2 );
234236 auto createShaftProximity =
235237 Operations::CreateCenterProximity::Operation::get (itShaft->getTypeInfo ());
236238 const BaseProximity::SPtr shaftProx = createShaftProximity (itShaft->element ());
237- const EdgeProximity::SPtr edgeProx = dynamic_pointer_cast<EdgeProximity>(shaftProx);
238- if (edgeProx)
239+ if (shaftProx)
239240 {
240- const type::Vec3 normal = (edgeProx->element ()->getP1 ()->getPosition () -
241- edgeProx->element ()->getP0 ()->getPosition ())
242- .normalized ();
243- if (dot (tip2Pt, normal) > 0_sreal) {
244- m_couplingPts.pop_back ();
241+ const EdgeProximity::SPtr edgeProx =
242+ dynamic_pointer_cast<EdgeProximity>(shaftProx);
243+ if (edgeProx)
244+ {
245+ const type::Vec3 normal = (edgeProx->element ()->getP1 ()->getPosition () -
246+ edgeProx->element ()->getP0 ()->getPosition ())
247+ .normalized ();
248+ if (dot (tip2Pt, normal) > 0_sreal)
249+ {
250+ m_couplingPts.pop_back ();
251+ }
252+ }
253+ else
254+ {
255+ msg_warning () << " shaftGeom: " << l_shaftGeom->getName ()
256+ << " is not an EdgeGeometry. Point removal is disabled" ;
245257 }
246258 }
259+ else
260+ {
261+ msg_warning () << " Cannot create proximity from shaftGeom: "
262+ << l_shaftGeom->getName () << " - point removal is disabled" ;
263+ }
247264 }
248265 }
249266
@@ -257,7 +274,8 @@ class InsertionAlgorithm : public BaseAlgorithm
257274 {
258275 const BaseProximity::SPtr shaftProx = findClosestProxOnShaft (
259276 m_couplingPts[i], l_shaftGeom.get (), projectOnShaft, getFilterFunc ());
260- if (shaftProx) {
277+ if (shaftProx)
278+ {
261279 shaftProx->normalize ();
262280 insertionOutput.add (shaftProx, m_couplingPts[i]);
263281 }
0 commit comments