MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / process_clash_set

Method process_clash_set

src/ifcclash/ifcclash/ifcclash.py:93–154  ·  view source on GitHub ↗
(self, clash_set: ClashSet)

Source from the content-addressed store, hash-verified

91 self.process_clash_set(clash_set)
92
93 def process_clash_set(self, clash_set: ClashSet) -> None:
94 self.tree = ifcopenshell.geom.tree()
95 self.create_group("a")
96 for source in clash_set["a"]:
97 source["ifc"] = self.load_ifc(source["file"])
98 self.add_collision_objects("a", source["ifc"], source)
99
100 if "b" in clash_set and clash_set["b"]:
101 self.create_group("b")
102 for source in clash_set["b"]:
103 source["ifc"] = self.load_ifc(source["file"])
104 self.add_collision_objects("b", source["ifc"], source)
105 b = "b"
106 else:
107 b = "a"
108
109 mode = clash_set["mode"]
110 if mode == "intersection":
111 assert "tolerance" in clash_set and "check_all" in clash_set
112 results = self.tree.clash_intersection_many(
113 list(self.groups["a"]["elements"].values()),
114 list(self.groups[b]["elements"].values()),
115 tolerance=clash_set["tolerance"],
116 check_all=clash_set["check_all"],
117 )
118 elif mode == "collision":
119 assert "allow_touching" in clash_set
120 results = self.tree.clash_collision_many(
121 list(self.groups["a"]["elements"].values()),
122 list(self.groups[b]["elements"].values()),
123 allow_touching=clash_set["allow_touching"],
124 )
125 elif mode == "clearance":
126 assert "clearance" in clash_set and "check_all" in clash_set
127 results = self.tree.clash_clearance_many(
128 list(self.groups["a"]["elements"].values()),
129 list(self.groups[b]["elements"].values()),
130 clearance=clash_set["clearance"],
131 check_all=clash_set["check_all"],
132 )
133 else:
134 assert_never(mode)
135
136 processed_results: dict[str, ClashResult] = {}
137 for result in results:
138 element1 = result.a
139 element2 = result.b
140
141 processed_results[f"{element1.get_argument(0)}-{element2.get_argument(0)}"] = ClashResult(
142 a_global_id=element1.get_argument(0),
143 b_global_id=element2.get_argument(0),
144 a_ifc_class=element1.is_a(),
145 b_ifc_class=element2.is_a(),
146 a_name=element1.get_argument(2),
147 b_name=element2.get_argument(2),
148 type=self.tree.get_clash_type(result.clash_type),
149 p1=list(result.p1),
150 p2=list(result.p2),

Callers 1

clashMethod · 0.95

Calls 12

create_groupMethod · 0.95
load_ifcMethod · 0.95
add_collision_objectsMethod · 0.95
ClashResultClass · 0.85
valuesMethod · 0.80
get_clash_typeMethod · 0.80
treeMethod · 0.45
clash_collision_manyMethod · 0.45
clash_clearance_manyMethod · 0.45
is_aMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected