DiscussionsIssue archiveVisualization and 3D Viewer

Archived discussion

Zoom to AIS_Shape

Visualization and 3D ViewerMon, 06/21/2021 - 14:554 replies

Browse this forum
QuestionAuthor

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, Author

Discussion

4 archived replies

Posts are displayed in their archived order.

01Commenter-1

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);
}
02Author

Thanks!

03Commenter-2

Hi Author,

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

Commenter-2

04Author

Thanks' Luc!