Skip to content

Commit c186962

Browse files
th-skamepernod
andauthored
[algorithm] Refactor: Remove needlePts variable (#51)
* [algorithm] Removed the needlePts variable - not needed * apply changes Co-authored-by: erik pernod <erik.pernod@gmail.com> --------- Co-authored-by: erik pernod <erik.pernod@gmail.com>
1 parent 5c8f27f commit c186962

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

src/sofa/collisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class InsertionAlgorithm : public BaseAlgorithm
3030
Data<bool> d_projective;
3131
Data<SReal> d_punctureForceThreshold, d_tipDistThreshold;
3232
ConstraintSolver::SPtr m_constraintSolver;
33-
std::vector<BaseProximity::SPtr> m_needlePts, m_couplingPts;
33+
std::vector<BaseProximity::SPtr> m_couplingPts;
3434
Data<bool> d_drawCollision, d_drawPoints;
3535
Data<SReal> d_drawPointsScale;
3636

@@ -57,7 +57,6 @@ class InsertionAlgorithm : public BaseAlgorithm
5757
"the last proximity detection. Once exceeded, a new "
5858
"proximity pair is added for the needle-volume coupling.")),
5959
m_constraintSolver(nullptr),
60-
m_needlePts(),
6160
m_couplingPts(),
6261
d_drawCollision(initData(&d_drawCollision, false, "drawcollision", "Draw collision.")),
6362
d_drawPoints(initData(&d_drawPoints, false, "drawPoints", "Draw detection outputs.")),
@@ -146,7 +145,6 @@ class InsertionAlgorithm : public BaseAlgorithm
146145
// EdgeNormalHandler in the Constraint classes will need this
147146
const BaseProximity::SPtr shaftProx = findClosestProxOnShaft(
148147
dpair.second, l_shaftGeom.get(), projectOnShaft, getFilterFunc());
149-
m_needlePts.push_back(shaftProx);
150148
m_couplingPts.push_back(dpair.second);
151149
insertionOutput.add(shaftProx, dpair.second);
152150
}
@@ -185,7 +183,6 @@ class InsertionAlgorithm : public BaseAlgorithm
185183
}
186184
else
187185
{
188-
189186
ElementIterator::SPtr itTip = l_tipGeom->begin();
190187
auto createTipProximity =
191188
Operations::CreateCenterProximity::Operation::get(itTip->getTypeInfo());
@@ -201,10 +198,8 @@ class InsertionAlgorithm : public BaseAlgorithm
201198
.normalized();
202199
const type::Vec3 ab = m_couplingPts.back()->getPosition() - tipProx->getPosition();
203200
const SReal dotProd = dot(ab, normal);
204-
if (dotProd > 0.0)
205-
{
201+
if (dotProd > 0.0) {
206202
m_couplingPts.pop_back();
207-
m_needlePts.pop_back();
208203
}
209204

210205
const SReal dist = ab.norm();
@@ -219,23 +214,18 @@ class InsertionAlgorithm : public BaseAlgorithm
219214
{
220215
volProx->normalize();
221216
m_couplingPts.push_back(volProx);
222-
m_needlePts.push_back(m_needlePts.back());
223217
}
224218
}
225219

226220
auto findClosestProxOnShaft =
227221
Operations::FindClosestProximity::Operation::get(l_shaftGeom);
228222
auto projectOnShaft = Operations::Project::Operation::get(l_shaftGeom);
229-
230223
for (int i = 0; i < m_couplingPts.size(); i++)
231224
{
232225
const BaseProximity::SPtr shaftProx = findClosestProxOnShaft(
233226
m_couplingPts[i], l_shaftGeom.get(), projectOnShaft, getFilterFunc());
234-
m_needlePts[i] = shaftProx;
227+
insertionOutput.add(shaftProx, m_couplingPts[i]);
235228
}
236-
237-
for (int i = 0; i < m_couplingPts.size(); i++)
238-
insertionOutput.add(m_needlePts[i], m_couplingPts[i]);
239229
}
240230

241231
d_collisionOutput.endEdit();

0 commit comments

Comments
 (0)