Skip to content

Commit adf8d79

Browse files
committed
[algorithm] Add a bool to enable/disable the puncture sequence
1 parent 7241d39 commit adf8d79

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

src/CollisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class InsertionAlgorithm : public BaseAlgorithm
2929

3030
GeomLink l_tipGeom, l_surfGeom, l_shaftGeom, l_volGeom;
3131
Data<AlgorithmOutput> d_collisionOutput, d_insertionOutput;
32-
Data<bool> d_projective;
32+
Data<bool> d_projective, d_enablePuncture;
3333
Data<SReal> d_punctureForceThreshold, d_tipDistThreshold;
3434
ConstraintSolver::SPtr m_constraintSolver;
3535
std::vector<BaseProximity::SPtr> m_couplingPts;
@@ -50,6 +50,8 @@ class InsertionAlgorithm : public BaseAlgorithm
5050
d_projective(initData(
5151
&d_projective, false, "projective",
5252
"Projection of closest detected proximity back onto the needle tip element.")),
53+
d_enablePuncture(
54+
initData(&d_enablePuncture, true, "enablePuncture", "Enable puncture algorithm.")),
5355
d_punctureForceThreshold(initData(&d_punctureForceThreshold, -1_sreal,
5456
"punctureForceThreshold",
5557
"Threshold for the force applied to the needle tip. "
@@ -134,42 +136,45 @@ class InsertionAlgorithm : public BaseAlgorithm
134136
auto projectOnSurf = Operations::Project::Operation::get(l_surfGeom);
135137

136138
// Puncture sequence
137-
auto createTipProximity =
138-
Operations::CreateCenterProximity::Operation::get(l_tipGeom->getTypeInfo());
139-
auto projectOnTip = Operations::Project::Operation::get(l_tipGeom);
140-
141-
const SReal punctureForceThreshold = d_punctureForceThreshold.getValue();
142-
for (auto itTip = l_tipGeom->begin(); itTip != l_tipGeom->end(); itTip++)
139+
if (d_enablePuncture.getValue())
143140
{
144-
BaseProximity::SPtr tipProx = createTipProximity(itTip->element());
145-
if (!tipProx) continue;
146-
const BaseProximity::SPtr surfProx = findClosestProxOnSurf(
147-
tipProx, l_surfGeom.get(), projectOnSurf, getFilterFunc());
148-
if (surfProx)
141+
auto createTipProximity =
142+
Operations::CreateCenterProximity::Operation::get(l_tipGeom->getTypeInfo());
143+
auto projectOnTip = Operations::Project::Operation::get(l_tipGeom);
144+
145+
const SReal punctureForceThreshold = d_punctureForceThreshold.getValue();
146+
for (auto itTip = l_tipGeom->begin(); itTip != l_tipGeom->end(); itTip++)
149147
{
150-
surfProx->normalize();
151-
152-
// Check whether puncture is happening - if so, create coupling point ...
153-
if (m_constraintSolver)
148+
BaseProximity::SPtr tipProx = createTipProximity(itTip->element());
149+
if (!tipProx) continue;
150+
const BaseProximity::SPtr surfProx = findClosestProxOnSurf(
151+
tipProx, l_surfGeom.get(), projectOnSurf, getFilterFunc());
152+
if (surfProx)
154153
{
155-
const MechStateTipType::SPtr mstate =
156-
l_tipGeom->getContext()->get<MechStateTipType>();
157-
const auto& lambda =
158-
m_constraintSolver->getLambda()[mstate.get()].read()->getValue();
159-
SReal norm{0_sreal};
160-
for (const auto& l : lambda)
161-
{
162-
norm += l.norm();
163-
}
164-
if (norm > punctureForceThreshold)
154+
surfProx->normalize();
155+
156+
// Check whether puncture is happening - if so, create coupling point ...
157+
if (m_constraintSolver)
165158
{
166-
m_couplingPts.push_back(surfProx);
167-
continue;
159+
const MechStateTipType::SPtr mstate =
160+
l_tipGeom->getContext()->get<MechStateTipType>();
161+
const auto& lambda =
162+
m_constraintSolver->getLambda()[mstate.get()].read()->getValue();
163+
SReal norm{0_sreal};
164+
for (const auto& l : lambda)
165+
{
166+
norm += l.norm();
167+
}
168+
if (norm > punctureForceThreshold)
169+
{
170+
m_couplingPts.push_back(surfProx);
171+
continue;
172+
}
168173
}
174+
175+
// ... if not, create a proximity pair for the tip-surface collision
176+
collisionOutput.add(tipProx, surfProx);
169177
}
170-
171-
// ... if not, create a proximity pair for the tip-surface collision
172-
collisionOutput.add(tipProx, surfProx);
173178
}
174179
}
175180

0 commit comments

Comments
 (0)