Files
茂之钳 aeb29ab87c
CI / Build & Test (push) Failing after 41s
CI / Release Build (push) Failing after 33s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
fix(v1.0.3): VDE-019 center参数 + VDE-020 cone/torus + VDE-022 位置查询 + VDE-026 BVH索引
VDE-019 (Fixed): make_box/make_cylinder/make_sphere 添加 Point3D center 参数
VDE-020 (Fixed): 新增 make_cone(r1,r2,height) 和 make_torus(rMajor,rMinor) 基本体
VDE-022 (Partially Fixed): 添加 get_edge_index_by_position / get_face_index_by_position / fillet_by_position / chamfer_by_position
VDE-026 (Fixed): Triangle3D 添加 int id 字段,BVH::build() 自动赋值索引,HitResult 添加 tri_index
VDE-021/023/024/025 (Acknowledged): mesh→NURBS 转换等复杂几何算法,需求已记录

反馈来自 ViewDesign feat/viewdesign-engine 分支
2026-07-28 17:08:03 +08:00

1.9 KiB

VDE-019: make_box/make_cylinder/make_sphere 不支持位置偏移参数

  • ID: VDE-019
  • Date: 2026-07-28
  • Status: Fixed
  • Severity: Medium
  • Category: API Gap
  • Source: ViewDesign feat/viewdesign-engine branch

Issue

VDE 的基本体 API 仅支持原点为中心的创建,缺少位置偏移参数:

// VDE 当前 API(仅原点)
auto box = vde::brep::make_box(10, 5, 3);         // 原点中心
auto sph = vde::brep::make_sphere(5.0);             // 原点中心
auto cyl = vde::brep::make_cylinder(2.0, 10.0);     // 原点中心,Y 轴

ViewDesign 的 PrimitiveFactory 需要任意位置的基本体构建:

Shape box(double x1, y1, z1, x2, y2, z2);          // 任意两点定义的盒子
Shape sphere(double cx, cy, cz, radius);             // 任意位置球体
Shape cylinder(double cx, cy, cz, radius, height);   // 任意位置圆柱

Current Workaround (ViewDesign)

通过 BrepModel → mesh 转换后手动偏移顶点坐标:

auto model = vde::brep::make_sphere(radius);
// 转换为 mesh,然后遍历顶点加偏移
brepToMeshData(model, verts, tris);
for (size_t i = 0; i < verts.size(); i += 3) {
    verts[i] += offX; verts[i+1] += offY; verts[i+2] += offZ;
}

此方案是 lossy 的(B-Rep 精度退化为 mesh 精度),但对于基本体生成可接受。

Suggested Fix

为 VDE 的 make_box/make_sphere/make_cylinder 添加可选的位置偏移参数:

BrepModel make_box(double w, double h, double d,
                   const Point3D& center = Point3D(0, 0, 0));
BrepModel make_sphere(double radius,
                      const Point3D& center = Point3D(0, 0, 0));
BrepModel make_cylinder(double radius, double height,
                        const Point3D& center = Point3D(0, 0, 0));

或者提供 make_box(double x1, y1, z1, x2, y2, z2) 两点定义的重载。