Skip to content

Commit 8df24e3

Browse files
committed
[algorithm] Make sanity checks happen only when appropriate for some data
1 parent 6a25270 commit 8df24e3

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/CollisionAlgorithm/algorithm/InsertionAlgorithm.h

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,32 @@ class InsertionAlgorithm : public BaseAlgorithm
7676
void init() override
7777
{
7878
BaseAlgorithm::init();
79-
this->getContext()->get<ConstraintSolver>(m_constraintSolver);
80-
msg_warning_when(!m_constraintSolver)
81-
<< "No constraint solver found in context. Insertion algorithm is disabled.";
8279

83-
if (d_punctureForceThreshold.getValue() < 0)
80+
if (d_enablePuncture.getValue())
8481
{
85-
msg_warning() << d_punctureForceThreshold.getName() +
86-
" parameter not defined or set to negative value." msgendl
87-
<< "Puncture will not function properly; provide a positive value";
88-
d_punctureForceThreshold.setValue(std::numeric_limits<double>::max());
82+
this->getContext()->get<ConstraintSolver>(m_constraintSolver);
83+
msg_warning_when(!m_constraintSolver)
84+
<< "No constraint solver found in context. Insertion algorithm is disabled.";
85+
d_punctureForceThreshold.setRequired(true);
86+
if (d_punctureForceThreshold.getValue() < 0)
87+
{
88+
msg_warning() << d_punctureForceThreshold.getName() +
89+
" parameter not defined or set to negative value." msgendl
90+
<< "Puncture will not function properly; provide a positive value";
91+
d_punctureForceThreshold.setValue(std::numeric_limits<double>::max());
92+
}
8993
}
9094

91-
if (d_tipDistThreshold.getValue() < 0)
95+
if (d_enableInsertion.getValue())
9296
{
93-
msg_warning() << d_tipDistThreshold.getName() +
94-
" parameter not defined or set to negative value." msgendl
95-
<< "Needle-volume coupling is disabled; provide a positive value";
96-
d_tipDistThreshold.setValue(std::numeric_limits<double>::max());
97+
d_tipDistThreshold.setRequired(true);
98+
if (d_tipDistThreshold.getValue() < 0)
99+
{
100+
msg_warning() << d_tipDistThreshold.getName() +
101+
" parameter not defined or set to negative value." msgendl
102+
<< "Needle-volume coupling is disabled; provide a positive value";
103+
d_tipDistThreshold.setValue(std::numeric_limits<double>::max());
104+
}
97105
}
98106
}
99107

0 commit comments

Comments
 (0)