Zoom to AIS_Shape

Hi OCC,

Is there a way to zoom a AIS_Shape in the view?, So that the AIS_Shape is maximized in the view?
Do you have any hints on how to achieve this?

Thanks, Guido

Kirill Gavrilov's picture

If you mean to fit AIS_Shape bounding box into entire View, then you may call an appropriate V3d_View::FitAll() method.

Handle(V3d_View)  theView;
Handle(AIS_Shape) thePrs;
Bnd_Box aBndBox;
thePrs->BoundingBox (aBndBox); // or use another AIS_Shape::BoundingBox() relying on BRepBndLib
if (!aBndBox.IsVoid())
{
  theView->FitAll (aBndBox, 0.01, true);
}
Guido van Hilst not specified's picture

Thanks!

Luc Wens's picture

Hi Guido,

something like this

Handle_V3d_View myView;

const Bnd_Box aBndSelected = getBndBoxSelected(myAISContext);
if (!aBndSelected.IsVoid())
{
myView->FitMinMax(myView->Camera(), aBndSelected, 0.01);
myView->Invalidate();
update3dView();
}

This will allow you to zoom into a bounding box, which you should be able to get easily from your shape. Look for FitMinMax for better examples.

Cheers

Luc

Guido van Hilst not specified's picture

Thanks' Luc!