// 临时探针: 打印 3mf/GLB 参考网格的整体/单件 bbox 与 z<0 顶点占比 // 用法: dbg_bbox3mf #include #include #include #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 \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; }