@@ -1004,15 +1004,37 @@ computeBoundingBox(const TopoDS_Shape& shape, gp_Pnt& pmin, gp_Pnt& pmax)
10041004{
10051005 Bnd_Box box;
10061006 BRepCheck_Analyzer analyzer (shape);
1007+
10071008 if (analyzer.IsValid ()) {
10081009 BRepBndLib::AddClose (shape, box);
10091010 } else {
10101011 BRepBndLib::AddOptimal (shape, box);
10111012 }
10121013
10131014 if (box.IsVoid ())
1015+ {
10141016 BRepBndLib::Add (shape, box);
1017+ }
10151018
1019+ TopAbs_ShapeEnum type = shape.ShapeType ();
1020+ if (type != TopAbs_FACE && type != TopAbs_EDGE && type != TopAbs_VERTEX)
1021+ {
1022+ // On teste si la box est plane
1023+ // Récupérer les coins min et max
1024+ gp_Pnt minCorner = box.CornerMin ();
1025+ gp_Pnt maxCorner = box.CornerMax ();
1026+
1027+ // Calculer les dimensions
1028+ double width = maxCorner.X () - minCorner.X ();
1029+ double height = maxCorner.Y () - minCorner.Y ();
1030+ double depth = maxCorner.Z () - minCorner.Z ();
1031+
1032+ // Vérifier si l'une des dimensions est nulle ou quasi-nulle
1033+ double tolerance = 1e-7 ;
1034+ if (width < tolerance || height < tolerance || depth < tolerance) {
1035+ BRepBndLib::Add (shape, box);
1036+ }
1037+ }
10161038 double xmin, ymin, zmin, xmax, ymax, zmax;
10171039 box.Get (xmin, ymin, zmin, xmax, ymax, zmax);
10181040 pmin.SetCoord (xmin, ymin, zmin);
0 commit comments