2.2 KiB
2.2 KiB
快速入门
5 分钟跑起 ViewDesignEngine
1. 编译
# Docker(推荐,开箱即用)
docker run --rm -v $(pwd):/ws -w /ws vde-builder:latest \
bash -c "cmake -B build && cmake --build build -j$(nproc)"
# 本地(需要 CMake 3.16+, GCC 11+/Clang 16+, Eigen3)
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
2. 运行测试
cd build && ctest --output-on-failure -E Benchmark
3. 第一个程序
#include <vde/brep/modeling.h>
#include <vde/brep/brep_boolean.h>
#include <vde/brep/step_export.h>
#include <iostream>
using namespace vde::brep;
int main() {
// 创建两个实体
auto box = make_box(2, 2, 2); // 2×2×2 立方体
auto sphere = make_sphere(1.5, 32); // 半径1.5球体
// 布尔并集
auto result = brep_union(box, sphere);
// 验证结果
auto report = validate(result);
std::cout << "Faces: " << result.num_faces()
<< " Valid: " << report.valid << std::endl;
// 导出 STEP
export_step_file("output.step", {result});
return 0;
}
编译运行:
g++ -std=c++20 -I include -L build/src \
my_program.cpp -lvde_brep -lvde_curves -lvde_foundation \
-lvde_core -o my_program
./my_program
4. 核心头文件速查
| 功能 | 头文件 | 关键 API |
|---|---|---|
| 创建基本体 | vde/brep/modeling.h |
make_box, make_cylinder, make_sphere |
| 布尔运算 | vde/brep/brep_boolean.h |
brep_union, brep_intersection, brep_difference |
| 拓扑修复 | vde/brep/brep_heal.h |
heal_topology, heal_gaps |
| 验证 | vde/brep/brep_validate.h |
validate |
| STEP 读写 | vde/brep/step_import.h / vde/brep/step_export.h |
import_step, export_step_file |
| 网格转换 | vde/brep/brep.h |
body.to_mesh() |
| SDF 建模 | vde/sdf/sdf_tree.h |
SDF 隐式曲面 |
| CAM 加工 | vde_cam/cam_strategies.h |
roughing_toolpath, finishing_toolpath |
| 装配体 | vde/brep/assembly.h |
Assembly, AssemblyNode |