mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
55428a0878
Wall body rebuild + slab underside re-clip are now unified behind tool.Model.regenerate_wall and called from split / merge / extend operators. Fillet corner walls accept extend-to-underside (poll + operator partition switched to is_path_connectable_wall) and surface the wall-unjoin gizmo without the parametric-edit gate, since fillets cannot enter that lifecycle. DumbWallJoiner.split strips the duplicate's inherited slab-trim booleans up front so wall2 lands at the cut point. regenerate_fillet_corner_wall re-clips after the body rewrite so a prior extend-to-slab survives neighbour recalcs. Drive-by bug sweep: tuple typo in hotkey_S_G's IfcSpace check, defensive .get() in draw_regen_operations for partial AuthoringData loads, and a try/except in get_active_representation matching the existing convention for stale mesh ifc_definition_ids after a representation rebuild. Tests cover the regenerate_wall branching, the get_active_representation stale-id contract, and the GizmoWallExtendVertically fillet acceptance. Generated with the assistance of an AI coding tool.
86 lines
3.1 KiB
Python
86 lines
3.1 KiB
Python
# Bonsai - OpenBIM Blender Add-on
|
|
# Copyright (C) 2026
|
|
#
|
|
# This file is part of Bonsai.
|
|
#
|
|
# Bonsai is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Bonsai is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# This file was generated with the assistance of an AI coding tool.
|
|
|
|
"""Pins the branching contract of ``tool.Model.regenerate_wall``.
|
|
|
|
The body rebuild always runs (extrusion + openings); the slab re-clip only
|
|
runs when an ``IfcRelConnectsElements(TOP)`` rel survives. A wall without
|
|
either feature still completes without crashing."""
|
|
|
|
from unittest.mock import Mock, patch
|
|
|
|
import pytest
|
|
|
|
import bonsai.tool as tool
|
|
|
|
pytestmark = pytest.mark.model
|
|
|
|
|
|
def test_regenerate_wall_rebuilds_body_and_reclips_when_connected():
|
|
"""Wall with a TOP connection: body rebuilt first, then re-clipped."""
|
|
element = Mock()
|
|
obj = Mock()
|
|
|
|
with patch("bonsai.tool.model.tool.Ifc.get_entity", return_value=element), patch.object(
|
|
tool.Model, "recreate_wall"
|
|
) as recreate, patch.object(tool.Model, "has_underside_connection", return_value=True), patch(
|
|
"bonsai.tool.model.bonsai.core.model.regenerate_wall_to_underside"
|
|
) as regen:
|
|
tool.Model.regenerate_wall(obj)
|
|
|
|
recreate.assert_called_once_with(element, obj)
|
|
regen.assert_called_once()
|
|
args, _ = regen.call_args
|
|
assert args[3] == [obj]
|
|
|
|
|
|
def test_regenerate_wall_skips_reclip_when_no_top_rel():
|
|
"""Wall without a TOP connection: body rebuilt; re-clip skipped."""
|
|
element = Mock()
|
|
obj = Mock()
|
|
|
|
with patch("bonsai.tool.model.tool.Ifc.get_entity", return_value=element), patch.object(
|
|
tool.Model, "recreate_wall"
|
|
) as recreate, patch.object(tool.Model, "has_underside_connection", return_value=False), patch(
|
|
"bonsai.tool.model.bonsai.core.model.regenerate_wall_to_underside"
|
|
) as regen:
|
|
tool.Model.regenerate_wall(obj)
|
|
|
|
recreate.assert_called_once_with(element, obj)
|
|
regen.assert_not_called()
|
|
|
|
|
|
def test_regenerate_wall_noops_when_obj_has_no_ifc_entity():
|
|
"""Non-IFC objects (e.g. a freshly created Blender mesh before
|
|
`tool.Ifc.run("root.create_entity")` runs) return None from get_entity;
|
|
the helper must return without touching the body or any rels."""
|
|
obj = Mock()
|
|
|
|
with patch("bonsai.tool.model.tool.Ifc.get_entity", return_value=None), patch.object(
|
|
tool.Model, "recreate_wall"
|
|
) as recreate, patch.object(tool.Model, "has_underside_connection") as has_top, patch(
|
|
"bonsai.tool.model.bonsai.core.model.regenerate_wall_to_underside"
|
|
) as regen:
|
|
tool.Model.regenerate_wall(obj)
|
|
|
|
recreate.assert_not_called()
|
|
has_top.assert_not_called()
|
|
regen.assert_not_called()
|