Copy Shape

Hi, how can I copy a shape with all its subshapes so that when I modify or transform the new shape, original shape is not affected. (no referenced subshapes, all copied)
Thanks

Rob Bachrach's picture

Technically, your original shape is never "affected" when you transform a copy:

TopoDS_Shape newShape = oldShape;

The transform simply changes the location of the new shape, but the referenced geometry remains the same.

You can also try using BRepBuilderAPI_GTransform. This will actually create a new, transformed geometry and will not just change the location within the TopoDS_Shape.

Rob

gianni's picture

To make a copy of a shape you should use the class
BRepBuilderAPI_Copy.

Something like:

BRepBuilderAPI_Copy A;
A.Perform(aShape);
TopoDS_Shape ShapeCopy;
ShapeCopy=A.Shape();