fix: SDF nan/edge cases + B-Rep vertex index → ID fix + IGES 1-based DE + STEP cleanup
CI / Build & Test (push) Failing after 16m57s
CI / Release Build (push) Failing after 2m59s

This commit is contained in:
茂之钳
2026-07-24 08:42:53 +00:00
parent ebc47a25c9
commit a323776fd3
12 changed files with 139 additions and 70 deletions
+10 -10
View File
@@ -139,8 +139,8 @@ TEST(SdfGradient, EvaluateWithGradientInside) {
GradResult r = evaluate_with_gradient(f, p, FD_H);
EXPECT_NEAR(r.value, -2.0, 1e-9);
// At center, gradient magnitude ≈ 1 (any direction is fine)
EXPECT_NEAR(r.grad.norm(), 1.0, EPS_LOOSE);
// At center, the SDF is non-differentiable; FD gradient ≈ (0,0,0)
EXPECT_LT(r.grad.norm(), 0.01) << "Gradient at exact center should be near-zero (degenerate SDF)";
}
// ═══════════════════════════════════════════════════
@@ -341,22 +341,22 @@ TEST(SdfChain, DifferenceGradient) {
Vector3D gA(1, 0, 0);
Vector3D gB(0, 1, 0);
// d1=0.5 (outside A), d2=-0.3 (inside B). -d1=-0.5 < d2=-0.3 → pick B
// d1=0.5 (outside A), d2=-0.3 (inside B).
// op_difference = max(d1, -d2) = max(0.5, 0.3) = 0.5 → picks grad_a
Vector3D g = chain_difference(gA, gB, 0.5, -0.3);
EXPECT_NEAR(g.y(), 1.0, 1e-9);
EXPECT_NEAR(g.x(), 1.0, 1e-9);
}
TEST(SdfChain, DifferenceNegatesGradA) {
Vector3D gA(1, 0, 0);
Vector3D gB(0, 1, 0);
// A completely outside B: d1=-0.5 (inside A subtracted part), d2=0.5
// -d1 = 0.5, d2 = 0.5. At equal: standard picks second (since op_difference uses >)
// Actually: op_difference = max(-d1, d2). If -d1 > d2, pick -d1 region with -grad_a
// d1=-1.0 (inside body), d2=0.0 (on cutter surface)
// op_difference = max(-1, 0) = 0. d1=-1, -d2=0. -d2 > d1 → pick -grad_b
// -grad_b = (0, -1, 0)
Vector3D g = chain_difference(gA, gB, -1.0, 0.0);
// -d1 = 1.0 > d2 = 0.0 → pick -grad_a
EXPECT_NEAR(g.x(), -1.0, 1e-9);
EXPECT_NEAR(g.y(), 0.0, 1e-9);
EXPECT_NEAR(g.x(), 0.0, 1e-9);
EXPECT_NEAR(g.y(), -1.0, 1e-9);
}
// ═══════════════════════════════════════════════════