2021-01-12 15:12:53 +11:00
|
|
|
class Data:
|
|
|
|
|
products = {}
|
|
|
|
|
openings = {}
|
|
|
|
|
fillings = {}
|
|
|
|
|
|
2021-02-03 17:30:19 +11:00
|
|
|
@classmethod
|
|
|
|
|
def purge(cls):
|
|
|
|
|
cls.products = {}
|
|
|
|
|
cls.openings = {}
|
|
|
|
|
cls.fillings = {}
|
|
|
|
|
|
2021-01-12 15:12:53 +11:00
|
|
|
@classmethod
|
2021-03-25 10:48:31 +11:00
|
|
|
def load(cls, file, product_id):
|
2021-01-12 15:12:53 +11:00
|
|
|
if not file:
|
|
|
|
|
return
|
|
|
|
|
cls.products[product_id] = set()
|
2021-01-12 16:39:01 +11:00
|
|
|
if product_id in cls.fillings:
|
|
|
|
|
del cls.fillings[product_id]
|
2021-01-12 15:12:53 +11:00
|
|
|
product = file.by_id(product_id)
|
|
|
|
|
for rel in file.by_type("IfcRelVoidsElement"):
|
|
|
|
|
building_element = rel.RelatingBuildingElement
|
|
|
|
|
if building_element != product:
|
|
|
|
|
continue
|
|
|
|
|
opening = rel.RelatedOpeningElement
|
|
|
|
|
opening_id = int(opening.id())
|
|
|
|
|
cls.products[product_id].add(opening_id)
|
|
|
|
|
cls.openings[opening_id] = {"Name": opening.Name, "HasFillings": set()}
|
|
|
|
|
for rel in file.by_type("IfcRelFillsElement"):
|
|
|
|
|
opening = rel.RelatingOpeningElement
|
|
|
|
|
opening_id = int(opening.id())
|
|
|
|
|
filling = rel.RelatedBuildingElement
|
|
|
|
|
filling_id = int(filling.id())
|
2021-01-12 16:39:01 +11:00
|
|
|
|
|
|
|
|
if filling_id == product_id and opening_id not in cls.openings:
|
|
|
|
|
cls.openings[opening_id] = {"Name": opening.Name, "HasFillings": set()}
|
|
|
|
|
|
|
|
|
|
if opening_id not in cls.openings:
|
|
|
|
|
continue
|
|
|
|
|
|
2021-01-12 15:12:53 +11:00
|
|
|
cls.fillings[filling_id] = {"Name": filling.Name, "FillsVoid": opening_id}
|
|
|
|
|
cls.openings[opening_id]["HasFillings"].add(filling_id)
|
|
|
|
|
return # See bug #1224
|
2021-09-09 21:27:23 +10:00
|
|
|
# if not hasattr(product, "HasOpenings") or not product.HasOpenings:
|
2021-01-12 15:12:53 +11:00
|
|
|
# return
|
2021-09-09 21:27:23 +10:00
|
|
|
# for rel_voids_element in product.HasOpenings:
|
2021-01-12 15:12:53 +11:00
|
|
|
# opening = rel_voids_element.RelatedOpeningElement
|
|
|
|
|
# opening_id = int(opening.id())
|
|
|
|
|
# fillings = []
|
|
|
|
|
# if opening.HasFillings:
|
|
|
|
|
# for rel_fills_element in opening.HasFillings:
|
|
|
|
|
# filling = rel_fills_element.RelatedBuildingElement
|
|
|
|
|
# filling_id = int(filling.id())
|
|
|
|
|
# fillings.append(filling_id)
|
|
|
|
|
# cls.fillings[filling_id] = {
|
|
|
|
|
# "Name": filling.Name,
|
|
|
|
|
# }
|
|
|
|
|
# cls.openings[opening_id] = {
|
|
|
|
|
# "Name": opening.Name,
|
|
|
|
|
# "HasFillings": fillings,
|
|
|
|
|
# }
|
|
|
|
|
# cls.products[product_id].append(opening_id)
|