From 307f24d6584c7ed5e0e3f3a896a1f1c18395ca37 Mon Sep 17 00:00:00 2001 From: epernod Date: Tue, 11 Oct 2022 14:02:23 +0200 Subject: [PATCH 1/5] [IRCtrl] Fix instrumentList parsing and bad filling at init --- .../InterventionalRadiologyController.inl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index dc554ec4b..4d46abfaa 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -88,8 +88,7 @@ void InterventionalRadiologyController::init() const type::vector& instrumentPathList = d_instrumentsPath.getValue(); if (instrumentPathList.empty()) { - WBeamInterpolation * wbinterpol= context->get< WBeamInterpolation >(BaseContext::Local); - m_instrumentsList.push_back(wbinterpol); + getContext()->get(&m_instrumentsList, sofa::core::objectmodel::BaseContext::SearchRoot); } else { @@ -104,8 +103,11 @@ void InterventionalRadiologyController::init() } } - if(m_instrumentsList.empty()) - msg_error()<<"No Beam Interpolation found !!! the component can not work."; + if (m_instrumentsList.empty()) { + msg_error() << "No instrument found (no WireBeamInterpolation)! the component can not work and will be set to Invalid."; + sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); + return; + } m_activatedPointsBuf.clear(); @@ -121,11 +123,6 @@ void InterventionalRadiologyController::init() loadMotionData(d_motionFilename.getValue()); } - if (m_instrumentsList.size() == 0) - { - msg_error()<<"No instrument found ( no WireBeamInterpolation)."; - return; - } auto x_instr_tip = sofa::helper::getWriteOnlyAccessor(d_xTip); x_instr_tip.resize(m_instrumentsList.size()); @@ -161,7 +158,7 @@ void InterventionalRadiologyController::init() Inherit::init(); - reinit(); + sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid); } template From 79a746f5efd2cce53c8ad3cfe1eade7904c59a02 Mon Sep 17 00:00:00 2001 From: epernod Date: Tue, 11 Oct 2022 14:03:48 +0200 Subject: [PATCH 2/5] [IRCtrl] Add warning at init if nbrDof is too low --- .../InterventionalRadiologyController.inl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index 4d46abfaa..3d2291f3a 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -201,6 +201,23 @@ void InterventionalRadiologyController::bwdInit() x[i] = d_startingPos.getValue(); m_numControlledNodes = x.size(); + sofa::Size nbrBeam = 0; + for (unsigned int i = 0; i < m_instrumentsList.size(); i++) + { + type::vector xP_noticeable_I; + type::vector< int > density_I; + m_instrumentsList[i]->getSamplingParameters(xP_noticeable_I, density_I); + + for (auto nb : density_I) + nbrBeam += nb; + } + + if (nbrBeam > m_numControlledNodes) + { + msg_warning() << "Parameter missmatch: According to the list of controlled instrument controlled. The number of potential beams: " + << nbrBeam << " exceed the number of degree of freedom in the MechanicalObject: " << m_numControlledNodes << ". This could lead to unespected behavior."; + } + applyInterventionalRadiologyController(); reinit(); } From d75889fd4fef070837e7eff675701017cadf4cab Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 14 Oct 2022 14:42:25 +0900 Subject: [PATCH 3/5] Fix compilation --- .../component/controller/InterventionalRadiologyController.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index b48dbac0c..a9f2b761c 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -87,7 +87,7 @@ void InterventionalRadiologyController::init() const type::vector& instrumentPathList = d_instrumentsPath.getValue(); if (instrumentPathList.empty()) { - getContext()->get(&m_instrumentsList, sofa::core::objectmodel::BaseContext::SearchRoot); + getContext()->template get(&m_instrumentsList, sofa::core::objectmodel::BaseContext::SearchRoot); } else { From 5e8d0a3172847e8b70fb0902a565f85aa48f79b1 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Thu, 27 Oct 2022 10:28:23 +0200 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Hugo --- .../controller/InterventionalRadiologyController.inl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index a9f2b761c..e888cedd9 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -107,6 +107,10 @@ void InterventionalRadiologyController::init() sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); return; } + else + { + msg_info() << m_instrumentsList.size() << " instrument(s) found (WireBeamInterpolation)"; + } m_activatedPointsBuf.clear(); From 117c68b88921d0b86d7ca43641e023e94b913e47 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Thu, 27 Oct 2022 10:55:39 +0200 Subject: [PATCH 5/5] Update InterventionalRadiologyController.inl --- .../component/controller/InterventionalRadiologyController.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index e888cedd9..cdddd0f47 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -87,7 +87,7 @@ void InterventionalRadiologyController::init() const type::vector& instrumentPathList = d_instrumentsPath.getValue(); if (instrumentPathList.empty()) { - getContext()->template get(&m_instrumentsList, sofa::core::objectmodel::BaseContext::SearchRoot); + getContext()->template get(&m_instrumentsList, sofa::core::objectmodel::BaseContext::Local); } else {