From 27c311d0b051fcc9569d23c2f7392770eeab2d1f Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Thu, 19 Mar 2026 17:26:50 +0900 Subject: [PATCH] fix potential div by 0 in computeInstrumentsCurvAbs --- .../controller/InterventionalRadiologyController.inl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl index 5a21797c4..08203f489 100644 --- a/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl +++ b/src/BeamAdapter/component/controller/InterventionalRadiologyController.inl @@ -573,9 +573,16 @@ void InterventionalRadiologyController::computeInstrumentsCurvAbs(typ if (curvAbs_interval > 0) { + const Real intervalLength = nxP - xP; + if (intervalLength <= 0 || density_I[j] == 0) + { + xSampling = curvAbs_nxP; + continue; + } + // compute the number of point of the emerged interval (if all the interval is emerged, i.e >0 , numNewNodes == density[j]) - Real ratio = Real(density_I[j]) / (nxP - xP); - int numNewNodes = int(floor(curvAbs_interval * ratio)); // if density == 0, no sampling (numNewNodes == 0) + Real ratio = Real(density_I[j]) / intervalLength; + int numNewNodes = int(floor(curvAbs_interval * ratio)); // Add the new points using reverse order iterator as they are computed deduce to next noticeable point for (int k = numNewNodes; k>0; k--)