IfcOpenShell / IfcOpenShell

Open source IFC library and geometry engine
GNU Lesser General Public License v3.0
1.83k stars 723 forks source link

Freeze when running iterator with context-ids filter #5490

Open theoryshaw opened 6 days ago

theoryshaw commented 6 days ago

Bonsai/Blender freezes up trying to open the following .ifc file. Cntl-alt-delete doesn't even work to exit out the program. Gnarly.

https://hub.openingdesign.com/OpeningDesign/Lake_Kegonsa_Renovation/src/commit/13d34c363c85fbb5355017ddeb5a07671ded9432/Open/Models/BlenderBIM/Lake_Kegonsa_Renovation.ifc

Moult commented 3 days ago

This is a weird one but I've managed to isolate it to a single element, and it only freezes if we run the iterator with a context filter. Ping @aothms to take a peek:

import faulthandler
import os
import sys
import numpy as np
import time
import multiprocessing
import ifcopenshell
import ifcopenshell.util.representation
import ifcopenshell.geom
import ifcopenshell.ifcopenshell_wrapper as wrapper
faulthandler.enable()

wrapper.turn_on_detailed_logging()

s = time.time()

import json
ifc_file = ifcopenshell.open('/home/dion/tmp/loadbug/Lake_Kegonsa_Renovation.ifc')
products = [ifc_file.by_guid("1C2VCFvL1E$wqXkkMR7GKt")]
print(products)
print(time.time() - s)
context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
print(context.id())
s = time.time()
settings = ifcopenshell.geom.settings()

# If you comment this line out, it doesn't freeze
settings.set("context-ids", [context.id()])

iterator = ifcopenshell.geom.iterator(settings, ifc_file, multiprocessing.cpu_count(), include=products, geometry_library="opencascade")
if iterator.initialize():
    i = 0
    while True:
        shape = iterator.get()
        print(i, len(shape.geometry.verts))
        if not iterator.next():
            break
        i += 1
print(time.time() - s)
sys.exit()
aothms commented 3 days ago

I only had a quick look, but you have this sanitary terminal 1C2VCFvL1E$wqXkkMR7GKt

afbeelding

which is part of an IfcElementAssembly 0nTjcIgbf7$ew$AC4L0OfL, which has 3 voids.

Applying the openings to the assembly means you apply it to this sink as well. Is that intended?

theoryshaw commented 3 days ago

No i don't think that was indented.