Skip to content
Snippets Groups Projects
Commit 46e4e9f8 authored by BATON Theau's avatar BATON Theau
Browse files

CurveTools Refactoring

parent d9095f70
No related branches found
No related tags found
No related merge requests found
Showing
with 88 additions and 74 deletions
......@@ -60,8 +60,8 @@ project(${PROJECT_NAME} LANGUAGES CXX CUDA)
set(CURRENT_TARGET ${LIBRARY_NAME})
#add_library(${CURRENT_TARGET})
add_executable(${CURRENT_TARGET})
add_library(${CURRENT_TARGET})
#add_executable(${CURRENT_TARGET})
target_include_directories(${CURRENT_TARGET} PUBLIC ${INCLUDE_DIRECTORY})
......
......@@ -2,16 +2,15 @@
#include "CurveGenerator.hpp"
namespace ct
{
class CURVETOOLS_API BSplineGenerator : public CurveGenerator
{
namespace ct {
class CURVETOOLS_API BSplineGenerator : public CurveGenerator {
private:
CurveGenerator* m_generator;
public:
BSplineGenerator(CurveGenerator* generator);
Point operator()(const Curve& points, double u) const override;
Point generate(const Curve& points, double u) const override;
std::vector<Point> generate(const Curve& points, const std::vector<double> & us) const override;
};
}
\ No newline at end of file
......@@ -2,13 +2,12 @@
#include "CurveGenerator.hpp"
namespace ct
{
class CURVETOOLS_API BezierGenerator : public CurveGenerator
{
namespace ct {
class CURVETOOLS_API BezierGenerator : public CurveGenerator {
public:
BezierGenerator(unsigned int degree = 3);
BezierGenerator(unsigned int degree = 1);
Point operator()(const Curve& points, double t) const override;
Point generate(const Curve& points, double t) const override;
std::vector<Point> generate(const Curve&, const std::vector<double> &) const override;
};
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ namespace ct
public:
CatmullRomGenerator();
Point operator()(const Curve& points, double t) const override;
Point generate(const Curve& points, double t) const override;
std::vector<Point> generate(const Curve& points, const std::vector<double> & us) const override;
};
}
\ No newline at end of file
#pragma once
#include "Export.hpp"
#include "../Generator.hpp"
#include <glm/glm.hpp>
#include <vector>
namespace ct
{
namespace ct {
using Point = glm::dvec3;
using Curve = std::vector<Point>;
class CURVETOOLS_API CurveGenerator
{
protected:
unsigned int m_degree;
class CURVETOOLS_API CurveGenerator : public Generator<Point, double> {
public:
CurveGenerator(unsigned int degree);
unsigned int getDegree() const;
virtual Point operator()(const Curve& points, double t) const = 0;
CurveGenerator(uint16_t degree);
static Point lerp(const Point& a, const Point& b, double t);
static Point smoothstep(const Point& a, const Point& b, double t);
......
......@@ -8,6 +8,6 @@ namespace ct
{
public:
static std::vector<double> generateSampleValues(unsigned int count, double min, double max);
static Curve sampleCurve(const Curve& curve, const CurveGenerator& generator, const std::vector<double>& t);
static Curve SampleCurve(const Curve& curve, const CurveGenerator& generator, const std::vector<double>& t);
};
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ namespace ct
public:
HermiteGenerator();
Point operator()(const Curve& points, double t) const override;
Point generate(const Curve& points, double t) const override;
std::vector<Point> generate(const Curve& points, const std::vector<double> & us) const override;
};
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ namespace ct
public:
LinearGenerator();
Point operator()(const Curve& points, double t) const override;
Point generate(const Curve& points, double t) const override;
std::vector<Point> generate(const Curve& points, const std::vector<double> & us) const override;
};
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ namespace ct
public:
SmootherstepGenerator();
Point operator()(const Curve& points, double t) const override;
Point generate(const Curve& points, double t) const override;
std::vector<Point> generate(const Curve& points, const std::vector<double> & us) const override;
};
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ namespace ct
public:
SmoothstepGenerator();
Point operator()(const Curve& points, double t) const override;
Point generate(const Curve& points, double t) const override;
std::vector<Point> generate(const Curve& points, const std::vector<double> & us) const override;
};
}
\ No newline at end of file
......@@ -5,8 +5,8 @@
namespace ct::gpu {
class BezierGenerator : public StreamedGenerator {
public:
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const override;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
__host__ Point generate(const thrust::universal_vector<Point> &, const float) const override;
__host__ Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
};
namespace kernel {
......
......@@ -5,8 +5,8 @@
namespace ct::gpu {
class CatmullRomGenerator : public StreamedGenerator {
public:
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const override;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
__host__ virtual Point generate(const thrust::universal_vector<Point> &, const float) const override;
__host__ virtual Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
};
namespace kernel {
......
#pragma once
#include <thrust/universal_vector.h>
#include "CurveTools/GPU/Tools/Types.cuh"
namespace ct::gpu {
using Point = Vec;
using Curve = std::vector<Point>;
class Generator {
public:
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const = 0;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &) const = 0;
};
}
\ No newline at end of file
......@@ -5,8 +5,8 @@
namespace ct::gpu {
class HermiteGenerator : public StreamedGenerator {
public:
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const override;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
__host__ virtual Point generate(const thrust::universal_vector<Point> &, const float) const override;
__host__ virtual Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
};
namespace kernel {
......
......@@ -7,8 +7,8 @@ namespace ct::gpu {
public:
LinearGenerator();
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
__host__ virtual Point generate(const thrust::universal_vector<Point> &, const float) const;
__host__ virtual Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
};
namespace kernel {
......
......@@ -7,8 +7,8 @@ namespace ct::gpu {
public:
SmootherstepGenerator();
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
__host__ virtual Point generate(const thrust::universal_vector<Point> &, const float) const;
__host__ virtual Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
};
namespace kernel {
......
......@@ -7,8 +7,8 @@ namespace ct::gpu {
public:
SmoothstepGenerator();
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
__host__ virtual Point generate(const thrust::universal_vector<Point> &, const float) const;
__host__ virtual Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const;
};
namespace kernel {
......
#pragma once
#include "Generator.cuh"
#include "../Generator.hpp"
#include <memory>
#include <thrust/universal_vector.h>
......@@ -8,10 +8,9 @@
#include "StreamedGenerator.cuh"
namespace ct::gpu {
class SplineGenerator : public Generator {
class SplineGenerator : public Generator<Point, float> {
private:
size_t _streamsCount;
size_t _cut;
StreamedGenerator * _generator;
public:
......@@ -20,8 +19,15 @@ namespace ct::gpu {
inline StreamedGenerator * generator() const {return this->_generator;}
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, float) const;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &) const;
__host__ Point generate(const thrust::universal_vector<Point> &, float) const;
__host__ Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &) const;
virtual Point generate(const std::vector<Point> & pts, float u) const override final {
return this->generate(thrust::universal_vector<Point>(pts), u);
}
virtual std::vector<Point> generate(const std::vector<Point> & pts, const std::vector<float> & us) const override final {
return this->generate(thrust::universal_vector<Point>(pts), us);
}
};
}
\ No newline at end of file
#pragma once
#include "Generator.cuh"
#include "../Generator.hpp"
#include <thrust/universal_vector.h>
#include "CurveTools/GPU/Tools/Types.cuh"
......@@ -9,12 +9,17 @@ namespace ct::gpu {
using Point = Vec;
using Curve = std::vector<Point>;
class StreamedGenerator : public Generator {
class StreamedGenerator : public Generator<Point, float> {
public:
__host__ virtual Point operator()(const thrust::universal_vector<Point> &, const float) const = 0;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t &) const = 0;
__host__ virtual Curve operator()(const thrust::universal_vector<Point> & ctrlPoint, const std::vector<float> & ps) const override final {
return (*this)(ctrlPoint, ps, 0);
__host__ virtual Point generate(const thrust::universal_vector<Point> &, const float) const = 0;
__host__ virtual Curve generate(const thrust::universal_vector<Point> &, const std::vector<float> &, const cudaStream_t & = 0) const = 0;
inline Point generate(const Curve& points, float p) const override final {
return this->generate(thrust::universal_vector<Point>(points), p);
}
inline std::vector<Point> generate(const Curve& points, const std::vector<float> & ps) const override final {
return this->generate(thrust::universal_vector<Point>(points), ps);
}
};
}
\ No newline at end of file
#pragma once
#include <stdint.h>
#include <vector>
namespace ct {
template <typename T, typename U>
class Generator {
private:
const uint16_t _degree;
public:
inline Generator(uint16_t degree = 1) : _degree(degree) {}
inline uint16_t getDegree() const {return this->_degree;}
virtual T generate(const std::vector<T> &, U) const = 0;
virtual std::vector<T> generate(const std::vector<T> &, const std::vector<U> &) const = 0;
inline T operator()(const std::vector<T> & pts, U p) const {return this->generate(pts, p);}
inline std::vector<T> operator()(const std::vector<T> & pts, const std::vector<U> & ps) {return this->generate(pts, ps);}
};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment