How to find the bounding shape of a complex brep?

I have a complex geometrical challenge relating to the automated feature extraction of fairly simple brep/mesh solids. I am trying to recognize the “master” outline shape of a CLT-wall panel that has a varying amount of holes, cutouts and edge tilts. I have created a solution that works to a certain degree but requires manual tweaking on some more complex situations. I am trying to get rid of this manual part.

So here’s a good representative of such shapes. It has a non-box-like shape but is perpendicular on all, but one side. For a human it is easy to recognise the cutouts. The selected (yellow) curve represents the optimal bounding outline of the master shape, where the cutouts have been removed.

Here is the solution I would like to end up with.

My current solution finds the footprint of the part, which is not the optimum solution, as cannot filter out the cutouts. The algorithm here is simple, basically mesh shadow with -Z projection.

Another parallel solution I have is to extract top and bottom surfaces, and use them to identify edge tilts. However, this solution obviously fails on situations like this, where there are cutouts.

I’m using another process to identify the cutouts themselves, by basically evaluation top or bottom oriented surfaces. This again is fairly trivial. But what is not trivial is how to “fill” these cutouts.

Here’s a simplified version of the current algorithm. There’s a bit more quality control done and for instance hole recognition, but I redacted that part for this question.

Shape (13.7 KB)

I’m dabbling with an idea to somehow identify and extract a continuous horisontal surface loop. If +/-Z oriented surfaces are removed, this particular object can be defined with 4 different surface loops. The largest being the optimal solution here.

But how tofind that loop or “untrim” it? Orient top/bottom edges along surface to minZ and maxZ?

Any ideas on this?

[The tilt(s) can be on any side(s), but the top and bottom are always flat. The amout and position of the cutouts are arbitrary, and they can be on top or bottom side, or on both.]

[Another example shape:


Try this:

Shape recognition (15.7 KB)

Thank you, this is actually a very simple solution. And it seems to work.
The simplifying of the curve is a clever way to get rid of the extra faces.

I added a tentative hole removal to test it with the other shape - and works perfectly.