Something strange about BRepAlgoAPI_Cut

Dear developers,

I noticed some strange behaviour of the BRepAlgoAPI_Cut. If a face is built with BRepBuilderAPI_MakeFace and has a shape like the attached picture 'No_Shape_Cut.png', the BRepAlgoAPI_Cut won't cut anything out of the face. It basically comes down to faces with material inside a hole. Faces with holes, built with BRepBuilderAPI_MakeFace, don't give any problem. Faces with material inside the holes built with a second BRepAlgoAPI_Cut (so create the hole in the face with the BRepAlgoAPI_Cut algorithm) don't give any problems as well.

Could this be an error? Also, does there exist another way to create faces with holes other than BRepBuilderAPI_MakeFace or BRepAlgoAPI_Cut (BRepAlgoAPI_Cut will take too much time).

I attached a some code that tests this situation. Note that it is written in Python, as I'm using the PythonOCC wrapper.

Kind Regards,
Thieme

Kirill Gavrilov's picture

It basically comes down to faces with material inside a hole.

TopoDS_Face "with material inside a hole" defines an invalid B-Rep (at least in OCCT notation), so it is not a surprise that algorithms fail on such invalid input. The shape like on your screenshot should be defined by two Faces (I would expect that passing such a Face to ShapeFix_Face tool with ShapeFix_Face::FixSplitFaceMode mode will produce two Faces).

Thieme Vandeput's picture

Dear Kirill,

Thank you for your reply. It indeed makes sense, I was confused because you can display this 'invalid B-Rep'. However, ShapeFix_Face::FixSplitFaceMode just returns the original face. Any other ways to split the faces that comes to mind? Or should it split the faces and am I doing something wrong? Otherwise I'll just create my own workaround. (below some code)

faceFixer = ShapeFix_Face()
faceFixer.Init(lattice)                        #Lattice -> TopoDS_Face
faceFixer.SetFixSplitFaceMode(1)
faceFixer.Perform()
result = faceFixer.Result()

Kirill Gavrilov's picture

If could be useful attaching a generated model as a .brep file (via BRepTools::Write() or BinTools::Write()) - it would allow playing with it in Draw Harness.

In general, direct modeling algorithms are expected to produce a valid geometry, while shape healing algorithms are supposed to deal with externally provided geometry (e.g. imported from another CAD engine or something like this), although in some cases they could be very handy as a shortcut.