Skip to content

Commit acfd8b7

Browse files
authored
Merge pull request #220 from fredroy/irc_fix_div_0
[InterventionalRadiologyController] fix potential div by 0 in computeInstrumentsCurvAbs
2 parents 8f4f63b + 27c311d commit acfd8b7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/BeamAdapter/component/controller/InterventionalRadiologyController.inl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,16 @@ void InterventionalRadiologyController<DataTypes>::computeInstrumentsCurvAbs(typ
573573

574574
if (curvAbs_interval > 0)
575575
{
576+
const Real intervalLength = nxP - xP;
577+
if (intervalLength <= 0 || density_I[j] == 0)
578+
{
579+
xSampling = curvAbs_nxP;
580+
continue;
581+
}
582+
576583
// compute the number of point of the emerged interval (if all the interval is emerged, i.e >0 , numNewNodes == density[j])
577-
Real ratio = Real(density_I[j]) / (nxP - xP);
578-
int numNewNodes = int(floor(curvAbs_interval * ratio)); // if density == 0, no sampling (numNewNodes == 0)
584+
Real ratio = Real(density_I[j]) / intervalLength;
585+
int numNewNodes = int(floor(curvAbs_interval * ratio));
579586

580587
// Add the new points using reverse order iterator as they are computed deduce to next noticeable point
581588
for (int k = numNewNodes; k>0; k--)

0 commit comments

Comments
 (0)