You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.2 KiB
69 lines
2.2 KiB
#ifndef NURBSEVALUATOR_NURBS_CURVE_CUH
|
|
#define NURBSEVALUATOR_NURBS_CURVE_CUH
|
|
|
|
#include <cuda_runtime.h>
|
|
#include <vector>
|
|
#include <glm/glm.hpp>
|
|
|
|
namespace NurbsCurve {
|
|
const int POINT_SIZE = 4;
|
|
/**
|
|
* 曲线计算的核函数
|
|
* @param d_pointSize 点的大小(3: [x, y, z] | 4:[x, y, z, w])
|
|
*/
|
|
__global__ static void
|
|
g_evaluate(float *res, const float *NTexture, const float *d_points, int d_pointsCnt, int d_pointSize,
|
|
float d_lastKnot, int d_sampleCnt);
|
|
|
|
__global__ static void
|
|
g_derivative(float *derivatives, const float *derTexture, const float *nTexture, const float *d_points,
|
|
int d_pointsCnt, int d_pointSize, float d_lastKnot,
|
|
int d_sampleCnt);
|
|
|
|
__global__ static void g_curvature(const float *derivatives, int sampleCnt, float lastKnot);
|
|
|
|
class Curve {
|
|
private:
|
|
std::vector<std::vector<float>> controlPoints;
|
|
std::vector<float> knots;
|
|
float *d_knots;
|
|
float *d_points;
|
|
bool recordTime;
|
|
|
|
float *d_nTexture; // 指向度为p时的device中的nurbs基函数矩阵
|
|
float *d_nTexture1; // 指向度为p-1时的device中的nurbs基函数矩阵
|
|
|
|
float *d_derivatives{}; // 一阶导计算结果
|
|
|
|
public:
|
|
/**
|
|
* 构造函数
|
|
* @param controlPoints 控制点矩阵[pointsCnt][3]
|
|
*/
|
|
explicit Curve(std::vector<std::vector<float>> controlPoints, std::vector<float> knots);
|
|
|
|
/**
|
|
* 供外部CPU程序使用的、负责调用gpu并行进行evaluation的方法
|
|
* @param sampleCnt_ 在参数域内均匀采样的采样数,它会更新成员变量中的sampleCnt
|
|
* @return 由 map 组成的vector{<u, {x, y, z}>}
|
|
*/
|
|
std::vector<glm::vec3> evaluate(int sampleCnt_);
|
|
|
|
/**
|
|
* 供外部CPU程序使用的、负责调用gpu并行计算切向量的方法
|
|
*/
|
|
void derivative(int sampleCnt);
|
|
|
|
/**
|
|
* 供外部CPU程序使用的、负责调用gpu并行计算二阶导的方法
|
|
*/
|
|
void curvature(int sampleCnt);
|
|
|
|
~Curve();
|
|
|
|
void setRecordTime(bool r);
|
|
};
|
|
}
|
|
|
|
|
|
#endif //NURBSEVALUATOR_NURBS_CURVE_CUH
|
|
|