Skip to content

Commit b084d90

Browse files
fredroybakpaulepernod
authored
[InterventionalRadiologyController] fix when giving 0 as index for fixFirstNodesWithUntil (#219)
* fix when giving 0 as index for fixFirstNodesWithUntil * Update src/BeamAdapter/component/controller/InterventionalRadiologyController.inl Co-authored-by: erik pernod <erik.pernod@gmail.com> --------- Co-authored-by: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Co-authored-by: erik pernod <erik.pernod@gmail.com>
1 parent 7a3305f commit b084d90

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/BeamAdapter/component/controller/InterventionalRadiologyController.inl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,14 +1128,21 @@ void InterventionalRadiologyController<DataTypes>::fillInstrumentCurvAbsTable(co
11281128
template <class DataTypes>
11291129
void InterventionalRadiologyController<DataTypes>::fixFirstNodesWithUntil(unsigned int firstSimulatedNode)
11301130
{
1131+
l_fixedConstraint->clearConstraints();
1132+
1133+
if (firstSimulatedNode == 0)
1134+
{
1135+
msg_warning() << "An invalid value of firstSimulatedNode equal to 0 has been given to fixFirstNodesWithUntil() method.";
1136+
d_indexFirstNode = 0;
1137+
return;
1138+
}
1139+
11311140
WriteAccessor<Data<VecCoord> > xMstate = *getMechanicalState()->write(sofa::core::vec_id::write_access::position);
11321141
WriteAccessor<Data<VecCoord> > xrestMstate = *getMechanicalState()->write(sofa::core::vec_id::write_access::restPosition);
11331142
WriteAccessor<Data<VecDeriv> > vMstate = *getMechanicalState()->write(sofa::core::vec_id::write_access::velocity);
11341143

11351144
// set the position to startingPos for all the nodes that are not simulated
11361145
const auto& startPos = d_startingPos.getValue();
1137-
// and add a fixedConstraint
1138-
l_fixedConstraint->clearConstraints();
11391146
for(unsigned int i=0; i<firstSimulatedNode-1 ; i++)
11401147
{
11411148
xMstate[i] = startPos;

0 commit comments

Comments
 (0)