From fc22c1ec318d9461ffa760d3623ca6a274e432d0 Mon Sep 17 00:00:00 2001 From: epernod Date: Wed, 3 May 2023 23:16:48 +0200 Subject: [PATCH 1/2] Fix potential problem in MultiAdaptiveBeamMapping --- .../InterventionalRadiologyController.inl | 2 +- .../mapping/MultiAdaptiveBeamMapping.inl | 64 +++++++++++-------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index 86ff86f5b..2657773e2 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -528,7 +528,7 @@ void InterventionalRadiologyController::interventionalRadiologyComput m_instrumentsList[i]->getSamplingParameters(xP_noticeable_I, density_I); // check each interval of noticeable point to see if they go out (>0) and use corresponding density to sample the interval. - for (unsigned int j=0; j::assignSubMappingFromControllerInfo() // 1. get the new controls m_ircontroller->interventionalRadiologyCollisionControls(_xPointList, _idm_instrumentList, removeEdgeAtPoint); - + if(!isBarycentricMapping) { + //Case if this is not a barycentric mapping // 2. assign each value of xPointList to the corresponding "sub Mapping" // i.e = each point from xPointList of the collision model is controlled by a given instrument wich id is provided in _id_m_instrumentList @@ -183,9 +184,7 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::assignSubMappingFromControllerInfo() } // handle the possible topological change - sofa::type::vector edgeToRemove; - edgeToRemove.clear(); for (unsigned int i=0; i::assignSubMappingFromControllerInfo() } else { - msg_error() << " WARNING !! baseEdge = "<0) @@ -251,32 +250,37 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::assignSubMappingFromControllerInfo() template void MultiAdaptiveBeamMapping< TIn, TOut>::init() { - if (m_ircontroller==nullptr) { - ///////// get the Adaptive Interpolation component /////// - core::objectmodel::BaseContext * c = this->getContext(); - - const type::vector& interpolName = m_controlerPath.getValue(); - if (interpolName.empty()) { - m_ircontroller = c->get(core::objectmodel::BaseContext::Local); - } else { - m_ircontroller = c->get(m_controlerPath.getValue()[0]); - } + if (m_ircontroller==nullptr) + { + ///////// get the Adaptive Interpolation component /////// + core::objectmodel::BaseContext * c = this->getContext(); + + const type::vector& interpolName = m_controlerPath.getValue(); + if (interpolName.empty()) { + m_ircontroller = c->get(core::objectmodel::BaseContext::Local); + } else { + m_ircontroller = c->get(m_controlerPath.getValue()[0]); + } - if(m_ircontroller==nullptr) - msg_error() << " no Beam Interpolation found !!! the component can not work"; - else - msg_info() << " interpolation named" << m_ircontroller->getName() << " found (for " << this->getName()<<")"; + if (m_ircontroller == nullptr) { + msg_error() << " no Beam Interpolation found !!! the component can not work"; + sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); + return; + } + else { + msg_info() << " interpolation named" << m_ircontroller->getName() << " found (for " << this->getName() << ")"; } + } - m_ircontroller->getInstrumentList(m_instrumentList); + m_ircontroller->getInstrumentList(m_instrumentList); - // create a mapping for each instrument - m_subMappingList.clear(); - for (unsigned int i=0; i::SPtr newMapping = sofa::core::objectmodel::New>(this->fromModel, this->toModel,m_instrumentList[i],true); - m_subMappingList.push_back(newMapping); - } + // create a mapping for each instrument + m_subMappingList.clear(); + for (unsigned int i=0; i::SPtr newMapping = sofa::core::objectmodel::New>(this->fromModel, this->toModel,m_instrumentList[i],true); + m_subMappingList.push_back(newMapping); + } this->f_listening.setValue(true); @@ -284,8 +288,9 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::init() ///////// STEP 3 : get the edgeSet topology and fill it with segments this->getContext()->get(_topology); - if(_topology != nullptr && this->f_printLog.getValue() ) + if (_topology != nullptr && this->f_printLog.getValue()) { msg_info() << " FIND topology named " << _topology->getName(); + } this->getContext()->get(_edgeMod); @@ -324,13 +329,16 @@ void MultiAdaptiveBeamMapping< TIn, TOut>::init() { _topology->addEdge(i,i+1); } + + // create edge around vertex array + _topology->init(); + // resize Mstate this->toModel->resize(numSeg+1); // resize the internal list of the collision points ( for each point : [x_curv on the global wire , id of the corresponding instrument] _xPointList.resize(numSeg+1); _idm_instrumentList.resize(numSeg+1); - } From abd30fa2052769d6ef192168d675d7fbabccb371 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Wed, 17 May 2023 09:40:47 +0200 Subject: [PATCH 2/2] Update src/BeamAdapter/component/controller/InterventionalRadiologyController.inl Co-authored-by: Hugo --- .../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 2657773e2..cd806bffd 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -528,7 +528,7 @@ void InterventionalRadiologyController::interventionalRadiologyComput m_instrumentsList[i]->getSamplingParameters(xP_noticeable_I, density_I); // check each interval of noticeable point to see if they go out (>0) and use corresponding density to sample the interval. - for (auto j=0; j<(int)(xP_noticeable_I.size()-1); j++) + for (int j=0; j<(int)(xP_noticeable_I.size()-1); j++) { const Real xP = xP_noticeable_I[j]; const Real nxP = xP_noticeable_I[j + 1];