How to move an AIS_SHAPE????

Hi, I need help

I tried to move a sphere which is an AIS_SHAPE but I didn't get it. I think maybe jooo can help me.


Hugues's picture

You can move an AIS_Shape or more generally an AIS_InteractiveObjet with the procedure AIS_InteractiveContext::SetLocation.
It takes the interactive object to move, and the move as a transformation.
Transformations are gp_Trsf objects.

To translate an item to P(x, y, z) do :
gp_Trsf move;
move.SetValues (1, 0, 0, x,
0, 1, 0, y,
0, 0, 1, z,
angular_tol, confusion_tol);
ais_context->SetLocation (ais_shape, move);

viviana's picture

Hi Hugues

Thank you very much, It worked.

Madesh R's picture

its not working for me,Here is the procedure that i followed

  BRepPrimAPI_MakeSphere mkSphere2(5.0);
     TopoDS_Shape Sphere2=mkSphere2.Shape();

Handle(AIS_Shape) AISsphere2=new AIS_Shape(Sphere2);
 gp_Trsf move;
 move.SetValues(10, 0, 0, 500,
 0, 10, 0, 100,
 0, 0, 1, 0);
 AISContext->SetLocation (AISsphere2, move);
  AISContext->SetDisplayMode (AIS_Shaded);

Irrespective of x,y,z values the sphere location is intact.Please help.

Kirill Gavrilov's picture

Your code produces expected result within current OCCT (although for certain you are using some obsolete version), so I don't see your problem.