From 143b6da2c79fa726e58bbdba8f64e05ce0738daa Mon Sep 17 00:00:00 2001 From: hm-thinkbook14p Date: Sat, 14 Nov 2026 22:49:42 +0800 Subject: [PATCH] test(cae): assert conical shell area --- tests/cae/test_vde1346_cae_preprocess.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/cae/test_vde1346_cae_preprocess.cpp b/tests/cae/test_vde1346_cae_preprocess.cpp index 3eb4e0890..3fb72ebe2 100644 --- a/tests/cae/test_vde1346_cae_preprocess.cpp +++ b/tests/cae/test_vde1346_cae_preprocess.cpp @@ -1,5 +1,6 @@ #include +#include #include #include "vde/brep/modeling.h" #include "vde/brep/brep_boolean.h" @@ -181,5 +182,18 @@ TEST(VDE1346CaePreprocess, ConicalShellMidsurfaceAndMesh) { if (p.kind == vde::cae::MidsurfaceKind::Cone) ++cones; EXPECT_EQ(cones, 1); const auto mesh = vde::cae::shell_mesh(shell); - EXPECT_FALSE(mesh.triangles.empty()) << mesh.diagnostic; + ASSERT_FALSE(mesh.triangles.empty()) << mesh.diagnostic; + double area = 0.0; + for (const auto& t : mesh.triangles) { + const auto a = mesh.vertices[t[0]]; + const auto b = mesh.vertices[t[1]]; + const auto c = mesh.vertices[t[2]]; + area += 0.5 * (b - a).cross(c - a).norm(); + } + const auto& cp = *std::find_if(patches.begin(), patches.end(), + [](const auto& p){ return p.kind == vde::cae::MidsurfaceKind::Cone; }); + const double len = std::sqrt((cp.v1 - cp.v0) * (cp.v1 - cp.v0) + + (cp.r1 - cp.r0) * (cp.r1 - cp.r0)); + const double expect = 3.14159265358979323846 * (cp.r0 + cp.r1) * len; + EXPECT_NEAR(area, expect, 0.02 * expect); }