feat(v3.3): B-Rep face splitting + fuzz testing (all 3 tasks)
CI / Build & Test (push) Failing after 33s
CI / Release Build (push) Failing after 29s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled

This commit is contained in:
茂之钳
2026-07-24 12:48:42 +00:00
parent acc26e3a4b
commit 107cf58034
10 changed files with 775 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
#include <gtest/gtest.h>
#include "vde/brep/brep_boolean.h"
#include "vde/brep/modeling.h"
#include <cmath>
#include <random>
using namespace vde::brep;
// ── B-Rep fuzz: random sized boxes with boolean operations ──
TEST(FuzzBoolean, RandomBoxBooleans) {
std::mt19937 rng(42);
std::uniform_real_distribution<double> size_dist(1.0, 5.0);
std::uniform_real_distribution<double> offset_dist(-2.0, 2.0);
for (int i = 0; i < 30; ++i) {
double s1 = size_dist(rng);
double s2 = size_dist(rng);
double ox = offset_dist(rng);
double oy = offset_dist(rng);
double oz = offset_dist(rng);
// NOTE: ox, oy, oz computed for future translate API use
(void)ox; (void)oy; (void)oz;
auto box1 = make_box(s1, s1, s1);
auto box2 = make_box(s2, s2, s2);
// Test that operations don't crash
auto u = brep_union(box1, box2);
auto inter = brep_intersection(box1, box2);
auto diff = brep_difference(box1, box2);
// Basic sanity: results should have finite bounds
EXPECT_TRUE(std::isfinite(u.bounds().min().x()));
EXPECT_TRUE(std::isfinite(inter.bounds().min().x()));
EXPECT_TRUE(std::isfinite(diff.bounds().min().x()));
}
}
// ── B-Rep fuzz: self-operations (AA, A∩A, A\A) ──
TEST(FuzzBoolean, SelfOperations) {
for (int i = 0; i < 20; ++i) {
double s = 1.0 + i * 0.2;
auto box = make_box(s, s, s);
// Self-union should be valid
auto self_u = brep_union(box, box);
EXPECT_TRUE(self_u.is_valid());
// Self-difference should be valid
auto self_d = brep_difference(box, box);
EXPECT_TRUE(self_d.is_valid());
// Self-intersection should be valid
auto self_i = brep_intersection(box, box);
EXPECT_TRUE(self_i.is_valid());
}
}