feat: Implement CUDA support for VoxRaytracer, add CUDA tests for voxel image operations, and update CMake to enable CUDA compilation.
This commit is contained in:
@@ -23,8 +23,6 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#ifndef VOXRAYTRACER_H
|
||||
#define VOXRAYTRACER_H
|
||||
|
||||
@@ -32,62 +30,74 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Math/StructuredGrid.h"
|
||||
#include "Math/VoxImage.h"
|
||||
|
||||
#ifdef USE_CUDA
|
||||
#include <cuda_runtime.h>
|
||||
#endif
|
||||
|
||||
namespace uLib {
|
||||
|
||||
class VoxRaytracer {
|
||||
|
||||
public:
|
||||
class RayData {
|
||||
public:
|
||||
RayData() : m_TotalLength(0) {}
|
||||
class RayData {
|
||||
public:
|
||||
RayData() : m_TotalLength(0) {}
|
||||
|
||||
typedef struct {
|
||||
Id_t vox_id;
|
||||
Scalarf L;
|
||||
} Element;
|
||||
|
||||
inline void AddElement(Id_t id, float L);
|
||||
|
||||
void AppendRay ( const RayData &in);
|
||||
|
||||
inline const std::vector<Element>& Data() const { return this->m_Data; }
|
||||
|
||||
inline const Scalarf& TotalLength() const { return this->m_TotalLength; }
|
||||
|
||||
void PrintSelf(std::ostream &o);
|
||||
|
||||
private:
|
||||
std::vector<Element> m_Data;
|
||||
Scalarf m_TotalLength;
|
||||
struct Element {
|
||||
Id_t vox_id;
|
||||
Scalarf L;
|
||||
~Element() {}
|
||||
};
|
||||
|
||||
inline void AddElement(Id_t id, float L);
|
||||
|
||||
public:
|
||||
VoxRaytracer(StructuredGrid &image) : m_Image(&image) {
|
||||
m_scale <<
|
||||
(m_Image->GetWorldMatrix() * Vector4f(1,0,0,0)).norm(),
|
||||
(m_Image->GetWorldMatrix() * Vector4f(0,1,0,0)).norm(),
|
||||
(m_Image->GetWorldMatrix() * Vector4f(0,0,1,0)).norm();
|
||||
}
|
||||
void AppendRay(const RayData &in);
|
||||
|
||||
bool GetEntryPoint(const HLine3f &line, HPoint3f &pt);
|
||||
inline const std::vector<Element> &Data() const { return this->m_Data; }
|
||||
|
||||
bool GetExitPoint(const HLine3f &line, HPoint3f &pt);
|
||||
inline const Scalarf &TotalLength() const { return this->m_TotalLength; }
|
||||
|
||||
RayData TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const;
|
||||
void PrintSelf(std::ostream &o);
|
||||
|
||||
RayData TraceLine(const HLine3f &line) const;
|
||||
private:
|
||||
std::vector<Element> m_Data;
|
||||
Scalarf m_TotalLength;
|
||||
};
|
||||
|
||||
inline StructuredGrid* GetImage() const { return this->m_Image; }
|
||||
public:
|
||||
VoxRaytracer(StructuredGrid &image) : m_Image(&image) {
|
||||
m_scale << (m_Image->GetWorldMatrix() * Vector4f(1, 0, 0, 0)).norm(),
|
||||
(m_Image->GetWorldMatrix() * Vector4f(0, 1, 0, 0)).norm(),
|
||||
(m_Image->GetWorldMatrix() * Vector4f(0, 0, 1, 0)).norm();
|
||||
}
|
||||
|
||||
bool GetEntryPoint(const HLine3f &line, HPoint3f &pt);
|
||||
|
||||
bool GetExitPoint(const HLine3f &line, HPoint3f &pt);
|
||||
|
||||
RayData TraceBetweenPoints(const HPoint3f &in, const HPoint3f &out) const;
|
||||
|
||||
RayData TraceLine(const HLine3f &line) const;
|
||||
|
||||
inline StructuredGrid *GetImage() const { return this->m_Image; }
|
||||
|
||||
#ifdef USE_CUDA
|
||||
template <typename VoxelT>
|
||||
void AccumulateLinesCUDA(const HLine3f *lines, size_t num_lines,
|
||||
VoxImage<VoxelT> &image);
|
||||
#endif
|
||||
|
||||
private:
|
||||
StructuredGrid *m_Image;
|
||||
Vector3f m_scale;
|
||||
StructuredGrid *m_Image;
|
||||
Vector3f m_scale;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace uLib
|
||||
|
||||
#ifdef USE_CUDA
|
||||
#include "Math/VoxRaytracerCUDA.hpp"
|
||||
#endif
|
||||
|
||||
#endif // VOXRAYTRACER_H
|
||||
|
||||
Reference in New Issue
Block a user