Move TopoDS_Shape to global position

Hello

How can I move my TopoDS_Shape to global coordinates?

I have shape with some coordinates and I want to add this shape to my context in new position relative to some point, for example to global (0,0,0)

I tried:

gp_Trsf trsf;

trsf.SetTransformation(gp_Ax3(gp_Pnt(0., 0., 0.), gp_Dir()));

BRepBuilderAPI_Transform transform(trsf);

transform.Perform(shape);

//auto curLoc = shape.Location();

//shape.Location(TopLoc_Location(trsf));

Handle_AIS_Shape aisShape = new AIS_Shape(shape);

myAISContext->Display(aisShape, false);

But the new shape does not appear in (0,0,0)

Francois Lauzon's picture

you should probably have something like thing instead:

Handle_AIS_Shape aisShape = new AIS_Shape(transform.Shape());

a.kliuchnikova_144191's picture

Thank you for you answer! But I have strange behavior. I added box in MFC sample. Then I copy it in std::vector<TopoDS_Shape> copy  as 

void OCC_3dBaseDoc::OnObjectCopy()

{

for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())

{

copy.clear();

if (myAISContext->SelectedInteractive()->IsKind(STANDARD_TYPE(AIS_Shape))) {

Handle_AIS_Shape anIS = Handle_AIS_Shape::DownCast(myAISContext->SelectedInteractive());

TopoDS_Shape shape = anIS->Shape();

BRepBuilderAPI_Copy A;

A.Perform(shape);

copy.push_back(A.Shape());

}

}

}

Then I do Paste

void OCC_3dBaseDoc::OnBackgroundPaste()

{

if (copy.size() != 0) {

//make dialog to past point

}

for (auto &shape : copy) {

gp_Trsf trsf;

trsf.SetTransformation(gp_Ax3(gp_Pnt(0., 0., 0.), gp_Dir()));

BRepBuilderAPI_Transform transform(trsf);

transform.Perform(shape);

Handle_AIS_Shape aisShape = new AIS_Shape(transform.Shape()); 

myAISContext->Display(aisShape, false);

}

}

What did I get?

If I make my box with left corner in (100. 0 0), copy it and then past in (0,0,0) I see that my RIGHT corner of copy shape in (0,0,0) Not left as I expect. And the same with any other positions. I see my copy in right point but not left corner in this point, but right.