test(ifcpatch): add MergeProjects regression test for merging 3+ files (#7973)

Merging more than two IFC models with the MergeProjects recipe leaves
duplicated IfcGeometricRepresentationContext entities behind. All elements
are kept, but the accumulated contexts cause later disciplines to appear
"not merged" in viewers.

This test merges three projects and asserts the elements are kept, a single
IfcProject remains, and the geometric contexts are reused rather than
accumulated. It currently fails on the context assertion, reproducing #7973.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Petru Conduraru
2026-06-25 12:33:27 +03:00
committed by Thomas Krijnen
parent f3dcf0b539
commit fce7cd3eb4
+22
View File
@@ -177,6 +177,28 @@ class TestMergeProjects(test.bootstrap.IFC4):
assert np.any(np.all(np.isclose(np.array((17.847, 24.707, 3.0)), verts, atol=1e-3), axis=1))
assert np.any(np.all(np.isclose(np.array((20.410, 25.902, 5.0)), verts, atol=1e-3), axis=1))
def test_merging_three_or_more_projects(self):
# Regression test for #7973: merging N>2 models must keep every
# project's elements and must not leave duplicated geometric contexts
# behind (which makes later disciplines appear "not merged" in viewers).
self.file = self.setup_project(self.file)
second_file = self.setup_project()
third_file = self.setup_project()
output = ifcpatch.execute(
{
"file": self.file,
"recipe": "MergeProjects",
"arguments": [[second_file, third_file]],
}
)
assert self.file == output
# Every model contributed exactly one wall.
assert len(output.by_type("IfcWall")) == 3
# A single merged project must remain.
assert len(output.by_type("IfcProject")) == 1
# Contexts must be reused, not accumulated: one Model + one Body.
assert len(output.by_type("IfcGeometricRepresentationContext")) == 2
class TestMergeProjectsIFC2X3(test.bootstrap.IFC2X3, TestMergeProjects):
pass