Map unchanged shapes resulting from BRepBuilderAPI_MakeShape algorithms [solved]

The BRepBuilderAPI_MakeShape algorithm interface provides the methods

  • Modified
  • Generated
  • Deleted

which allow to map (sub)shapes resulting from an algorithm from the original shape to the result shape, i.e. provide the shape history.

This allows e.g. to figure out, what faces during a Boolean operation are trimmed and what the original faces in the original shapes have been.

The API does not allow though to map the shapes (e.g. faces) that have not been modified.

Lets make an example:

Lets say we have a boolean operation between two boxes

auto box1 = BRepPrimAPI_MakeBox(...).Shape();
auto box2 = BRepPrimAPI_MakeBox(...).Shape();
BRepAlgoAPI_Common algo(box1, box2);
auto result = algo.Shape();

Now I want to know, which face in result was which faces in box1 or box2. The API currently only allows to map the changed faces.

I tried to use the HashCode function on each face, in the hope that the unchanged faces keep the same hash, but this is not the case.

If course, one could try to figure this out by geometric properties (control points, location ...), but this is probably more work than required.

Does anyone know a function to map the same subshapes in two different shapes (assuming, one shape was created by the other by an algorithm)?

Martin Siggel's picture

I am sorry, I mistakenly used BRepAlgoAPI_Common, which does not preserve any original faces.

I wanted to use BRepAlgoAPI_Fuse (Boolean Add).

The resulting unchanged faces have the same hash as the original faces.

The thread can be marked as solved!

Matthias K.'s picture

It will also work for Common-operation when using IsSame/IsEqual-function of TopoDS_Shape.