test(cae): assert conical shell area
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user