mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
fix(ifctester): accept tuple results when chaining facet filters
Facet.filter() implementations broad-phase query with ifc_file.by_type(), then check isinstance(elements, list) to decide whether a previous facet already narrowed the candidate set. In v0.9.0, file.by_type() returns a tuple instead of a list, so that check silently failed and every facet after the first re-scanned the whole model instead of the already-narrowed (possibly empty) set. This let a prohibited Entity+Attribute applicability match instances of the wrong class, e.g. an IfcSlab satisfying an "IFCWALL" Entity facet's chain. Accept tuples too, matching how by_type() results are actually returned now.
This commit is contained in:
committed by
Thomas Krijnen
parent
e7370dff9f
commit
df3d07e952
@@ -201,7 +201,7 @@ class Entity(Facet):
|
|||||||
def filter(
|
def filter(
|
||||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]] = None
|
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]] = None
|
||||||
) -> list[ifcopenshell.entity_instance]:
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
if isinstance(elements, list):
|
if isinstance(elements, (list, tuple)):
|
||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
|
|
||||||
if isinstance(self.name, str):
|
if isinstance(self.name, str):
|
||||||
@@ -280,7 +280,7 @@ class Attribute(Facet):
|
|||||||
def filter(
|
def filter(
|
||||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
||||||
) -> list[ifcopenshell.entity_instance]:
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
if isinstance(elements, list):
|
if isinstance(elements, (list, tuple)):
|
||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
@@ -415,7 +415,7 @@ class Classification(Facet):
|
|||||||
def filter(
|
def filter(
|
||||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
||||||
) -> list[ifcopenshell.entity_instance]:
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
if isinstance(elements, list):
|
if isinstance(elements, (list, tuple)):
|
||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
return ifc_file.by_type("IfcObjectDefinition")
|
return ifc_file.by_type("IfcObjectDefinition")
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ class PartOf(Facet):
|
|||||||
def filter(
|
def filter(
|
||||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
||||||
) -> list[ifcopenshell.entity_instance]:
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
if isinstance(elements, list):
|
if isinstance(elements, (list, tuple)):
|
||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
return list(ifc_file) # Lazy
|
return list(ifc_file) # Lazy
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ class Property(Facet):
|
|||||||
def filter(
|
def filter(
|
||||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
||||||
) -> list[ifcopenshell.entity_instance]:
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
if isinstance(elements, list):
|
if isinstance(elements, (list, tuple)):
|
||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
if ifc_file.schema == "IFC2X3":
|
if ifc_file.schema == "IFC2X3":
|
||||||
return ifc_file.by_type("IfcObjectDefinition")
|
return ifc_file.by_type("IfcObjectDefinition")
|
||||||
@@ -946,7 +946,7 @@ class Material(Facet):
|
|||||||
def filter(
|
def filter(
|
||||||
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
self, ifc_file: ifcopenshell.file, elements: Optional[list[ifcopenshell.entity_instance]]
|
||||||
) -> list[ifcopenshell.entity_instance]:
|
) -> list[ifcopenshell.entity_instance]:
|
||||||
if isinstance(elements, list):
|
if isinstance(elements, (list, tuple)):
|
||||||
return super().filter(ifc_file, elements)
|
return super().filter(ifc_file, elements)
|
||||||
return ifc_file.by_type("IfcObjectDefinition")
|
return ifc_file.by_type("IfcObjectDefinition")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user