Commit d09e516b authored by David Frank's avatar David Frank
Browse files

Add some constexpr functions

parent fc3598f3
......@@ -141,11 +141,11 @@ namespace elsa
return blobs::blob_projected(s, radius_, alpha_, order_);
}
data_t radius() const { return radius_; }
constexpr data_t radius() const { return radius_; }
data_t alpha() const { return alpha_; }
constexpr data_t alpha() const { return alpha_; }
int order() const { return order_; }
constexpr int order() const { return order_; }
private:
data_t radius_;
......
......@@ -82,11 +82,11 @@ namespace elsa
// Expand bounding box as rays have larger support now
auto aabb = _boundingBox;
aabb._min.array() -= support;
aabb._min[leadingdir] += support;
aabb._min.array() -= static_cast<real_t>(support);
aabb._min[leadingdir] += static_cast<real_t>(support);
aabb._max.array() += support;
aabb._max[leadingdir] -= support;
aabb._max.array() += static_cast<real_t>(support);
aabb._max[leadingdir] -= static_cast<real_t>(support);
// --> setup traversal algorithm
SliceTraversal traversal(aabb, ray);
......@@ -135,11 +135,11 @@ namespace elsa
// Expand bounding box as rays have larger support now
auto aabb = _boundingBox;
aabb._min.array() -= support;
aabb._min[leadingdir] += support;
aabb._min.array() -= static_cast<real_t>(support);
aabb._min[leadingdir] += static_cast<real_t>(support);
aabb._max.array() += support;
aabb._max[leadingdir] -= support;
aabb._max.array() += static_cast<real_t>(support);
aabb._max[leadingdir] -= static_cast<real_t>(support);
// --> setup traversal algorithm
SliceTraversal traversal(aabb, ray);
......
......@@ -2,6 +2,7 @@
#include "Blobs.h"
#include "Logger.h"
#include "Timer.h"
#include <array>
......@@ -12,6 +13,8 @@ namespace elsa
template <typename data_t, index_t N>
constexpr std::array<data_t, N> blob_lut(ProjectedBlob<data_t> blob)
{
Logger::get("blob_lut")->debug("Calculating lut");
std::array<data_t, N> lut;
auto t = static_cast<data_t>(0);
......@@ -47,10 +50,10 @@ namespace elsa
class Lut
{
public:
Lut(std::array<data_t, N> data) : data_(std::move(data)) {}
constexpr Lut(std::array<data_t, N> data) : data_(std::move(data)) {}
template <typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
data_t operator()(T index) const
constexpr data_t operator()(T index) const
{
if (index < 0 || index > N) {
return 0;
......@@ -63,7 +66,7 @@ namespace elsa
/// lerp(last, last+1, t), for some t > 0, yields f(last) / 2, as f(last + 1) = 0,
/// this should be handled
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
data_t operator()(T index) const
constexpr data_t operator()(T index) const
{
if (index < 0 || index > N) {
return 0;
......@@ -101,13 +104,16 @@ namespace elsa
{
}
data_t radius() const { return blob_.radius(); }
constexpr data_t radius() const { return blob_.radius(); }
data_t alpha() const { return blob_.alpha(); }
constexpr data_t alpha() const { return blob_.alpha(); }
data_t order() const { return blob_.order(); }
constexpr data_t order() const { return blob_.order(); }
data_t operator()(data_t distance) const { return lut_((distance / blob_.radius()) * N); }
constexpr data_t operator()(data_t distance) const
{
return lut_((distance / blob_.radius()) * N);
}
private:
ProjectedBlob<data_t> blob_;
......
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