mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 05:46:51 +00:00
Fix test Model.get_manual_booleans after we added pset to store them
This commit is contained in:
@@ -478,7 +478,7 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
return {"thickness": thickness, "offset": offset, "direction_sense": direction_sense}
|
return {"thickness": thickness, "offset": offset, "direction_sense": direction_sense}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_booleans(cls, element=None, representation=None):
|
def get_booleans(cls, element=None, representation=None) -> list[ifcopenshell.entity_instance]:
|
||||||
if representation is None:
|
if representation is None:
|
||||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
if not representation:
|
if not representation:
|
||||||
@@ -493,7 +493,7 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
return booleans
|
return booleans
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_manual_booleans(cls, element, representation=None):
|
def get_manual_booleans(cls, element, representation=None) -> list[ifcopenshell.entity_instance]:
|
||||||
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Boolean")
|
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Boolean")
|
||||||
if not pset:
|
if not pset:
|
||||||
return []
|
return []
|
||||||
@@ -502,7 +502,7 @@ class Model(blenderbim.core.tool.Model):
|
|||||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
if not representation:
|
if not representation:
|
||||||
return []
|
return []
|
||||||
booleans = [b for b in cls.get_booleans(element) if b.id() in boolean_ids]
|
booleans = [b for b in cls.get_booleans(element, representation) if b.id() in boolean_ids]
|
||||||
return booleans
|
return booleans
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -55,58 +55,44 @@ class TestGenerateOccurrenceName(NewFile):
|
|||||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||||
|
|
||||||
|
|
||||||
class TestGetManualBooleans(NewFile):
|
class TestGetBooleans(NewFile):
|
||||||
def test_get_manual_booleans(self):
|
def test_run(self):
|
||||||
clippings = [
|
|
||||||
{
|
|
||||||
"type": "IfcBooleanClippingResult",
|
|
||||||
"operand_type": "IfcHalfSpaceSolid",
|
|
||||||
"matrix": np.eye(4).tolist(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "IfcBooleanResult",
|
|
||||||
"operand_type": "IfcHalfSpaceSolid",
|
|
||||||
"matrix": np.eye(4).tolist(),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
self.ifc = ifc
|
|
||||||
tool.Ifc.set(ifc)
|
tool.Ifc.set(ifc)
|
||||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
|
||||||
length = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT")
|
|
||||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[length])
|
|
||||||
ifcopenshell.api.run("unit.assign_unit", ifc)
|
|
||||||
element = ifc.createIfcColumn()
|
|
||||||
hea100 = ifc.create_entity(
|
|
||||||
"IfcIShapeProfileDef",
|
|
||||||
ProfileName="HEA100",
|
|
||||||
ProfileType="AREA",
|
|
||||||
OverallWidth=100,
|
|
||||||
OverallDepth=96,
|
|
||||||
WebThickness=5,
|
|
||||||
FlangeThickness=8,
|
|
||||||
FilletRadius=12,
|
|
||||||
)
|
|
||||||
model3d = ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
|
||||||
body = ifcopenshell.api.run(
|
|
||||||
"context.add_context",
|
|
||||||
ifc,
|
|
||||||
context_type="Model",
|
|
||||||
context_identifier="Body",
|
|
||||||
target_view="MODEL_VIEW",
|
|
||||||
parent=model3d,
|
|
||||||
)
|
|
||||||
representation = ifcopenshell.api.run(
|
|
||||||
"geometry.add_profile_representation", ifc, context=body, profile=hea100, depth=5, clippings=clippings
|
|
||||||
)
|
|
||||||
ifcopenshell.api.run("geometry.assign_representation", ifc, product=element, representation=representation)
|
|
||||||
|
|
||||||
booleans = subject.get_booleans(element)
|
context = ifc.createIfcGeometricRepresentationContext()
|
||||||
assert len(booleans) == 2
|
element = ifc.createIfcWall()
|
||||||
assert len(subject.get_manual_booleans(element)) == 0
|
|
||||||
subject.mark_manual_booleans(element, booleans)
|
items = [ifc.createIfcExtrudedAreaSolid(), ifc.createIfcExtrudedAreaSolid()]
|
||||||
assert len(subject.get_manual_booleans(element)) == 2
|
representation = ifc.createIfcShapeRepresentation(Items=items, ContextOfItems=context)
|
||||||
|
tool.Ifc.run("geometry.assign_representation", product=element, representation=representation)
|
||||||
|
|
||||||
|
bool1 = set(tool.Ifc.run("geometry.add_boolean", representation=representation, matrix=np.eye(4)))
|
||||||
|
bool2 = set(tool.Ifc.run("geometry.add_boolean", representation=representation, matrix=np.eye(4)))
|
||||||
|
|
||||||
|
assert set(subject.get_booleans(element, representation)) == bool1 | bool2
|
||||||
|
|
||||||
|
|
||||||
|
class TestGetManualBooleans(NewFile):
|
||||||
|
def test_run(self):
|
||||||
|
ifc = ifcopenshell.file()
|
||||||
|
tool.Ifc.set(ifc)
|
||||||
|
|
||||||
|
context = ifc.createIfcGeometricRepresentationContext()
|
||||||
|
element = ifc.createIfcWall()
|
||||||
|
|
||||||
|
items = [ifc.createIfcExtrudedAreaSolid(), ifc.createIfcExtrudedAreaSolid()]
|
||||||
|
representation = ifc.createIfcShapeRepresentation(Items=items, ContextOfItems=context)
|
||||||
|
tool.Ifc.run("geometry.assign_representation", product=element, representation=representation)
|
||||||
|
|
||||||
|
bool1 = set(tool.Ifc.run("geometry.add_boolean", representation=representation, matrix=np.eye(4)))
|
||||||
|
bool2 = set(tool.Ifc.run("geometry.add_boolean", representation=representation, matrix=np.eye(4)))
|
||||||
|
|
||||||
|
assert set(subject.get_booleans(element, representation)) == bool1 | bool2
|
||||||
|
assert len(subject.get_manual_booleans(element, representation)) == 0
|
||||||
|
|
||||||
|
subject.mark_manual_booleans(element, bool1)
|
||||||
|
assert set(subject.get_manual_booleans(element, representation)) == bool1
|
||||||
|
|
||||||
|
|
||||||
class TestMarkManualBooleans(NewFile):
|
class TestMarkManualBooleans(NewFile):
|
||||||
|
|||||||
Reference in New Issue
Block a user