(self, ifc_file: ifcopenshell.file, should_filter_version: bool = False)
| 280 | return self.is_ifc_version |
| 281 | |
| 282 | def validate(self, ifc_file: ifcopenshell.file, should_filter_version: bool = False) -> None: |
| 283 | if should_filter_version and not self.is_ifc_version: |
| 284 | return |
| 285 | |
| 286 | elements = None |
| 287 | |
| 288 | # This is a broadphase filter of applicability. We almost never want to |
| 289 | # test every single class in an IFC model. |
| 290 | for i, facet in enumerate(self.applicability): |
| 291 | elements = facet.filter(ifc_file, elements) |
| 292 | |
| 293 | for element in elements or []: |
| 294 | is_applicable = True |
| 295 | for facet in self.applicability: |
| 296 | if isinstance(facet, Entity): |
| 297 | continue |
| 298 | if not bool(facet(element)): |
| 299 | is_applicable = False |
| 300 | break |
| 301 | if not is_applicable: |
| 302 | continue |
| 303 | self.applicable_entities.append(element) |
| 304 | if self.maxOccurs != 0: # Requirements are skipped for prohibited applicability |
| 305 | for facet in self.requirements: |
| 306 | result = facet(element) |
| 307 | if bool(result): |
| 308 | self.passed_entities.add(element) |
| 309 | facet.passed_entities.add(element) |
| 310 | else: |
| 311 | self.failed_entities.add(element) |
| 312 | facet.failures.append(FacetFailure(element=element, reason=str(result))) |
| 313 | |
| 314 | self.status = True |
| 315 | for facet in self.requirements: |
| 316 | facet.status = not bool(facet.failures) |
| 317 | if not facet.status: |
| 318 | self.status = False |
| 319 | |
| 320 | if self.minOccurs != 0: # Required specification |
| 321 | if not self.applicable_entities: |
| 322 | self.status = False |
| 323 | for facet in self.requirements: |
| 324 | facet.status = False |
| 325 | elif self.maxOccurs == 0: # Prohibited specification |
| 326 | if self.applicable_entities: |
| 327 | self.status = False |
| 328 | |
| 329 | def get_usage(self) -> Cardinality: |
| 330 | if self.minOccurs != 0: |
nothing calls this directly
no test coverage detected