Commit 4fbfe5f5 authored by Jens Petit's avatar Jens Petit Committed by Tobias Lasser

Fix (hopefully) all warnings using -Wall.

parent 84b630c8
Pipeline #200376 passed with stages
in 4 minutes and 21 seconds
......@@ -36,9 +36,11 @@ namespace elsa
std::vector<Geometry> geometryList;
real_t angleIncrement = static_cast<real_t>(1.0) * arcDegrees / (numberOfPoses - 1.0);
real_t angleIncrement = static_cast<real_t>(1.0f) * static_cast<real_t>(arcDegrees)
/ (static_cast<real_t>(numberOfPoses) - 1.0f);
for (index_t i = 0; i < numberOfPoses; ++i) {
real_t angle = i * angleIncrement * pi_t / 180.0; // convert to radians
real_t angle =
static_cast<real_t>(i) * angleIncrement * pi_t / 180.0f; // convert to radians
if (dim == 2) {
Geometry geom(sourceToCenter, centerToDetector, angle, volumeDescriptor,
sinoDescriptor);
......
......@@ -9,7 +9,7 @@ namespace elsa
{
template <typename data_t>
void EllipseGenerator<data_t>::drawFilledEllipse2d(DataContainer<data_t>& dc, data_t amplitude,
Vec2 center, Vec2 sizes, data_t angle)
Vec2 const& center, Vec2 sizes, data_t angle)
{
// sanity check
if (dc.getDataDescriptor().getNumberOfDimensions() != 2)
......@@ -21,7 +21,7 @@ namespace elsa
return;
// convert to radians
auto angleRad = angle * pi<double> / 180.0;
auto angleRad = angle * pi<double> / 180.0f;
// special case: circle or no rotation
if (sizes[0] == sizes[1] || std::fmod(angle, 180.0) == 0) {
......@@ -30,13 +30,15 @@ namespace elsa
}
// convert rotation by angle into shearing
data_t theta = std::atan2(-sizes[1] * std::tan(angleRad), sizes[0]);
auto theta = std::atan2(static_cast<real_t>(-sizes[1]) * std::tan(angleRad), sizes[0]);
Vec2 shear;
shear[0] = std::floor((sizes[0] * std::cos(theta) * std::cos(angleRad))
- (sizes[1] * std::sin(theta) * std::sin(angleRad)));
shear[1] = std::floor((sizes[0] * std::cos(theta) * std::sin(angleRad))
+ (sizes[1] * std::sin(theta) * std::cos(angleRad)));
shear[0] = static_cast<index_t>(
std::floor((static_cast<real_t>(sizes[0]) * std::cos(theta) * std::cos(angleRad))
- (static_cast<real_t>(sizes[1]) * std::sin(theta) * std::sin(angleRad))));
shear[1] = static_cast<index_t>(
std::floor((static_cast<real_t>(sizes[0]) * std::cos(theta) * std::sin(angleRad))
+ (static_cast<real_t>(sizes[1]) * std::sin(theta) * std::cos(angleRad))));
Vec2 shearedSizes;
shearedSizes[0] = std::abs(shear[0]);
......@@ -71,18 +73,18 @@ namespace elsa
auto sinPsi = std::sin(psiRad);
// setup ZXZ Euler rotation matrix
Eigen::Matrix<data_t, 3, 3> R;
R(0, 0) = cosPhi * cosPsi - cosTheta * sinPhi * sinPsi;
R(0, 1) = cosPsi * sinPhi + cosPhi * cosTheta * sinPsi;
R(0, 2) = sinTheta * sinPsi;
Eigen::Matrix<data_t, 3, 3> rot;
rot(0, 0) = static_cast<real_t>(cosPhi * cosPsi - cosTheta * sinPhi * sinPsi);
rot(0, 1) = static_cast<real_t>(cosPsi * sinPhi + cosPhi * cosTheta * sinPsi);
rot(0, 2) = static_cast<real_t>(sinTheta * sinPsi);
R(1, 0) = -cosPhi * sinPsi - cosTheta * cosPsi * sinPhi;
R(1, 1) = cosPhi * cosTheta * cosPsi - sinPhi * sinPsi;
R(1, 2) = cosPsi * sinTheta;
rot(1, 0) = static_cast<real_t>(-cosPhi * sinPsi - cosTheta * cosPsi * sinPhi);
rot(1, 1) = static_cast<real_t>(cosPhi * cosTheta * cosPsi - sinPhi * sinPsi);
rot(1, 2) = static_cast<real_t>(cosPsi * sinTheta);
R(2, 0) = sinPhi * sinTheta;
R(2, 1) = -cosPhi * sinTheta;
R(2, 2) = cosTheta;
rot(2, 0) = static_cast<real_t>(sinPhi * sinTheta);
rot(2, 1) = static_cast<real_t>(-cosPhi * sinTheta);
rot(2, 2) = static_cast<real_t>(cosTheta);
// enables safe early abort
index_t maxSize = sizes.maxCoeff();
......@@ -120,14 +122,23 @@ namespace elsa
index_t zc = z - center[2];
// check ellipsoid equation
data_t aPart = (hasRotation) ? xc * R(0, 0) + yc * R(0, 1) + zc * R(0, 2) : xc;
aPart *= aPart / asq;
data_t bPart = (hasRotation) ? xc * R(1, 0) + yc * R(1, 1) + zc * R(1, 2) : yc;
bPart *= bPart / bsq;
data_t cPart = (hasRotation) ? xc * R(2, 0) + yc * R(2, 1) + zc * R(2, 2) : zc;
cPart *= cPart / csq;
data_t aPart = (hasRotation) ? static_cast<data_t>(xc) * rot(0, 0)
+ static_cast<data_t>(yc) * rot(0, 1)
+ static_cast<data_t>(zc) * rot(0, 2)
: static_cast<data_t>(xc);
aPart *= aPart / static_cast<data_t>(asq);
data_t bPart = (hasRotation) ? static_cast<data_t>(xc) * rot(1, 0)
+ static_cast<data_t>(yc) * rot(1, 1)
+ static_cast<data_t>(zc) * rot(1, 2)
: static_cast<data_t>(yc);
bPart *= bPart / static_cast<data_t>(bsq);
data_t cPart = (hasRotation) ? static_cast<data_t>(xc) * rot(2, 0)
+ static_cast<data_t>(yc) * rot(2, 1)
+ static_cast<data_t>(zc) * rot(2, 2)
: static_cast<data_t>(zc);
cPart *= cPart / static_cast<data_t>(csq);
if (aPart + bPart + cPart <= 1.0)
dc(idx) += amplitude;
......@@ -138,15 +149,15 @@ namespace elsa
template <typename data_t>
void EllipseGenerator<data_t>::drawShearedFilledEllipse2d(DataContainer<data_t>& dc,
data_t amplitude, Vec2 center,
Vec2 sizes, Vec2 shear)
data_t amplitude, Vec2 const& center,
Vec2 sizes, Vec2 const& shear)
{
auto twoSizeXSquared = 2 * sizes[0] * sizes[0];
auto twoSizeYSquared = 2 * sizes[1] * sizes[1];
// setup first ellipse part where major axis of "advance" is the y axis
auto x = sizes[0];
auto y = 0;
index_t y = 0;
auto xChange = sizes[1] * sizes[1] * (1 - 2 * sizes[0]);
auto yChange = sizes[0] * sizes[0];
......
......@@ -32,8 +32,8 @@ namespace elsa
* \param[in] sizes the radii (horizontal/vertical) of the ellipse
* \param[in] angle rotation angle of the ellipse in degrees (with respect to y axis)
*/
static void drawFilledEllipse2d(DataContainer<data_t>& dc, data_t amplitude, Vec2 center,
Vec2 sizes, data_t angle);
static void drawFilledEllipse2d(DataContainer<data_t>& dc, data_t amplitude,
Vec2 const& center, Vec2 sizes, data_t angle);
/**
* \brief Draw a rotated, filled 3d ellipsoid
......@@ -66,7 +66,7 @@ namespace elsa
* For Drawing Ellipses".
*/
static void drawShearedFilledEllipse2d(DataContainer<data_t>& dc, data_t amplitude,
Vec2 center, Vec2 sizes, Vec2 shear);
Vec2 const& center, Vec2 sizes, Vec2 const& shear);
/**
* \brief draw sheared 2d line pairs for ellipses
......
......@@ -30,67 +30,67 @@ namespace elsa
if (sizes.size() == 2) {
EllipseGenerator<data_t>::drawFilledEllipse2d(dc, 1.0,
{scaleShift(dd, 0), scaleShift(dd, 0)},
{scale(dd, 0.69), scale(dd, 0.92)}, 0);
{scale(dd, 0.69f), scale(dd, 0.92f)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, -0.8, {scaleShift(dd, 0), scaleShift(dd, -0.0184)},
{scale(dd, 0.6624), scale(dd, 0.8740)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(dc, -0.2,
{scaleShift(dd, 0.22), scaleShift(dd, 0)},
{scale(dd, 0.11), scale(dd, 0.31)}, -18);
dc, -0.8f, {scaleShift(dd, 0), scaleShift(dd, -0.0184f)},
{scale(dd, 0.6624f), scale(dd, 0.8740f)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, -0.2, {scaleShift(dd, -0.22), scaleShift(dd, 0)},
{scale(dd, 0.16), scale(dd, 0.41)}, 18);
EllipseGenerator<data_t>::drawFilledEllipse2d(dc, 0.1,
{scaleShift(dd, 0), scaleShift(dd, 0.35)},
{scale(dd, 0.21), scale(dd, 0.25)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(dc, 0.1,
{scaleShift(dd, 0), scaleShift(dd, 0.1)},
{scale(dd, 0.046), scale(dd, 0.046)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(dc, 0.1,
{scaleShift(dd, 0), scaleShift(dd, -0.1)},
{scale(dd, 0.046), scale(dd, 0.046)}, 0);
dc, -0.2f, {scaleShift(dd, 0.22f), scaleShift(dd, 0)},
{scale(dd, 0.11f), scale(dd, 0.31f)}, -18);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1, {scaleShift(dd, -0.08), scaleShift(dd, -0.605)},
{scale(dd, 0.046), scale(dd, 0.023)}, 0);
dc, -0.2f, {scaleShift(dd, -0.22f), scaleShift(dd, 0)},
{scale(dd, 0.16f), scale(dd, 0.41f)}, 18);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1, {scaleShift(dd, 0), scaleShift(dd, -0.606)},
{scale(dd, 0.023), scale(dd, 0.023)}, 0);
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, 0.35f)},
{scale(dd, 0.21f), scale(dd, 0.25)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1, {scaleShift(dd, 0.06), scaleShift(dd, -0.605)},
{scale(dd, 0.023), scale(dd, 0.046)}, 0);
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, 0.1f)},
{scale(dd, 0.046f), scale(dd, 0.046f)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, -0.1f)},
{scale(dd, 0.046f), scale(dd, 0.046f)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1f, {scaleShift(dd, -0.08f), scaleShift(dd, -0.605f)},
{scale(dd, 0.046f), scale(dd, 0.023f)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, -0.606f)},
{scale(dd, 0.023f), scale(dd, 0.023f)}, 0);
EllipseGenerator<data_t>::drawFilledEllipse2d(
dc, 0.1f, {scaleShift(dd, 0.06f), scaleShift(dd, -0.605f)},
{scale(dd, 0.023f), scale(dd, 0.046f)}, 0);
}
if (sizes.size() == 3) {
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 1.0, {scaleShift(dd, 0), scaleShift(dd, 0), scaleShift(dd, 0)},
{scale(dd, 0.69), scale(dd, 0.92), scale(dd, 0.81)}, 0, 0, 0);
{scale(dd, 0.69f), scale(dd, 0.92f), scale(dd, 0.81f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, -0.8, {scaleShift(dd, 0), scaleShift(dd, -0.0184), scaleShift(dd, 0)},
{scale(dd, 0.6624), scale(dd, 0.874), scale(dd, 0.78)}, 0, 0, 0);
dc, -0.8f, {scaleShift(dd, 0), scaleShift(dd, -0.0184f), scaleShift(dd, 0)},
{scale(dd, 0.6624f), scale(dd, 0.874f), scale(dd, 0.78f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, -0.2, {scaleShift(dd, 0.22), scaleShift(dd, 0), scaleShift(dd, 0)},
{scale(dd, 0.11), scale(dd, 0.31), scale(dd, 0.22)}, -18, 0, 10);
dc, -0.2f, {scaleShift(dd, 0.22f), scaleShift(dd, 0), scaleShift(dd, 0)},
{scale(dd, 0.11f), scale(dd, 0.31f), scale(dd, 0.22f)}, -18, 0, 10);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, -0.2, {scaleShift(dd, -0.22), scaleShift(dd, 0), scaleShift(dd, 0)},
{scale(dd, 0.16), scale(dd, 0.41), scale(dd, 0.28)}, 18, 0, 10);
dc, -0.2f, {scaleShift(dd, -0.22f), scaleShift(dd, 0), scaleShift(dd, 0)},
{scale(dd, 0.16f), scale(dd, 0.41f), scale(dd, 0.28f)}, 18, 0, 10);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 0.1, {scaleShift(dd, 0), scaleShift(dd, 0.35), scaleShift(dd, -0.15)},
{scale(dd, 0.21), scale(dd, 0.25), scale(dd, 0.41)}, 0, 0, 0);
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, 0.35f), scaleShift(dd, -0.15f)},
{scale(dd, 0.21f), scale(dd, 0.25f), scale(dd, 0.41f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 0.1, {scaleShift(dd, 0), scaleShift(dd, 0.1), scaleShift(dd, 0.25)},
{scale(dd, 0.046), scale(dd, 0.046), scale(dd, 0.05)}, 0, 0, 0);
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, 0.1f), scaleShift(dd, 0.25f)},
{scale(dd, 0.046f), scale(dd, 0.046f), scale(dd, 0.05f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 0.1, {scaleShift(dd, 0), scaleShift(dd, -0.1), scaleShift(dd, 0.25)},
{scale(dd, 0.046), scale(dd, 0.046), scale(dd, 0.05)}, 0, 0, 0);
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, -0.1f), scaleShift(dd, 0.25f)},
{scale(dd, 0.046f), scale(dd, 0.046f), scale(dd, 0.05f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 0.1, {scaleShift(dd, -0.08), scaleShift(dd, -0.605), scaleShift(dd, 0)},
{scale(dd, 0.046), scale(dd, 0.023), scale(dd, 0.05)}, 0, 0, 0);
dc, 0.1f, {scaleShift(dd, -0.08f), scaleShift(dd, -0.605f), scaleShift(dd, 0)},
{scale(dd, 0.046f), scale(dd, 0.023f), scale(dd, 0.05f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 0.1, {scaleShift(dd, 0), scaleShift(dd, -0.606), scaleShift(dd, 0)},
{scale(dd, 0.023), scale(dd, 0.023), scale(dd, 0.02)}, 0, 0, 0);
dc, 0.1f, {scaleShift(dd, 0), scaleShift(dd, -0.606f), scaleShift(dd, 0)},
{scale(dd, 0.023f), scale(dd, 0.023f), scale(dd, 0.02f)}, 0, 0, 0);
EllipseGenerator<data_t>::drawFilledEllipsoid3d(
dc, 0.1, {scaleShift(dd, 0.06), scaleShift(dd, -0.605), scaleShift(dd, 0)},
{scale(dd, 0.023), scale(dd, 0.046), scale(dd, 0.02)}, 0, 0, 0);
dc, 0.1f, {scaleShift(dd, 0.06f), scaleShift(dd, -0.605f), scaleShift(dd, 0)},
{scale(dd, 0.023f), scale(dd, 0.046f), scale(dd, 0.02f)}, 0, 0, 0);
}
return dc;
......@@ -99,13 +99,16 @@ namespace elsa
template <typename data_t>
index_t PhantomGenerator<data_t>::scale(const DataDescriptor& dd, data_t value)
{
return std::lround(value * (dd.getNumberOfCoefficientsPerDimension()[0] - 1) / 2.0f);
return std::lround(
value * static_cast<data_t>(dd.getNumberOfCoefficientsPerDimension()[0] - 1) / 2.0f);
}
template <typename data_t>
index_t PhantomGenerator<data_t>::scaleShift(const DataDescriptor& dd, data_t value)
{
return std::lround(value * (dd.getNumberOfCoefficientsPerDimension()[0] - 1) / 2.0f)
return std::lround(value
* static_cast<data_t>(dd.getNumberOfCoefficientsPerDimension()[0] - 1)
/ 2.0f)
+ (dd.getNumberOfCoefficientsPerDimension()[0] / 2);
}
......
......@@ -29,8 +29,8 @@ SCENARIO("Create a Circular Trajectory")
WHEN("We create a half circular trajectory for this scenario")
{
index_t halfCircular = 180;
index_t diffCenterSource = s * 100;
index_t diffCenterDetector = s;
auto diffCenterSource = static_cast<real_t>(s * 100);
auto diffCenterDetector = static_cast<real_t>(s);
auto [geomList, sdesc] = CircleTrajectoryGenerator::createTrajectory(
numberOfAngles, desc, halfCircular, diffCenterSource, diffCenterDetector);
......@@ -41,9 +41,10 @@ SCENARIO("Create a Circular Trajectory")
const real_t sourceToCenter = diffCenterSource;
const real_t centerToDetector = diffCenterDetector;
real_t angle = (1.0f / (numberOfAngles - 1)) * halfCircular;
real_t angle = static_cast<real_t>(1.0) * static_cast<real_t>(halfCircular)
/ real_t(numberOfAngles - 1);
for (int i = 0; i < numberOfAngles; ++i) {
real_t currAngle = i * angle * pi_t / 180.0f;
real_t currAngle = static_cast<real_t>(i) * angle * pi_t / 180.0f;
Geometry tmpGeom(sourceToCenter, centerToDetector, currAngle, desc, *sdesc);
REQUIRE((tmpGeom.getCameraCenter() - geomList[i].getCameraCenter()).norm()
......@@ -62,8 +63,8 @@ SCENARIO("Create a Circular Trajectory")
WHEN("We create a full circular trajectory for this scenario")
{
index_t halfCircular = 359;
index_t diffCenterSource = s * 100;
index_t diffCenterDetector = s;
auto diffCenterSource = static_cast<real_t>(s * 100);
auto diffCenterDetector = static_cast<real_t>(s);
auto [geomList, sdesc] = CircleTrajectoryGenerator::createTrajectory(
numberOfAngles, desc, halfCircular, diffCenterSource, diffCenterDetector);
......@@ -74,9 +75,10 @@ SCENARIO("Create a Circular Trajectory")
const real_t sourceToCenter = diffCenterSource;
const real_t centerToDetector = diffCenterDetector;
real_t angle = (1.0 / (numberOfAngles - 1)) * halfCircular;
real_t angle = static_cast<real_t>(1.0) * static_cast<real_t>(halfCircular)
/ static_cast<real_t>(numberOfAngles - 1);
for (int i = 0; i < numberOfAngles; ++i) {
real_t currAngle = i * angle * pi_t / 180.0;
real_t currAngle = static_cast<real_t>(i) * angle * pi_t / 180.0f;
Geometry tmpGeom(sourceToCenter, centerToDetector, currAngle, desc, *sdesc);
REQUIRE((tmpGeom.getCameraCenter() - geomList[i].getCameraCenter()).norm()
......@@ -103,8 +105,8 @@ SCENARIO("Create a Circular Trajectory")
WHEN("We create a half circular trajectory for this scenario")
{
index_t halfCircular = 180;
index_t diffCenterSource = s * 100;
index_t diffCenterDetector = s;
auto diffCenterSource = static_cast<real_t>(s * 100);
auto diffCenterDetector = static_cast<real_t>(s);
auto [geomList, sdesc] = CircleTrajectoryGenerator::createTrajectory(
numberOfAngles, desc, halfCircular, diffCenterSource, diffCenterDetector);
......@@ -115,9 +117,10 @@ SCENARIO("Create a Circular Trajectory")
const real_t sourceToCenter = diffCenterSource;
const real_t centerToDetector = diffCenterDetector;
real_t angleInc = 1.0 * halfCircular / (numberOfAngles - 1);
real_t angleInc = 1.0f * static_cast<real_t>(halfCircular)
/ static_cast<real_t>(numberOfAngles - 1);
for (int i = 0; i < numberOfAngles; ++i) {
real_t angle = i * angleInc * pi_t / 180.0;
real_t angle = static_cast<real_t>(i) * angleInc * pi_t / 180.0f;
Geometry tmpGeom(sourceToCenter, centerToDetector, desc, *sdesc, angle);
REQUIRE((tmpGeom.getCameraCenter() - geomList[i].getCameraCenter()).norm()
......@@ -136,8 +139,8 @@ SCENARIO("Create a Circular Trajectory")
WHEN("We create a full circular trajectory for this scenario")
{
index_t halfCircular = 359;
index_t diffCenterSource = s * 100;
index_t diffCenterDetector = s;
auto diffCenterSource = static_cast<real_t>(s * 100);
auto diffCenterDetector = static_cast<real_t>(s);
auto [geomList, sdesc] = CircleTrajectoryGenerator::createTrajectory(
numberOfAngles, desc, halfCircular, diffCenterSource, diffCenterDetector);
......@@ -148,9 +151,10 @@ SCENARIO("Create a Circular Trajectory")
const real_t sourceToCenter = diffCenterSource;
const real_t centerToDetector = diffCenterDetector;
real_t angleInc = 1.0 * halfCircular / (numberOfAngles - 1);
real_t angleInc = 1.0f * static_cast<real_t>(halfCircular)
/ static_cast<real_t>(numberOfAngles - 1);
for (int i = 0; i < numberOfAngles; ++i) {
real_t angle = i * angleInc * pi_t / 180.0;
real_t angle = static_cast<real_t>(i) * angleInc * pi_t / 180.0f;
Geometry tmpGeom(sourceToCenter, centerToDetector, desc, *sdesc, angle);
REQUIRE((tmpGeom.getCameraCenter() - geomList[i].getCameraCenter()).norm()
......
......@@ -11,7 +11,7 @@
using namespace elsa;
static constexpr auto pi_d = pi<double>;
static constexpr auto pi_d = pi<real_t>;
SCENARIO("Drawing a rotated filled ellipse in 2d")
{
......@@ -30,8 +30,8 @@ SCENARIO("Drawing a rotated filled ellipse in 2d")
THEN("the ellipse mostly matches the efficient one")
{
// check a few rotation angles
for (real_t angleDeg : {0, 18, 30, 45, 60, 72, 90}) {
real_t angleRad = angleDeg * pi_d / 180.0;
for (real_t angleDeg : {0.0f, 18.0f, 30.0f, 45.0f, 60.0f, 72.0f, 90.0f}) {
real_t angleRad = angleDeg * pi_d / 180.0f;
dc = 0;
EllipseGenerator<real_t>::drawFilledEllipse2d(dc, 1.0, center, sizes, angleDeg);
......@@ -40,15 +40,17 @@ SCENARIO("Drawing a rotated filled ellipse in 2d")
for (index_t x = 0; x < numCoeff[0]; ++x) {
for (index_t y = 0; y < numCoeff[1]; ++y) {
real_t aPart = (x - center[0]) * std::cos(angleRad)
+ (y - center[1]) * std::sin(angleRad);
real_t aPart =
static_cast<real_t>(x - center[0]) * std::cos(angleRad)
+ static_cast<real_t>(y - center[1]) * std::sin(angleRad);
aPart *= aPart;
aPart /= sizes[0] * sizes[0];
aPart /= static_cast<real_t>(sizes[0] * sizes[0]);
real_t bPart = -(x - center[0]) * std::sin(angleRad)
+ (y - center[1]) * std::cos(angleRad);
real_t bPart =
-static_cast<real_t>(x - center[0]) * std::sin(angleRad)
+ static_cast<real_t>(y - center[1]) * std::cos(angleRad);
bPart *= bPart;
bPart /= sizes[1] * sizes[1];
bPart /= static_cast<real_t>(sizes[1] * sizes[1]);
IndexVector_t coord(2);
coord[0] = x;
......@@ -63,8 +65,9 @@ SCENARIO("Drawing a rotated filled ellipse in 2d")
}
}
}
REQUIRE((static_cast<real_t>(wrongPixelCounter) / sizes.prod())
< 0.11); // 11% isn't great... :(
REQUIRE(
(static_cast<real_t>(wrongPixelCounter) / static_cast<real_t>(sizes.prod()))
< 0.11); // 11% isn't great... :(
}
}
}
......
......@@ -3,6 +3,7 @@
#include "TraverseAABB.h"
#include <stdexcept>
#include <type_traits>
namespace elsa
{
......@@ -115,7 +116,8 @@ namespace elsa
auto detectorCoord = _rangeDescriptor->getCoordinateFromIndex(detectorIndex);
// center of detector pixel is 0.5 units away from the corresponding detector coordinates
auto geometry = _geometryList.at(detectorCoord(dimension - 1));
auto geometry =
_geometryList.at(std::make_unsigned_t<index_t>(detectorCoord(dimension - 1)));
auto [ro, rd] = geometry.computeRayTo(
detectorCoord.block(0, 0, dimension - 1, 1).template cast<real_t>().array() + 0.5);
......
......@@ -3,6 +3,7 @@
#include "TraverseAABBJosephsMethod.h"
#include <stdexcept>
#include <type_traits>
namespace elsa
{
......@@ -142,7 +143,8 @@ namespace elsa
auto detectorCoord = _rangeDescriptor->getCoordinateFromIndex(detectorIndex);
// center of detector pixel is 0.5 units away from the corresponding detector coordinates
auto geometry = _geometryList.at(detectorCoord(dimension - 1));
auto geometry =
_geometryList.at(std::make_unsigned_t<index_t>(detectorCoord(dimension - 1)));
auto [ro, rd] = geometry.computeRayTo(
detectorCoord.block(0, 0, dimension - 1, 1).template cast<real_t>().array() + 0.5);
......
......@@ -3,6 +3,7 @@
#include "TraverseAABB.h"
#include <stdexcept>
#include <type_traits>
namespace elsa
{
......@@ -119,7 +120,8 @@ namespace elsa
auto detectorCoord = _rangeDescriptor->getCoordinateFromIndex(detectorIndex);
// center of detector pixel is 0.5 units away from the corresponding detector coordinates
auto geometry = _geometryList.at(detectorCoord(dimension - 1));
auto geometry =
_geometryList.at(std::make_unsigned_t<index_t>(detectorCoord(dimension - 1)));
auto [ro, rd] = geometry.computeRayTo(
detectorCoord.block(0, 0, dimension - 1, 1).template cast<real_t>().array() + 0.5);
......
This diff is collapsed.
......@@ -61,11 +61,11 @@ namespace elsa
const std::vector<Geometry>& geometryList, bool fast = true);
/// destructor
virtual ~JosephsMethodCUDA();
~JosephsMethodCUDA() override;
protected:
/// default copy constructor, hidden from non-derived classes to prevent potential slicing
JosephsMethodCUDA(const JosephsMethodCUDA<data_t>&) = default;
/// copy constructor, used for cloning
JosephsMethodCUDA(const JosephsMethodCUDA<data_t>& other);
/// apply Joseph's method (i.e. forward projection)
void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override;
......@@ -88,7 +88,8 @@ namespace elsa
std::vector<Geometry> _geometryList;
/// threads per block used in the kernel execution configuration
const int _threadsPerBlock = TraverseJosephsCUDA<data_t>::MAX_THREADS_PER_BLOCK;
static const unsigned int THREADS_PER_BLOCK =
TraverseJosephsCUDA<data_t>::MAX_THREADS_PER_BLOCK;
/// flag specifying which version of the backward projection should be used
const bool _fast;
......
This diff is collapsed.
......@@ -52,7 +52,7 @@ namespace elsa
const std::vector<Geometry>& geometryList);
/// destructor
~SiddonsMethodCUDA();
~SiddonsMethodCUDA() override;
protected:
/// default copy constructor, hidden from non-derived classes to prevent potential slicing
......@@ -79,7 +79,8 @@ namespace elsa
std::vector<Geometry> _geometryList;
/// threads per block used in the kernel execution configuration
const int _threadsPerBlock = TraverseSiddonsCUDA<data_t>::MAX_THREADS_PER_BLOCK;
static const unsigned int THREADS_PER_BLOCK =
TraverseSiddonsCUDA<data_t>::MAX_THREADS_PER_BLOCK;
/// inverse of of projection matrices; stored column-wise on GPU
cudaPitchedPtr _projInvMatrices;
......
......@@ -58,6 +58,9 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE)
list(SORT OUT_VARIABLE)
endfunction()
# make sure host compiler used by NVCC is the one used for the rest of the project
set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}")
set(CUDA_ARCH_TYPES "Auto" CACHE STRING "Space-separated list of target GPU architectures. Defaults to Auto. If Auto attempts to detect and target all installed GPUS.")
if ("${CUDA_ARCH_TYPES}" STREQUAL "Auto")
......@@ -76,6 +79,10 @@ foreach(TARGET_GPU ${TARGET_GPUS})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --generate-code arch=compute_${TARGET_GPU},code=[sm_${TARGET_GPU},compute_${TARGET_GPU}]")
endforeach()
if (ELSA_BUILD_WITH_MORE_WARNINGS)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wreorder -Xptxas=-warn-spills,-warn-lmem-usage")
endif()
# set the name of the module
set(ELSA_MODULE_NAME projector_kernels)
set(ELSA_MODULE_TARGET_NAME elsa_${ELSA_MODULE_NAME})
......@@ -95,7 +102,7 @@ set(MODULE_SOURCES
add_library(${ELSA_MODULE_TARGET_NAME} ${MODULE_HEADERS} ${MODULE_SOURCES})
add_library(elsa::${ELSA_MODULE_NAME} ALIAS ${ELSA_MODULE_TARGET_NAME})
# CUDA doesn't support C++17, require C++14
#CUDA doesn't support C++17, require C++14
set_target_properties(${ELSA_MODULE_TARGET_NAME} PROPERTIES CUDA_STANDARD 14 POSITION_INDEPENDENT_CODE ON)
# CUDA doesn't support linking against a library built under the C++17 standard,
......
......@@ -8,7 +8,7 @@
*/
#pragma once
#include <stdint.h>
#include <cstdint>
#include <cuda_runtime.h>
......@@ -17,9 +17,9 @@
namespace elsa
{
template <typename data_t = elsa::real_t, uint dim = 3>
template <typename data_t = real_t, uint dim = 3>
struct TraverseJosephsCUDA {
const static uint32_t MAX_THREADS_PER_BLOCK = 32;
constexpr static uint32_t MAX_THREADS_PER_BLOCK = 32;
/**
* Allows for the bounding box to be passed to the kernel by value.
......@@ -29,53 +29,45 @@ namespace elsa
struct BoundingBox {
// min is always 0
real_t max[dim];