半个卡座 导入 to_mesh 出现 zmin≈-26.993 假凸起:端部圆边的弧顶坐标带 ~1e-13 z 噪声,使 ccw=π+1.9e-13,原严格 'ccw<=M_PI' 判短弧误判成取互补弧,端部圆弧翻到错误半侧。修复:判别加 kArcHalfTol=1e-9 容差(≈5.7e-8 度),恰为半圆的边稳定取 STEP 方向弧 a_s→a_e。回归:卡座 bbox zmin≈0、test_cube_circle 保持 [-5,-5,-0]~[5,5,10]。顺带删除已提交的 [circle-dbg] 环境门控诊断;附裁剪诊断器 dbg_trimcase_review 与参考网格 bbox 探针 dbg_bbox3mf。
51 lines
2.0 KiB
C++
51 lines
2.0 KiB
C++
// 临时探针: 打印 3mf/GLB 参考网格的整体/单件 bbox 与 z<0 顶点占比
|
|
// 用法: dbg_bbox3mf <file>
|
|
#include <cctype>
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
#include "vde/brep/step_import.h"
|
|
#include "vde/foundation/io_3mf.h"
|
|
#include "vde/foundation/io_gltf.h"
|
|
|
|
using namespace vde::brep;
|
|
using namespace vde::foundation;
|
|
|
|
static void report_mesh(const vde::mesh::HalfedgeMesh& m, const char* tag) {
|
|
if (m.num_vertices() == 0) { std::printf("[%s] empty\n", tag); return; }
|
|
double mn[3] = {1e300, 1e300, 1e300}, mx[3] = {-1e300, -1e300, -1e300};
|
|
long long nz = 0;
|
|
for (size_t i = 0; i < m.num_vertices(); ++i) {
|
|
const auto& p = m.vertex((int)i);
|
|
if (p.z() < -1e-6) ++nz;
|
|
mn[0] = mn[0] < p.x() ? mn[0] : p.x(); mx[0] = mx[0] > p.x() ? mx[0] : p.x();
|
|
mn[1] = mn[1] < p.y() ? mn[1] : p.y(); mx[1] = mx[1] > p.y() ? mx[1] : p.y();
|
|
mn[2] = mn[2] < p.z() ? mn[2] : p.z(); mx[2] = mx[2] > p.z() ? mx[2] : p.z();
|
|
}
|
|
std::printf("[%s] bbox=[%.4f,%.4f,%.4f]~[%.4f,%.4f,%.4f] nz_verts=%lld/%zu\n",
|
|
tag, mn[0], mn[1], mn[2], mx[0], mx[1], mx[2],
|
|
nz, m.num_vertices());
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc < 2) {
|
|
std::printf("usage: dbg_bbox3mf <file>\n");
|
|
return 2;
|
|
}
|
|
const std::string path = argv[1];
|
|
std::string lower = path;
|
|
for (auto& c : lower) c = (char)std::tolower((unsigned char)c);
|
|
if (lower.size() >= 4 && lower.substr(lower.size() - 4) == ".3mf") {
|
|
auto ms = read_3mf(path);
|
|
std::printf("3mf meshes=%zu\n", ms.size());
|
|
for (size_t i = 0; i < ms.size(); ++i)
|
|
report_mesh(ms[i].mesh, ("m" + std::to_string(i)).c_str());
|
|
} else {
|
|
auto res = import_gltf(path);
|
|
std::printf("glb meshes=%zu ok=%d\n", res.meshes.size(), (int)res.success);
|
|
for (size_t i = 0; i < res.meshes.size(); ++i)
|
|
report_mesh(res.meshes[i], ("m" + std::to_string(i)).c_str());
|
|
}
|
|
return 0;
|
|
}
|