- GEOMUtils::PreciseBoundingBox(aShape, Box);
- return sqrt( Box.SquareExtent() );
+ // avoid too long waiting on large shapes. PreciseBoundingBox() was added
+ // to assure same result which else depends on presence of triangulation (IPAL52557).
+ const int maxNbFaces = 4000;
+ int nbFaces = 0;
+ for ( TopExp_Explorer f( aShape, TopAbs_FACE ); f.More() && nbFaces < maxNbFaces; f.Next() )
+ ++nbFaces;
+ if ( nbFaces < maxNbFaces )
+ GEOMUtils::PreciseBoundingBox(aShape, Box);
+ else
+ BRepBndLib::Add( aShape, Box);
+ if ( !Box.IsVoid() )
+ return sqrt( Box.SquareExtent() );