| 92 | self.filter_elements = filter_elements |
| 93 | |
| 94 | def diff(self) -> None: |
| 95 | logging.disable(logging.CRITICAL) |
| 96 | |
| 97 | self.precision = self.get_precision() |
| 98 | |
| 99 | if self.filter_elements: |
| 100 | old_elements = set( |
| 101 | e.GlobalId for e in ifcopenshell.util.selector.filter_elements(self.old, self.filter_elements) |
| 102 | ) |
| 103 | new_elements = set( |
| 104 | e.GlobalId for e in ifcopenshell.util.selector.filter_elements(self.new, self.filter_elements) |
| 105 | ) |
| 106 | else: |
| 107 | old_elements = self.old.by_type("IfcElement") |
| 108 | if self.old.schema == "IFC2X3": |
| 109 | old_elements += self.old.by_type("IfcSpatialStructureElement") |
| 110 | else: |
| 111 | old_elements += self.old.by_type("IfcSpatialElement") |
| 112 | old_elements = set(e.GlobalId for e in old_elements if not e.is_a("IfcFeatureElement")) |
| 113 | new_elements = self.new.by_type("IfcElement") |
| 114 | if self.new.schema == "IFC2X3": |
| 115 | new_elements += self.new.by_type("IfcSpatialStructureElement") |
| 116 | else: |
| 117 | new_elements += self.new.by_type("IfcSpatialElement") |
| 118 | new_elements = set(e.GlobalId for e in new_elements if not e.is_a("IfcFeatureElement")) |
| 119 | |
| 120 | print(" - {} item(s) are in the old model".format(len(old_elements))) |
| 121 | print(" - {} item(s) are in the new model".format(len(new_elements))) |
| 122 | |
| 123 | self.deleted_elements = old_elements - new_elements |
| 124 | self.added_elements = new_elements - old_elements |
| 125 | same_elements = new_elements - self.added_elements |
| 126 | total_same_elements = len(same_elements) |
| 127 | |
| 128 | print(" - {} item(s) were added".format(len(self.added_elements))) |
| 129 | print(" - {} item(s) were deleted".format(len(self.deleted_elements))) |
| 130 | print(" - {} item(s) are common to both models".format(total_same_elements)) |
| 131 | |
| 132 | total_diffed = 0 |
| 133 | |
| 134 | potential_old_changes = [] |
| 135 | potential_new_changes = [] |
| 136 | |
| 137 | should_check_attributes = False |
| 138 | should_check_geometry = False |
| 139 | should_check_other = False |
| 140 | |
| 141 | for relationship in self.relationships: |
| 142 | if relationship == "attributes": |
| 143 | should_check_attributes = True |
| 144 | elif relationship == "geometry": |
| 145 | should_check_geometry = True |
| 146 | else: |
| 147 | should_check_other = True |
| 148 | |
| 149 | for global_id in same_elements: |
| 150 | total_diffed += 1 |
| 151 | if total_diffed % 250 == 0: |