Skip to content

Commit 9553a37

Browse files
authored
[InterventionalRadiologyController] Remove processDrop which is not anymore supported (#120)
* Remove code related to drop action, not anymore supported * [IRCtrl] VArious small cleanup * Add deprecated macro
1 parent 6ecec66 commit 9553a37

2 files changed

Lines changed: 22 additions & 98 deletions

File tree

src/BeamAdapter/component/controller/InterventionalRadiologyController.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ class InterventionalRadiologyController : public MechanicalStateController<DataT
116116
/// Getter to the tools curviline abscisses sorted @sa m_nodeCurvAbs at the current timestep.
117117
[[nodiscard]] const type::vector<Real>& getCurrentCurvAbscisses() const { return m_nodeCurvAbs; }
118118

119+
120+
/////////////////////////// Deprecated Methods //////////////////////////////////////////
121+
[[deprecated("Releasing catheter or brokenIn2 mode is not anymore supported. Feature has been removed after release v23.06")]]
122+
void processDrop(unsigned int& previousNumControlledNodes, unsigned int& seg_remove)
123+
{
124+
SOFA_UNUSED(previousNumControlledNodes);
125+
SOFA_UNUSED(seg_remove);
126+
msg_warning() << "Releasing catheter or brokenIn2 mode is not anymore supported. Feature has been removed after release v23.06";
127+
}
128+
129+
119130
public:
120131

121132
using Inherit1::f_printLog;
@@ -133,7 +144,6 @@ class InterventionalRadiologyController : public MechanicalStateController<DataT
133144
/// Interface for interventionalRadiology instruments:
134145
virtual void applyInterventionalRadiologyController(void);
135146

136-
void processDrop(unsigned int &previousNumControlledNodes, unsigned int &seg_remove);
137147

138148
private:
139149
/** Compute the sambling curv abscisses using each instrument sampling and key points parameters
@@ -170,13 +180,11 @@ class InterventionalRadiologyController : public MechanicalStateController<DataT
170180
bool m_useBeamActions = false;
171181
bool m_FF, m_RW, m_sensored;
172182
FixedConstraint<DataTypes> * m_fixedConstraint;
173-
type::vector<int> m_droppedInstruments;
174183
type::vector<Vec3d> m_sensorMotionData;
175184
unsigned int m_currentSensorData;
176185
type::vector<Real> m_nodeCurvAbs;
177186
type::vector< type::vector<int> > m_idInstrumentCurvAbsTable;
178187
unsigned int m_numControlledNodes; // Excluding the nodes that are "dropped"
179-
bool m_dropCall;
180188
};
181189

182190
#if !defined(SOFA_PLUGIN_BEAMADAPTER_INTERVENTIONALRADIOCONTROLLER_CPP)

src/BeamAdapter/component/controller/InterventionalRadiologyController.inl

Lines changed: 11 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ InterventionalRadiologyController<DataTypes>::InterventionalRadiologyController(
7474
, d_indexFirstNode(initData(&d_indexFirstNode, (unsigned int) 0, "indexFirstNode", "first node (should be fixed with restshape)"))
7575
{
7676
m_fixedConstraint = nullptr;
77-
m_dropCall = false;
7877
m_sensored =false;
7978
}
8079

@@ -141,10 +140,6 @@ void InterventionalRadiologyController<DataTypes>::init()
141140
if(m_fixedConstraint==nullptr)
142141
msg_error()<<"No fixedConstraint found.";
143142

144-
/// List of the instrument for which a "DROPPED" was proceeed TODO
145-
m_droppedInstruments.clear();
146-
147-
148143
// the controller must listen to the event (in particular BeginAnimationStep event)
149144
if (!f_listening.isSet())
150145
{
@@ -446,82 +441,9 @@ void InterventionalRadiologyController<DataTypes>::applyAction(sofa::beamadapter
446441
}
447442
case BeamAdapterAction::DROP_TOOL:
448443
{
449-
m_dropCall = true;
450-
}
451-
}
452-
}
453-
454-
455-
template <class DataTypes>
456-
void InterventionalRadiologyController<DataTypes>::processDrop(unsigned int &previousNumControlledNodes,
457-
unsigned int &segRemove)
458-
{
459-
int ci = int(d_controlledInstrument.getValue());
460-
Real xMinOutLocal= 0.0;
461-
462-
Real xBegin=0.0;
463-
464-
// Quelque soit le resultat du process, le drop call est traite ici
465-
m_dropCall = false;
466-
467-
// Step1 : quel est l'abscisse curviligne ou l'instrument controllé est seul ?
468-
for (unsigned int i=0; i<m_nodeCurvAbs.size(); i++)
469-
{
470-
// on parcourt toutes abscisse curv jusqu'à trouver un endroit où il n'y a qu'un seul instrument
471-
if (m_idInstrumentCurvAbsTable[i].size()==1)
472-
{
473-
// on vérifie qu'il s'agit de celui qui est controle
474-
if( ci ==m_idInstrumentCurvAbsTable[i][0])
475-
{
476-
xBegin = d_xTip.getValue()[ci] - m_instrumentsList[ci]->getRestTotalLength();
477-
xMinOutLocal = m_nodeCurvAbs[i] - xBegin;
478-
break;
479-
}
480-
else
481-
{
482-
msg_error()<<" The control instrument is not out, drop is impossible.";
483-
return;
484-
}
485-
}
486-
}
487-
488-
if(xMinOutLocal<=0.0)
489-
{
490-
msg_error()<<" x_min_out_local <= 0.0 The control instrument is not out, drop is impossible.";
491-
return;
444+
msg_warning() << "Releasing catheter or brokenIn2 mode is not anymore supported. Feature has been removed after release v23.06";
492445
}
493-
494-
// Step2 : on verifie que cette abscisse curviligne est compatible avec celle de l'instrument
495-
// (on ne peut pas casser un instrument s'il est à l'intérieur d'un autre instrument)
496-
int numBeamsNotUnderControlled = 0;
497-
Real xBreak;
498-
if( m_instrumentsList[ci]->breaksInTwo(xMinOutLocal, xBreak, numBeamsNotUnderControlled) )
499-
{
500-
msg_error()<<"Breaks in two process activated.";
501-
502-
// for now, we simply suppress one more beam !
503-
m_numControlledNodes -= (numBeamsNotUnderControlled + 1);
504-
505-
auto xEnds = sofa::helper::getWriteOnlyAccessor(d_xTip);
506-
xEnds[ci] = xBegin + xBreak;
507-
}
508-
else
509-
return;
510-
511-
// Step3 : on remet à jour les abscisse curviligne des noeuds en virant toutes celles qui correspondent à la partie
512-
// cassée
513-
Real eps=d_threshold.getValue();
514-
for (unsigned int i=0; i<m_nodeCurvAbs.size(); i++)
515-
{
516-
if( m_nodeCurvAbs[i] > (xBegin + xBreak + eps) )
517-
{
518-
type::removeIndex(m_nodeCurvAbs,i);
519-
type::removeIndex(m_idInstrumentCurvAbsTable, i);
520-
i--;
521-
}
522446
}
523-
segRemove = 1;
524-
previousNumControlledNodes =m_numControlledNodes;
525447
}
526448

527449

@@ -784,18 +706,15 @@ void InterventionalRadiologyController<DataTypes>::applyInterventionalRadiologyC
784706
{
785707
const Real& threshold = d_threshold.getValue();
786708

787-
/// Create vectors with the CurvAbs of the noticiable points and the id of the corresponding instrument
709+
710+
// Create vectors with the CurvAbs of the noticiable points and the id of the corresponding instrument
788711
type::vector<Real> newCurvAbs;
789-
790-
/// In case of drop:
791-
unsigned int previousNumControlledNodes = m_numControlledNodes;
792-
unsigned int seg_remove = 0;
712+
type::vector<type::vector<int>> idInstrumentTable;
793713

794714
// ## STEP 1: Find the total length of the COMBINED INSTRUMENTS and the one for which xtip > 0 (so the one which are simulated)
795715
helper::AdvancedTimer::stepBegin("step1");
796716
Real totalLengthCombined=0.0;
797-
type::vector<Real> tools_xBegin;
798-
type::vector<Real> tools_xEnd;
717+
type::vector<Real> tools_xBegin, tools_xEnd;
799718
for (unsigned int i=0; i<m_instrumentsList.size(); i++)
800719
{
801720
const Real& xend= d_xTip.getValue()[i];
@@ -836,11 +755,9 @@ void InterventionalRadiologyController<DataTypes>::applyInterventionalRadiologyC
836755
computeInstrumentsCurvAbs(newCurvAbs, tools_xBegin, totalLengthCombined);
837756

838757
// => id_instrument_table which provides for each simulated node, the id of all instruments which belong this node
839-
type::vector<type::vector<int>> idInstrumentTable;
840758
fillInstrumentCurvAbsTable(newCurvAbs, tools_xBegin, tools_xEnd, idInstrumentTable);
841759
helper::AdvancedTimer::stepEnd("step2");
842760

843-
844761
// ## STEP 3: Re-interpolate the positions and the velocities
845762
helper::AdvancedTimer::stepBegin("step3");
846763

@@ -852,19 +769,19 @@ void InterventionalRadiologyController<DataTypes>::applyInterventionalRadiologyC
852769
const sofa::Size nbrCurvAbs = newCurvAbs.size(); // number of simulated nodes
853770
const sofa::Size prev_nbrCurvAbs = m_nodeCurvAbs.size(); // previous number of simulated nodes;
854771
const Real prev_maxCurvAbs = m_nodeCurvAbs.back();
855-
772+
856773
// => Change curv if totalLength has changed: modifiedCurvAbs = newCurvAbs - current motion (Length between new and old tip curvAbs)
857774
type::vector<Real> modifiedCurvAbs;
858775
totalLengthIsChanging(newCurvAbs, modifiedCurvAbs, idInstrumentTable);
859776

860777
sofa::Size nbrUnactiveNode = m_numControlledNodes - nbrCurvAbs; // m_numControlledNodes == nbr Dof | nbr of CurvAbs > 0
861-
sofa::Size prev_nbrUnactiveNode = previousNumControlledNodes - prev_nbrCurvAbs;
778+
sofa::Size prev_nbrUnactiveNode = m_numControlledNodes - prev_nbrCurvAbs;
862779

863780
for (sofa::Index xId = 0; xId < nbrCurvAbs; xId++)
864781
{
865-
const sofa::Index globalNodeId = nbrUnactiveNode + xId; // fill the end of the dof buffer
782+
const sofa::Index globalNodeId = nbrUnactiveNode + xId; // position of the curvAbs in the dof buffer filled by the end
866783
const Real xCurvAbs = modifiedCurvAbs[xId];
867-
784+
868785
// 2 cases: TODO : remove first case
869786
//1. the abs curv is further than the previous state of the instrument
870787
//2. this is not the case and the node position can be interpolated using previous step positions
@@ -890,7 +807,7 @@ void InterventionalRadiologyController<DataTypes>::applyInterventionalRadiologyC
890807
prev_xId++;
891808
}
892809

893-
sofa::Index prev_globalNodeId = prev_nbrUnactiveNode + seg_remove + prev_xId;
810+
sofa::Index prev_globalNodeId = prev_nbrUnactiveNode + prev_xId;
894811
const Real prev_xCurvAbs = m_nodeCurvAbs[prev_xId];
895812

896813
if (fabs(prev_xCurvAbs - xCurvAbs) < threshold)
@@ -1012,9 +929,7 @@ void InterventionalRadiologyController<DataTypes>::applyInterventionalRadiologyC
1012929
if(rigid)
1013930
m_fixedConstraint->addConstraint(firstSimulatedNode+i);
1014931
}
1015-
1016932
}
1017-
1018933
}
1019934
helper::AdvancedTimer::stepEnd("step5");
1020935

@@ -1026,6 +941,7 @@ void InterventionalRadiologyController<DataTypes>::applyInterventionalRadiologyC
1026941
m_idInstrumentCurvAbsTable = idInstrumentTable;
1027942
}
1028943

944+
1029945
template <class DataTypes>
1030946
void InterventionalRadiologyController<DataTypes>::totalLengthIsChanging(const type::vector<Real>& newNodeCurvAbs,
1031947
type::vector<Real>& modifiedNodeCurvAbs,

0 commit comments

Comments
 (0)