Skip to content

Commit 3f707ee

Browse files
epernodfredroy
andauthored
[InterventionalRadiologyController] Rewrite method interventionalRadiologyComputeSampling (#62)
* [InterventionalRadiologyController] rewrite sampling method. * Update src/BeamAdapter/component/controller/InterventionalRadiologyController.inl Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com> Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com>
1 parent c803e81 commit 3f707ee

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

src/BeamAdapter/component/controller/InterventionalRadiologyController.inl

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -458,28 +458,50 @@ void InterventionalRadiologyController<DataTypes>::interventionalRadiologyComput
458458
const Real& xend)
459459

460460
{
461-
// Step 1 = put the noticeable Nodes
461+
// Step 1 => put the noticeable Nodes
462+
// Step 2 => add the beams given the sampling parameters
462463
double maxAbsLength=0.0;
463-
for (unsigned int i=0; i<m_instrumentsList.size(); i++)
464+
Real xSampling = 0.0;
465+
for (auto i=0; i<m_instrumentsList.size(); i++)
464466
{
465467
type::vector<Real> xP_noticeable_I;
466468
type::vector< int > density_I;
467469
m_instrumentsList[i]->getSamplingParameters(xP_noticeable_I, density_I);
468470

469-
for (unsigned int j=0; j<xP_noticeable_I.size(); j++)
471+
// check each interval of noticeable point to see if they go out (>0) and use corresponding density to sample the interval.
472+
for (unsigned int j=0; j<xP_noticeable_I.size()-1; j++)
470473
{
474+
const Real xP = xP_noticeable_I[j];
475+
const Real nxP = xP_noticeable_I[j + 1];
476+
471477
//compute the corresponding abs curv of this "noticeable point" on the combined intrument
472-
Real curvAbs_xP = xBegin[i] + xP_noticeable_I[j];
473-
if (curvAbs_xP>0.0) // all the noticiable point that have a negative curv abs are not simulated => considered as outside of the patient...
478+
const Real curvAbs_xP = xBegin[i] + xP;
479+
const Real curvAbs_nxP = xBegin[i] + nxP;
480+
481+
// compute interval between next point and previous one (0 for the first iter)
482+
const Real curvAbs_interval = (curvAbs_nxP - xSampling);
483+
484+
if (curvAbs_interval > 0)
474485
{
475-
newCurvAbs.push_back(curvAbs_xP);
486+
// compute the number of point of the emerged interval (if all the interval is emerged, i.e >0 , numNewNodes == density[j])
487+
Real ratio = Real(density_I[j]) / (nxP - xP);
488+
int numNewNodes = int(floor(curvAbs_interval * ratio)); // if density == 0, no sampling (numNewNodes == 0)
476489

477-
if (curvAbs_xP > maxAbsLength)
478-
maxAbsLength=curvAbs_xP;
490+
// Add the new points in reverse order
491+
for (int k = numNewNodes; k>0; k--)
492+
{
493+
auto value = curvAbs_nxP - (k / ratio);
494+
newCurvAbs.push_back(value);
495+
}
496+
497+
// Add j+1 bound point
498+
newCurvAbs.push_back(curvAbs_nxP);
499+
xSampling = curvAbs_nxP;
479500
}
480501
}
481502
}
482503

504+
483505
// Step 1(bis) = add Nodes the curv_abs of the rigid parts border
484506
// When there are rigid segments, # of dofs is different than # of edges and beams
485507
const type::vector< Real > *rigidCurvAbs = &d_rigidCurvAbs.getValue();
@@ -510,34 +532,6 @@ void InterventionalRadiologyController<DataTypes>::interventionalRadiologyComput
510532
}
511533
}
512534

513-
// Step 2 => add the beams given the sampling parameters
514-
Real xSampling = 0.0;
515-
for (unsigned int i=0; i<m_instrumentsList.size(); i++)
516-
{
517-
type::vector<Real> xPNoticeableI;
518-
type::vector< int > density_I;
519-
m_instrumentsList[i]->getSamplingParameters(xPNoticeableI, density_I);
520-
521-
for (unsigned int j=0; j<density_I.size(); j++){
522-
523-
//compute the corresponding abs curv of this "noticeable point" on the combined intrument
524-
Real curvAbsxP = xBegin[i] + xPNoticeableI[j+1];
525-
526-
// use density parameter (size = xP_noticeable_I -1 )
527-
if (curvAbsxP > xSampling && density_I[j]>0)
528-
{
529-
Real ratio = (Real)density_I[j] / (xPNoticeableI[j+1] - xPNoticeableI[j]) ;
530-
int numNewNodes = (int)floor( (curvAbsxP- xSampling) *ratio) ;
531-
532-
for (int k=0; k<numNewNodes; k++)
533-
{
534-
newCurvAbs.push_back( xPNoticeableI[j+1] + xBegin[i] - (k+1) * (1/ratio) );
535-
}
536-
xSampling = curvAbsxP;
537-
}
538-
}
539-
}
540-
541535
sortCurvAbs(newCurvAbs, idInstrumentTable);
542536
}
543537

src/BeamAdapter/component/engine/WireRestShape.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class WireRestShape : public core::objectmodel::BaseObject
103103
void getInterpolationParam(const Real& x_curv, Real &_rho, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J);
104104

105105
/**
106-
* This function provides a type::vector with the curviliar abscissa of the noticeable point(s)
107-
* and the minimum density (number of points) between them
106+
* This function provides a type::vector with the curviliar abscissa of the noticeable point(s)
107+
* and the minimum density (number of points) between them. (Nb. nbP_density.size() == xP_noticeable.size() - 1)
108108
*/
109109
void getSamplingParameters(type::vector<Real>& xP_noticeable, type::vector<int>& nbP_density) const ;
110110

0 commit comments

Comments
 (0)