@@ -29,7 +29,7 @@ class InsertionAlgorithm : public BaseAlgorithm
2929 Data<AlgorithmOutput> d_collisionOutput, d_insertionOutput;
3030 Data<bool > d_projective;
3131 Data<SReal> d_punctureForceThreshold, d_tipDistThreshold;
32- ConstraintSolver* m_constraintSolver;
32+ ConstraintSolver::SPtr m_constraintSolver;
3333 std::vector<BaseProximity::SPtr> m_needlePts, m_couplingPts;
3434 Data<bool > d_drawCollision, d_drawPoints;
3535 Data<SReal> d_drawPointsScale;
@@ -71,7 +71,7 @@ class InsertionAlgorithm : public BaseAlgorithm
7171 void init () override
7272 {
7373 BaseAlgorithm::init ();
74- m_constraintSolver = this ->getContext ()->get <ConstraintSolver>();
74+ this ->getContext ()->get <ConstraintSolver>(m_constraintSolver );
7575 }
7676
7777 void draw (const core::visual::VisualParams* vparams)
@@ -108,10 +108,11 @@ class InsertionAlgorithm : public BaseAlgorithm
108108
109109 if (insertionOutput.size () == 0 )
110110 {
111- const MechStateTipType* mstate = l_tipGeom->getContext ()->get <MechStateTipType>();
111+ const MechStateTipType::SPtr mstate = l_tipGeom->getContext ()->get <MechStateTipType>();
112112 if (m_constraintSolver)
113113 {
114- const auto lambda = m_constraintSolver->getLambda ()[mstate].read ()->getValue ();
114+ const auto lambda =
115+ m_constraintSolver->getLambda ()[mstate.get ()].read ()->getValue ();
115116 if (lambda[0 ].norm () > d_punctureForceThreshold.getValue ())
116117 {
117118 auto findClosestProxOnShaft =
@@ -121,7 +122,7 @@ class InsertionAlgorithm : public BaseAlgorithm
121122 {
122123 // Reproject onto the needle to create an EdgeProximity - the
123124 // EdgeNormalHandler in the Constraint classes will need this
124- BaseProximity::SPtr shaftProx = findClosestProxOnShaft (
125+ const BaseProximity::SPtr shaftProx = findClosestProxOnShaft (
125126 dpair.second , l_shaftGeom.get (), projectOnShaft, getFilterFunc ());
126127 m_needlePts.push_back (shaftProx);
127128 m_couplingPts.push_back (dpair.second ->copy ());
@@ -146,7 +147,7 @@ class InsertionAlgorithm : public BaseAlgorithm
146147 {
147148 BaseProximity::SPtr tipProx = createTipProximity (itTip->element ());
148149 if (!tipProx) continue ;
149- BaseProximity::SPtr surfProx = findClosestProxOnSurf (
150+ const BaseProximity::SPtr surfProx = findClosestProxOnSurf (
150151 tipProx, l_surfGeom.get (), projectOnSurf, getFilterFunc ());
151152 if (surfProx)
152153 {
@@ -173,12 +174,12 @@ class InsertionAlgorithm : public BaseAlgorithm
173174 ElementIterator::SPtr itTip = l_tipGeom->begin ();
174175 auto createTipProximity =
175176 Operations::CreateCenterProximity::Operation::get (itTip->getTypeInfo ());
176- BaseProximity::SPtr tipProx = createTipProximity (itTip->element ());
177+ const BaseProximity::SPtr tipProx = createTipProximity (itTip->element ());
177178
178179 ElementIterator::SPtr itShaft = l_shaftGeom->begin (l_shaftGeom->getSize () - 2 );
179180 auto createShaftProximity =
180181 Operations::CreateCenterProximity::Operation::get (itShaft->getTypeInfo ());
181- BaseProximity::SPtr shaftProx = createShaftProximity (itShaft->element ());
182+ const BaseProximity::SPtr shaftProx = createShaftProximity (itShaft->element ());
182183 const EdgeProximity::SPtr edgeProx = dynamic_pointer_cast<EdgeProximity>(shaftProx);
183184 const type::Vec3 normal = (edgeProx->element ()->getP1 ()->getPosition () -
184185 edgeProx->element ()->getP0 ()->getPosition ())
@@ -197,7 +198,7 @@ class InsertionAlgorithm : public BaseAlgorithm
197198 auto findClosestProxOnVol =
198199 Operations::FindClosestProximity::Operation::get (l_volGeom);
199200 auto projectOnVol = Operations::Project::Operation::get (l_volGeom);
200- BaseProximity::SPtr volProx =
201+ const BaseProximity::SPtr volProx =
201202 findClosestProxOnVol (tipProx, l_volGeom.get (), projectOnVol, getFilterFunc ());
202203 if (volProx)
203204 {
@@ -213,8 +214,8 @@ class InsertionAlgorithm : public BaseAlgorithm
213214
214215 for (int i = 0 ; i < m_couplingPts.size (); i++)
215216 {
216- BaseProximity::SPtr shaftProx = findClosestProxOnShaft (m_couplingPts[i], l_shaftGeom. get (),
217- projectOnShaft, getFilterFunc ());
217+ const BaseProximity::SPtr shaftProx = findClosestProxOnShaft (
218+ m_couplingPts[i], l_shaftGeom. get (), projectOnShaft, getFilterFunc ());
218219 m_needlePts[i] = shaftProx;
219220 }
220221
0 commit comments