Commit 5513c97f authored by Tobias Lasser's avatar Tobias Lasser

fix size 0 problem in EllipseGenerator

parent b3227b9d
Pipeline #195469 passed with stages
in 6 minutes and 39 seconds
......@@ -16,6 +16,10 @@ namespace elsa
throw std::invalid_argument(
"EllipseGenerator::drawFilledEllipse2d: can only work on 2d DataContainers");
// don't draw anything if size is 0
if (sizes[0] == 0 && sizes[1] == 0)
return;
// convert to radians
auto angleRad = angle * pi<double> / 180.0;
......
......@@ -99,13 +99,13 @@ namespace elsa
template <typename data_t>
index_t PhantomGenerator<data_t>::scale(const DataDescriptor& dd, data_t value)
{
return std::round(value * dd.getNumberOfCoefficientsPerDimension()[0] / 2);
return std::lround(value * (dd.getNumberOfCoefficientsPerDimension()[0] - 1) / 2.0f);
}
template <typename data_t>
index_t PhantomGenerator<data_t>::scaleShift(const DataDescriptor& dd, data_t value)
{
return std::round(value * dd.getNumberOfCoefficientsPerDimension()[0] / 2)
return std::lround(value * (dd.getNumberOfCoefficientsPerDimension()[0] - 1) / 2.0f)
+ (dd.getNumberOfCoefficientsPerDimension()[0] / 2);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment