Improve filling operators and tests (#1754)

* Test add_filling operator

* Test Remove filling

* Update bootstrap defs for filling test

* Fix possible errors in add_filling and remove_filling

* Enable adding fillings from the opening object ui

* Typo

* Revert "Enable adding fillings from the opening object ui"

This reverts commit b217860840.

* Display a list of all fillings when an opening is selected

* Ensure an IfcOpeningElement can't be voided

* merge 0.7.0

* Add test cases for filling operators

* Test Opening operators

* Delete related fill relations on object deletion

* Remove try/except

* typo

* Minor fix

* Remove boolean modifier on previous element when voiding a new one

* Don't show ui elements when not applicable

* Test filling void b with an element that already fills void a
correctly removes the filling from void a

Co-authored-by: Dion Moult <dion@thinkmoult.com>
This commit is contained in:
Gorgious56
2021-09-29 08:27:43 +02:00
committed by GitHub
parent 24eac8ccdd
commit 2ed30ef0a2
5 changed files with 400 additions and 21 deletions
@@ -38,6 +38,99 @@ class TestAddOpening(test.bim.bootstrap.NewFile):
And the object "IfcWall/Cube" is voided by "Cube"
"""
@test.bim.bootstrap.scenario
def test_adding_an_opening_on_an_opening(self):
"""An opening can't legally be voided by another opening"""
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And the object "IfcOpeningElement/Cube" is selected
And additionally the object "IfcOpeningElement/Cube.001" is selected
And I press "bim.add_opening(opening='IfcOpeningElement/Cube', obj='IfcOpeningElement/Cube.001')"
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the object "IfcOpeningElement/Cube" should display as "WIRE"
And the object "IfcOpeningElement/Cube" is not a void
Then the object "IfcOpeningElement/Cube.001" is an "IfcOpeningElement"
And the object "IfcOpeningElement/Cube.001" should display as "WIRE"
Then the object "IfcOpeningElement/Cube.001" has no boolean difference by "IfcOpeningElement/Cube"
And the object "IfcOpeningElement/Cube.001" is not voided by "Cube"
"""
@test.bim.bootstrap.scenario
def test_adding_an_opening_on_a_null_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I deselect all objects
And I press "bim.add_opening(opening='IfcOpeningElement/Cube')"
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the object "IfcOpeningElement/Cube" should display as "WIRE"
And the object "IfcOpeningElement/Cube" is not a void
"""
@test.bim.bootstrap.scenario
def test_adding_an_opening_on_a_non_ifc_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I press "bim.add_opening(opening='IfcOpeningElement/Cube', obj='Cube')"
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the object "IfcOpeningElement/Cube" should display as "WIRE"
And the object "IfcOpeningElement/Cube" is not a void
And the object "Cube" is not an IFC element
"""
@test.bim.bootstrap.scenario
def test_adding_an_opening_with_a_null_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And I deselect all objects
And I press "bim.add_opening(obj='IfcWall/Cube')"
Then the object "IfcWall/Cube" is an "IfcWall"
And the object "IfcWall/Cube" is not voided
"""
@test.bim.bootstrap.scenario
def test_adding_an_opening_to_element_b_with_a_void_that_already_voids_element_a(self):
"""An opening can legally void at most one element"""
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And I add a cube
And I press "bim.add_opening(opening='Cube', obj='IfcWall/Cube')"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And I press "bim.add_opening(opening='IfcOpeningElement/Cube', obj='IfcWall/Cube.001')"
Then the object "IfcWall/Cube" is not voided
And the object "IfcWall/Cube" has no boolean difference by "IfcOpeningElement/Cube"
And the object "IfcWall/Cube.001" is voided by "Cube"
And the object "IfcWall/Cube.001" has a boolean difference by "IfcOpeningElement/Cube"
"""
class TestRemoveOpening(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
@@ -115,3 +208,197 @@ class TestRemoveOpening(test.bim.bootstrap.NewFile):
And I delete the selected objects
Then the object "Cube" is not an IFC element
"""
class TestAddFilling(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_adding_a_filling(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And the object "IfcOpeningElement/Cube" is selected
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='IfcDoor/Cube')"
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the object "IfcOpeningElement/Cube" should display as "WIRE"
And the object "IfcDoor/Cube" is an "IfcDoor"
And the void "IfcOpeningElement/Cube" is filled by "Cube"
"""
@test.bim.bootstrap.scenario
def test_adding_a_filling_on_null_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And the object "IfcDoor/Cube" is selected
And I press "bim.add_filling(obj='IfcDoor/Cube')"
Then the object "IfcDoor/Cube" is an "IfcDoor"
And the object "IfcDoor/Cube" is not a filling
"""
@test.bim.bootstrap.scenario
def test_adding_a_filling_on_itself(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And the object "IfcOpeningElement/Cube" is selected
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='IfcOpeningElement/Cube')"
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the void "IfcOpeningElement/Cube" is not filled by "Cube"
And the object "IfcOpeningElement/Cube" is not a filling
"""
@test.bim.bootstrap.scenario
def test_adding_a_filling_with_a_non_ifc_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "IfcOpeningElement/Cube" is selected
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='Cube')"
Then the object "Cube" is not an IFC element
And the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the void "IfcOpeningElement/Cube" is not filled by "Cube"
"""
@test.bim.bootstrap.scenario
def test_adding_a_filling_on_a_non_ifc_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I press "bim.add_filling(opening='Cube', obj='IfcDoor/Cube')"
Then the object "Cube" is not an IFC element
And the object "IfcDoor/Cube" is an "IfcDoor"
"""
@test.bim.bootstrap.scenario
def test_adding_a_filling_on_opening_b_when_the_filling_alread_fills_element_a(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='IfcDoor/Cube')"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I press "bim.add_filling(opening='IfcOpeningElement/Cube.001', obj='IfcDoor/Cube')"
Then the void "IfcOpeningElement/Cube" is not filled by "Cube"
And the void "IfcOpeningElement/Cube.001" is filled by "Cube"
"""
class TestRemoveFilling(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_removing_a_filling(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='IfcDoor/Cube')"
And I press "bim.remove_filling(obj='IfcDoor/Cube')"
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the object "IfcDoor/Cube" is an "IfcDoor"
And the void "IfcOpeningElement/Cube" is not filled by "Cube"
"""
@test.bim.bootstrap.scenario
def test_removing_a_filling_which_is_not_an_ifc_object(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I press "bim.remove_filling(obj='Cube')"
Then the object "Cube" is not an IFC element
"""
@test.bim.bootstrap.scenario
def test_removing_a_filling_which_is_not_a_filling(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And I press "bim.remove_filling(obj='IfcDoor/Cube')"
Then the object "IfcDoor/Cube" is an "IfcDoor"
And the object "IfcDoor/Cube" is not a filling
"""
@test.bim.bootstrap.scenario
def test_removing_a_filling_which_is_null(self):
return """
Given an empty IFC project
And I press "bim.remove_filling()"
Then nothing interesting happens
"""
@test.bim.bootstrap.scenario
def test_removing_a_filling_using_deletion_on_the_filling(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='IfcDoor/Cube')"
And the object "IfcDoor/Cube" is selected
And I delete the selected objects
Then the object "IfcOpeningElement/Cube" is an "IfcOpeningElement"
And the void "IfcOpeningElement/Cube" is not filled by "Cube"
"""
@test.bim.bootstrap.scenario
def test_removing_a_filling_using_deletion_on_the_opening(self):
return """
Given an empty IFC project
And I add a cube
When the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcOpeningElement"
And I press "bim.assign_class"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcDoor"
And I press "bim.assign_class"
And I press "bim.add_filling(opening='IfcOpeningElement/Cube', obj='IfcDoor/Cube')"
And the object "IfcOpeningElement/Cube" is selected
And I delete the selected objects
Then the object "IfcDoor/Cube" is an "IfcDoor"
And the object "IfcDoor/Cube" is not a filling
"""