A tool for evaluating multiple NURBS curve/surface points using the GPU.
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.

75 lines
2.8 KiB

2 years ago
# NurbsPerformer
2 years ago
2 years ago
2 years ago
A tool for performing NURBS curve/surface modeling operations in parallel using the GPU.
## Dependencies
2 years ago
+ **MSVC**
+ CUDA 11.8.0
## Usage
### 直接运行
根据CMake构建项目,运行main文件即可生成可执行文件
### 作为依赖使用
1. CMakeLists.txt中注释以下代码,不再生成可执行文件
```cmake
2 years ago
add_executable(NurbsPerformer ${PROJECT_SOURCES})
```
2. CMakeLists.txt中取消注释以下代码,表示需要生成静态库。构建项目。
```cmake
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2 years ago
add_library(NurbsPerformer ${PROJECT_SOURCES})
```
3. 原项目连接到生成的静态库目录。如果是由CMake构建,可以用 target_link_libraries 指向依赖(.lib),用 target_include_directories 指向头文件目录。
4. 使用.cu文件调用NurbsEvaluator
### Nurbs曲线
在构造函数中传入控制点向量和knots向量:
```c++
2 years ago
NurbsCurve::Curve nurbsCurveEvaluator(
{
{-1, 0, 0},
{0, 1, 6},
{1, 0, 4},
{2, 0.5, 3},
{3, 3, 1},
{4, -5, 0}
},
{0, 0, 0, 0.1, 0.5, 0.8, 1, 1, 1}
); // 6点控制,knots长度为9,degree为2的NURBS
```
设置是否需要输出GPU并行计算花费的时间(默认否):
```c++
nurbsCurveEvaluator.setRecordTime(true);
```
开始计算
```c++
nurbsCurveEvaluator.calculate(5); // 在参数域采样5个点
```
### Nurbs曲面
曲面在构造函数中需要传入三层vector嵌套表示的二维点阵、u方向的knots向量、v方向的knots向量
```c++
2 years ago
NurbsSurface::Surface nurbsSurfaceEvaluator(
{
{{-1, 0, 0}, {0, 1, 6}, {1, 0, 4}, {2, 0.5, 3}, {3, 3, 1}, {4, -5, 0}},
{{-2, 1, 1.2}, {1, 2, 3}, {2, 2, 3}, {-1, -0.3, 2}, {-1, 2, 0}, {7, -8, 2}},
{{-3.4, 2, 3}, {2, 3, 0}, {4, 3, 7}, {-2, 0, -0.2}, {1, 1.7, 5}, {9, -10.3, 6}},
{{-1.5, 3.2, 1}, {2.6, 7, -2}, {5, 0.8, 4.2}, {-4, 1, 4}, {2.1, 4, -2}, {11, -6, 4}},
{{-0.2, 2, 0}, {5, 3, 2}, {5, 1.5, 1.4}, {-3, 2, 5}, {0.8, 1.3, 0}, {15, -2, 0.9}},
{{3, 1.4, -1}, {6, 2, 4}, {-1, 0, -2}, {0, 2.8, 2}, {-0.5, 2, 1.2}, {7, -3, -2}}
},
{0, 0, 0, 0.1, 0.5, 0.8, 1, 1, 1},
{0, 0, 0, 0.2, 0.7, 0.8, 1, 1, 1}
);
nurbsSurfaceEvaluator.setRecordTime(true);
nurbsSurfaceEvaluator.calculate(3, 4); // 计算时需要传入u、v两个方向的采样数目
2 years ago
```
## Primary Reference
2 years ago
+ [Direct Evaluation of NURBS Curves and Surfaces on the GPU - 2007 - Krishnamurthy, Khardekar, Mcmains](https://dl.acm.org/doi/abs/10.1145/1236246.1236293)
+ CUDA C编程权威指南 - 2017 - 程润伟 , Max Grossman , Ty McKercher