First attempt at ripping out agnostic code into ifcopenshell.api namespace. See #1399.

This commit is contained in:
Dion Moult
2021-03-25 10:48:31 +11:00
parent 911d703f57
commit d77bc6bdaa
190 changed files with 388 additions and 437 deletions
@@ -0,0 +1,36 @@
class Data:
products = {}
representations = {}
@classmethod
def purge(cls):
cls.products = {}
cls.representations = {}
@classmethod
def load(cls, file, product_id):
if not file:
return
cls.products[product_id] = []
product = file.by_id(product_id)
representations = []
if product.is_a("IfcProduct"):
if product.Representation:
representations = product.Representation.Representations
else:
representations = []
elif product.is_a("IfcTypeProduct"):
representations = [rm.MappedRepresentation for rm in product.RepresentationMaps or []]
for representation in representations:
c = representation.ContextOfItems
rep_id = int(representation.id())
cls.representations[rep_id] = {
"RepresentationIdentifier": representation.RepresentationIdentifier,
"RepresentationType": representation.RepresentationType,
"ContextOfItems": {
"ContextType": c.ContextType,
"ContextIdentifier": c.ContextIdentifier,
"TargetView": c.TargetView if c.is_a("IfcGeometricRepresentationSubContext") else "",
}
}
cls.products[product_id].append(rep_id)