Making transformation "permanent"

Hello everybody,

I have a question concerning shape transformation/location. Assumed I had a sphere (radius R, middle point (0, 0, 0)). I use sphere.Move to apply a transformation (let's say a translation in z-axis so that the middle point is (0, 0, 10)). In this way I change the location of the shape. Is there a way to make this transformation "permanent" so that the underlying shape is updated but not its location (without using reshaping tools)?

I found this can be achieved through exporting into STEP and importing the file again but this doesn't seem to be the best solution...

Thanks in advance

Roman Lygin's picture

Hi Pawel,

Why would you need that ? Location is an additional member of TopoDS_Shape which enables sharing. Imaging an assembly consisting of multiple shared components, but each with its own location. It saves memory and allows to maintain real sharing (see TopoDS_Shape::IsPartner()).

If for any reason you really need to change underlying geometry to take into account location, then you will also need to break out sharing and to create separate copies of the 'partner' shapes. As an algorithm you might consider subclassing BRepTools_Modification to redefine its methods that would create new geometries for subshapes(faces, edges, vertices) using attached locations. Examples of such can be found in BRepTools and ShapeCustom. But I would really first double-check if loosing location is a preferred option.

Good luck.

Pawel's picture

Hi Roman,

thanks for clarification.

Yes, I see your point. What I was thinking of could be the following case: Let's consider a CAD/CAM application. The user modifies the a shape in the CAD module ("permanent" location modification) and then computes some additional movements ans simulates them ("volatile" location modification).

But I agree, this is more a question of the architecture.
Anyway, thanks for the hints.


Cauchy Ding's picture

Hi Pawel,

BRepBuilderAPI_Transform has a parameter "Copy". Hope it works.


Pawel's picture

Hello Cauchy,

thanks for the hint but it unfortunately doesn't work. The copy is made of both the shape and the transformation.


Jeff Moody's picture

The following should work (given a TopoDS_Shape named "shape"):
gp_Trsf transformation;
// ... set the desired properties of the transformation
shape = BRepBuilderAPI_Transform(shape, transformation, Standard_True);

Alternatively, you can use the following:
shape = BRepBuilderAPI_GTransform(shape, transformation);

I didn't see any difference when passing Standard_True as the 3rd argument in this case.
Also, if you want non-uniform scaling, you need to use BRepBuilderAPI_GTransform instead of BRepBuilderAPI_Transform.