# How to get information about openings in a shape?

Forums:

Hello everyone,

i want to disassemble a shape, save it in three lists (a vertices list with coordinates, a edges list with numbers of vertices that refer to the vertices list, a wires list with numbers of edges that refer to the edges list) and rebuild the shape again afterwards.

It works fine for most of the shapes, but i have some trouble with openings: If my shape is a building block with an opening (e. g. a wall with space for a window), the opening will be closed (see attached picture, the left one is the original shape, the right one is the rebuilt shape). My algorithm builds a face of the four outer edges that will cover the opening and it also builds another face for the opening itself.

I tried to use BRepFeat.brepfeat.IsInside() and compare the rebuilt faces to each other. If the order was true, i tried to cut out the inner face via BRepBuilderAPI.MakeFace.Add(). I did not succeed in doing this because the result of BRepFeat.brepfeat.IsInside() is also True for some faces that are parallel to another face. Am i doing something wrong in using this function?

My current solution is to disassemble the shape again – this time in faces – after rebuilding it, calculate the distance between the faces with BRepExtrema_DistShapeShape and get a boolean for BRepExtrema_ExtFF.IsParallel. If it’s true and the distance equals 0, i cut out the face with the minor surface. It works, but it uses many process steps.

It might work better if i use the information about how Open CASCADE handles these cases internally (e. g. how it stores the information that the face has an opening and that another face is the opening itself). Maybe i could also save it in the wires list and directly build a shape with openings. Is it possible to implement this approach? Does anyone have an idea how to do so?

Stefan

Attachments:

Hi Stefan,

I think your approach will only work if all faces are planer and all edges are straight line's? (so you don't have to store surfaces and curve info)

A face refers to a list of wires (and to an underlaying surface). The first wire of the face is the outer-wire, the other wires are holes. (Only one level deep)

When storing your points/edges/wires you should walk over the faces and then walk over the wires of each face.

So inststead of wire as "toplevel" you should have the face as top-level, referring to the wires indices? (1 wire if no hole's)

Now you can rebuild your face with BRepBuilderAPI_MakeFace: Put the first wire in the constructor, the other(holes) wires with Add(..)

If you do a dump (BRepTools::Dump(..)  of your shape you can see how OCC is internally keeping its data structure of a TopoDS_Shape.

Here is a dump of a face with a hole: DumpExample

Hope it help's you..

Best regards, Guido

Hi Guido,

thanks for your quick response. That’s correct, i only want to connect the vertices straight and use planar faces, so that could be a solution for my problem. I’ll check into it. Thanks a lot!

Stefan