diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index ef27df00dcb..3488fce9255 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -1007,13 +1008,17 @@ void MainWindow::computeViewerBBox(CGAL::qglviewer::Vec& min, CGAL::qglviewer::V max= CGAL::qglviewer::Vec(xmax, ymax, zmax); CGAL::qglviewer::Vec bbox_center((xmin+xmax)/2, (ymin+ymax)/2, (zmin+zmax)/2); + double bbox_diag = CGAL::approximate_sqrt( + (xmax - xmin)*(xmax - xmin) + + (ymax - ymin)*(ymax - ymin) + + (zmax - zmin)*(zmax - zmin)); CGAL::qglviewer::Vec offset(0,0,0); double l_dist = (std::max)((std::abs)(bbox_center.x - viewer->offset().x), (std::max)((std::abs)(bbox_center.y - viewer->offset().y), (std::abs)(bbox_center.z - viewer->offset().z))); - if((std::log2)(l_dist) > 13.0 ) + if((std::log2)(l_dist/bbox_diag) > 13.0 ) for(int i=0; i<3; ++i) { offset[i] = -bbox_center[i];