Commit 85607121 authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[types] Adapted Bounds and Shape to CUDA device side use

parent 0d258483
......@@ -4,6 +4,8 @@
#include <iostream>
#include <array>
#include <rtac_base/cuda_defines.h>
namespace rtac { namespace types {
template <typename T>
......@@ -11,11 +13,22 @@ struct Interval {
T min;
T max;
T length() const {
RTAC_HOSTDEVICE T length() const {
return this->max - this->min;
}
RTAC_HOSTDEVICE bool is_inside(T value) const {
return min < value && value < max;
}
};
}; //namespace types
}; //namespace rtac
#ifndef RTAC_CUDACC
namespace rtac { namespace types {
template <typename T, std::size_t N>
using Bounds = std::array<Interval<T>, N>;
......@@ -38,4 +51,6 @@ std::ostream& operator<<(std::ostream& os, const rtac::types::Bounds<T,N>& bound
return os;
}
#endif //RTAC_CUDACC
#endif //_DEF_RTAC_BASE_TYPES_BOUNDS_H_
#ifndef _DEF_RTAC_BASE_TYPES_SHAPE_H_
#define _DEF_RTAC_BASE_TYPES_SHAPE_H_
#include <iostream>
#include <rtac_base/cuda_defines.h>
namespace rtac { namespace types {
......@@ -19,7 +19,7 @@ struct Shape
T height;
template <typename RatioType = T>
RatioType ratio() const
RTAC_HOSTDEVICE RatioType ratio() const
{
return ((RatioType)width / height);
}
......@@ -30,7 +30,7 @@ struct Shape
}
template <typename SizeType = T>
SizeType size() const
RTAC_HOSTDEVICE SizeType size() const
{
return width * height;
}
......@@ -39,11 +39,15 @@ struct Shape
}; //namespace types
}; //namespace rtac
#ifndef RTAC_CUDACC
#include <iostream>
template <typename T>
std::ostream& operator<<(std::ostream& os, const rtac::types::Shape<T>& shape)
{
os << "width : " << shape.width << ", height : " << shape.height;
return os;
}
#endif //RTAC_CUDACC
#endif //_DEF_RTAC_BASE_TYPES_SHAPE_H_
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