fix(brep): accept valid boolean results with diagnostics
This commit is contained in:
@@ -134,15 +134,16 @@ try_ssi_boolean(const BrepModel& a, const BrepModel& b, FallbackBoolOp op) {
|
||||
diag.error_message = ssi_result.error_message;
|
||||
}
|
||||
|
||||
// 失败条件:有错误信息 或 结果为空
|
||||
bool has_failure = !ssi_result.error_message.empty()
|
||||
|| diag.result.num_faces() == 0;
|
||||
|
||||
// 失败条件:结果为空,或结果非空但 validate 不通过。
|
||||
// error_message 可能只是诊断/警告;只要 B-Rep 有效就接受。
|
||||
bool has_failure = diag.result.num_faces() == 0;
|
||||
if (!has_failure) {
|
||||
const auto v = validate(diag.result);
|
||||
if (!v.valid) {
|
||||
has_failure = true;
|
||||
diag.error_message = "SSI boolean result invalid";
|
||||
} else if (!ssi_result.error_message.empty()) {
|
||||
diag.error_message.clear();
|
||||
}
|
||||
}
|
||||
if (has_failure) {
|
||||
@@ -186,7 +187,6 @@ try_tolerant_boolean(const BrepModel& a, const BrepModel& b, FallbackBoolOp op)
|
||||
|
||||
// 失败条件:有 failed_faces 或 有错误信息
|
||||
bool has_failure = !diag.failed_faces.empty()
|
||||
|| !diag.error_message.empty()
|
||||
|| diag.result.num_faces() == 0;
|
||||
if (!has_failure && !validate(diag.result).valid) {
|
||||
has_failure = true;
|
||||
|
||||
@@ -287,3 +287,12 @@ TEST(BooleanFallbackTest, BRepQualityBodyIsAlwaysValid) {
|
||||
EXPECT_TRUE(validate(*result.brep_body).valid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(BooleanFallbackTest, Level1_ValidResultWithDiagnosticIsAccepted) {
|
||||
auto box = make_box(100, 100, 100);
|
||||
auto sphere = make_sphere(40.0, 16, 8);
|
||||
auto [diag, ok] = try_ssi_boolean(box, sphere, FallbackBoolOp::Difference);
|
||||
EXPECT_TRUE(ok);
|
||||
if (ok) EXPECT_TRUE(validate(diag.result).valid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user