See the attached file. The current algorithm, which is based on trimming down the common bounding box of all space boundaries, doesn't work in the general case. I see two possible solutions:

1) Find all space boundaries necessary to create a closed shape and construct the space object shape from that.

2) Keep the current algorithm, but segment the space into multiple virtual spaces that each are convex and build a compound out of them.

The first idea seems more natural, easy to understand and intuitive. Also we should have a full set of space boundaries for IFC export, calculations etc. However the downside is, that picking many faces (some of which aren't necessarily true space boundaries) might be annoying and holes like windows might cause trouble as well.

Also a mixed approach might be possible. I haven't thought about this in detail yet.

Any ideas or opinions?

Harald