Skip to content

Commit 2b65a60

Browse files
authored
Merge pull request sofa-framework#234 from fredroy/irc_remove_motionfile
[InterventionalRadiologyController] Remove motionData-related code
2 parents cac4005 + 08879e2 commit 2b65a60

2 files changed

Lines changed: 4 additions & 61 deletions

File tree

src/BeamAdapter/component/controller/InterventionalRadiologyController.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ class InterventionalRadiologyController : public sofa::component::controller::Me
156156
void totalLengthIsChanging(const type::vector<Real>& newNodeCurvAbs, type::vector<Real>& modifiedNodeCurvAbs, const type::vector< type::vector<int> >& newTable);
157157
void fixFirstNodesWithUntil(unsigned int first_simulated_Node);
158158
void activateBeamListForCollision( type::vector<Real> &curv_abs, type::vector< type::vector<int> > &id_instrument_table);
159-
void loadMotionData(std::string filename);
160159

161160
Data<int> d_controlledInstrument;
162161
Data<type::vector<Real>> d_xTip;
@@ -167,12 +166,11 @@ class InterventionalRadiologyController : public sofa::component::controller::Me
167166
Data<Coord> d_startingPos;
168167
Data<Real> d_threshold;
169168
Data<type::vector<Real>> d_rigidCurvAbs; // Pairs (start - end)
170-
Data<std::string> d_motionFilename;
171169
Data<unsigned int> d_indexFirstNode; // First Node simulated
172-
173-
170+
171+
174172
bool m_useBeamActions = false;
175-
bool m_FF, m_RW, m_sensored;
173+
bool m_FF = false, m_RW = false;
176174

177175
SingleLink<
178176
InterventionalRadiologyController, FixedProjectiveConstraint<DataTypes>,
@@ -183,8 +181,6 @@ class InterventionalRadiologyController : public sofa::component::controller::Me
183181

184182
DeprecatedAndRemoved m_fixedConstraint;
185183

186-
type::vector<Vec3d> m_sensorMotionData;
187-
unsigned int m_currentSensorData;
188184
type::vector<Real> m_nodeCurvAbs;
189185
type::vector< type::vector<int> > m_idInstrumentCurvAbsTable;
190186
};

src/BeamAdapter/component/controller/InterventionalRadiologyController.inl

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <sofa/component/topology/container/dynamic/EdgeSetGeometryAlgorithms.h>
3939
#include <sofa/core/behavior/MechanicalState.h>
4040
#include <sofa/helper/AdvancedTimer.h>
41-
#include <sofa/helper/system/FileRepository.h>
4241
#include <sofa/type/vector_algorithm.h>
4342

4443

@@ -68,12 +67,10 @@ InterventionalRadiologyController<DataTypes>::InterventionalRadiologyController(
6867
, d_startingPos(initData(&d_startingPos,Coord(),"startingPos","starting pos for inserting the instrument"))
6968
, d_threshold(initData(&d_threshold, (Real)0.01, "threshold", "threshold for controller precision which is homogeneous to the unit of length used in the simulation"))
7069
, d_rigidCurvAbs(initData(&d_rigidCurvAbs, "rigidCurvAbs", "pairs of curv abs for beams we want to rigidify"))
71-
, d_motionFilename(initData(&d_motionFilename, "motionFilename", "text file that includes tracked motion from optical sensor"))
7270
, d_indexFirstNode(initData(&d_indexFirstNode, (unsigned int) 0, "indexFirstNode", "first node (should be fixed with restshape)"))
7371
, l_fixedConstraint(initLink("fixedConstraint", "Path to the FixedProjectiveConstraint"))
7472
, l_mechanicalTopology(initLink("topology", "Path to the mechanical topology"))
7573
{
76-
m_sensored =false;
7774
}
7875

7976

@@ -137,13 +134,7 @@ void InterventionalRadiologyController<DataTypes>::init()
137134
{
138135
m_FF=true;
139136
m_RW=false;
140-
m_sensored = false;
141137
}
142-
if (!d_motionFilename.getValue().empty())
143-
{
144-
m_FF = true; m_sensored = true; m_currentSensorData = 0;
145-
loadMotionData(d_motionFilename.getValue());
146-
}
147138

148139
auto checkData = [&](auto& data)
149140
{
@@ -296,31 +287,6 @@ void InterventionalRadiologyController<DataTypes>::init()
296287
sofa::core::objectmodel::BaseComponent::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid);
297288
}
298289

299-
template<class DataTypes>
300-
void InterventionalRadiologyController<DataTypes>::loadMotionData(std::string filename)
301-
{
302-
if (!helper::system::DataRepository.findFile(filename))
303-
{
304-
msg_error() << "File " << filename << " not found.";
305-
return;
306-
}
307-
std::ifstream file(filename.c_str());
308-
309-
std::string line;
310-
Vec3 result;
311-
while( std::getline(file,line) )
312-
{
313-
if (line.empty())
314-
continue;
315-
std::istringstream values(line);
316-
values >> result[0] >> result[1] >> result[2];
317-
result[0] /= 1000;
318-
m_sensorMotionData.push_back(result);
319-
}
320-
321-
file.close();
322-
}
323-
324290
/*!
325291
* \todo fix the mouse event with better controls
326292
*/
@@ -413,26 +379,7 @@ void InterventionalRadiologyController<DataTypes>::onBeginAnimationStep(const do
413379
}
414380
if (m_FF)
415381
{
416-
if (!m_sensored)
417-
xInstrTip[id] += d_speed.getValue() * context->getDt();
418-
else
419-
{
420-
unsigned int newSensorData = m_currentSensorData + 1;
421-
422-
while( m_sensorMotionData[newSensorData][0] < context->getTime() )
423-
{
424-
m_currentSensorData = newSensorData;
425-
newSensorData++;
426-
}
427-
if(newSensorData >= m_sensorMotionData.size())
428-
{
429-
xInstrTip[id] = 0;
430-
}
431-
else
432-
{
433-
xInstrTip[id] += m_sensorMotionData[m_currentSensorData][1];
434-
}
435-
}
382+
xInstrTip[id] += d_speed.getValue() * context->getDt();
436383
}
437384
if (m_RW)
438385
{

0 commit comments

Comments
 (0)