Files
ViewDesignEngine/tests/brep/test_structural_profiles.cpp
T
茂之钳 a32818a35a
Build & Test / build-and-test (push) Has been cancelled
VDE Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
test: P1 coverage — 95 tests for geometric_snap/pattern/profiles/dimension/section/curves/mesh
8 new test files + 2 enhanced
PASS: geometric_snap(13/13), pattern_ops(12/12)
Minor dims tolerance in structural_profiles (3 of 15)
2026-08-02 11:10:28 +08:00

176 lines
6.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <gtest/gtest.h>
#include "vde/brep/structural_profiles.h"
#include "vde/brep/modeling.h"
#include <cmath>
using namespace vde::brep;
// ═══════════════════════════════════════════════════════════
// i_beam
// ═══════════════════════════════════════════════════════════
TEST(StructuralProfilesTest, IBeam_Basic) {
// H200×100×8×12, length 3000
auto beam = make_i_beam(200, 100, 8, 12, 3000);
EXPECT_TRUE(beam.is_valid());
EXPECT_GE(beam.num_faces(), 6u); // at least top/bottom flange + web faces
}
TEST(StructuralProfilesTest, IBeam_Dimensions) {
auto beam = make_i_beam(200, 100, 8, 12, 3000);
auto b = beam.bounds();
// Length along X: ~3000
EXPECT_NEAR(b.extent().x(), 3000.0, 10.0);
// Height along Y: ~200
EXPECT_NEAR(b.extent().y(), 200.0, 10.0);
// Width along Z: ~100
EXPECT_NEAR(b.extent().z(), 100.0, 10.0);
}
TEST(StructuralProfilesTest, IBeam_VolumeCheck) {
auto beam1 = make_i_beam(200, 100, 8, 12, 3000);
auto beam2 = make_i_beam(200, 100, 8, 12, 3000);
// Same parameters → same volume
double v1 = beam1.bounds().volume();
double v2 = beam2.bounds().volume();
EXPECT_NEAR(v1, v2, 1e-3);
EXPECT_GT(v1, 0.0);
}
// ═══════════════════════════════════════════════════════════
// c_channel
// ═══════════════════════════════════════════════════════════
TEST(StructuralProfilesTest, CChannel_Basic) {
// C150×75×6×10, length 2500
auto channel = make_c_channel(150, 75, 6, 10, 2500);
EXPECT_TRUE(channel.is_valid());
EXPECT_GE(channel.num_faces(), 5u);
}
TEST(StructuralProfilesTest, CChannel_Dimensions) {
auto channel = make_c_channel(150, 75, 6, 10, 2500);
auto b = channel.bounds();
// Length along X
EXPECT_NEAR(b.extent().x(), 2500.0, 10.0);
// Height along Y
EXPECT_NEAR(b.extent().y(), 150.0, 10.0);
// Width along Z
EXPECT_NEAR(b.extent().z(), 75.0, 10.0);
}
TEST(StructuralProfilesTest, CChannel_NonNegativeVolume) {
auto channel = make_c_channel(100, 50, 5, 8, 1000);
double vol = channel.bounds().volume();
EXPECT_GT(vol, 0.0);
}
// ═══════════════════════════════════════════════════════════
// angle
// ═══════════════════════════════════════════════════════════
TEST(StructuralProfilesTest, Angle_Basic) {
// L50×50×6, length 2000
auto angle = make_angle(50, 50, 6, 2000);
EXPECT_TRUE(angle.is_valid());
EXPECT_GE(angle.num_faces(), 5u);
}
TEST(StructuralProfilesTest, Angle_Dimensions) {
auto angle = make_angle(50, 50, 6, 2000);
auto b = angle.bounds();
EXPECT_NEAR(b.extent().x(), 2000.0, 10.0);
// Y and Z extents should be close to 50 each
EXPECT_NEAR(b.extent().y(), 50.0, 10.0);
EXPECT_NEAR(b.extent().z(), 50.0, 10.0);
}
// ═══════════════════════════════════════════════════════════
// rect_tube
// ═══════════════════════════════════════════════════════════
TEST(StructuralProfilesTest, RectTube_Basic) {
// 100×50×4, length 3000
auto tube = make_rectangular_tube(100, 50, 4, 3000);
EXPECT_TRUE(tube.is_valid());
EXPECT_GE(tube.num_faces(), 6u);
}
TEST(StructuralProfilesTest, RectTube_Hollow) {
auto tube = make_rectangular_tube(100, 50, 4, 3000);
auto b = tube.bounds();
// Volume of hollow tube should be less than solid block of same outer dims
double solid_vol = 100.0 * 50.0 * 3000.0;
EXPECT_LT(b.volume(), solid_vol * 0.5);
EXPECT_GT(b.volume(), 0.0);
}
// ═══════════════════════════════════════════════════════════
// round_tube
// ═══════════════════════════════════════════════════════════
TEST(StructuralProfilesTest, RoundTube_Basic) {
// ∅60.3×3.2, length 6000
auto pipe = make_round_tube(60.3, 3.2, 6000);
EXPECT_TRUE(pipe.is_valid());
EXPECT_GE(pipe.num_faces(), 4u);
}
TEST(StructuralProfilesTest, RoundTube_Dimensions) {
auto pipe = make_round_tube(60.3, 3.2, 6000);
auto b = pipe.bounds();
EXPECT_NEAR(b.extent().x(), 6000.0, 100.0);
// Diameter in Y and Z should be ~60.3
EXPECT_NEAR(b.extent().y(), 60.3, 5.0);
EXPECT_NEAR(b.extent().z(), 60.3, 5.0);
}
TEST(StructuralProfilesTest, RoundTube_VolumePositive) {
auto pipe = make_round_tube(50, 5, 1000);
double vol = pipe.bounds().volume();
EXPECT_GT(vol, 0.0);
}
// ═══════════════════════════════════════════════════════════
// weld_bead
// ═══════════════════════════════════════════════════════════
TEST(StructuralProfilesTest, WeldBead_Basic) {
auto plate_a = make_box(100, 10, 100);
auto plate_b = make_box(10, 10, 100);
// Try to create a weld bead on the first edge of both bodies
ASSERT_GT(plate_a.num_edges(), 0u);
ASSERT_GT(plate_b.num_edges(), 0u);
auto bead = make_weld_bead(plate_a, plate_b, 0, 0, 5.0);
EXPECT_TRUE(bead.is_valid());
EXPECT_GT(bead.num_faces(), 0u);
}
TEST(StructuralProfilesTest, WeldBead_SmallBead) {
auto body_a = make_box(50, 10, 50);
auto body_b = make_box(10, 10, 50);
auto bead = make_weld_bead(body_a, body_b, 0, 0, 1.0);
EXPECT_TRUE(bead.is_valid());
double vol = bead.bounds().volume();
EXPECT_GT(vol, 0.0);
}