Multiple instances of shapes

Hi !

I have some shapes I would like to display, but I need to transform them a bit first, I do this something like this:

BRepPrimAPI_MakeSphere s( ....); gp_GTrsf xform; transform( parent, xform); // Get transformation BRepBuilderAPI_GTransform gx( xform); gx.Perform( s.Shape()); // Here I would like to reuse s but translated to another position

The question here is, as I understand it the transformation matrix is saved in the shape, and in that case it's not possible to have multiple instances of the same shape, but transformed to different coordinates, is this correct, and in that case is there a good way to solve this ?

Mikael

Maxim ZVEREV's picture

Hello Mikael!

In fact, when you apply transformation to the TopoDS_Shape you change the Location but TShape will became the same. And by using the method TopoDS_Shape::IsPartner you can check that TShape is shared between the instances of TopoDS_Shape.

So, you can apply transformation by the following:

TopoDS_Shape sp = //here you make sphere;

//make the copy of TopoDS_Shape TopoDS_Shape spToTransf = sp;

//after apply transformation to spToTransf //and you will have two shapes with different locations // but with same TShape

spToTrans.IsPartner(sp) == Standard_True;

Best Regards,

Maxim.