@@ -1002,17 +1002,60 @@ computeArea(const TopoDS_Shape& volume)
10021002void OCCHelper::
10031003computeBoundingBox (const TopoDS_Shape& shape, gp_Pnt& pmin, gp_Pnt& pmax)
10041004{
1005+ Bnd_Box box0;
1006+ double xmin, ymin, zmin, xmax, ymax, zmax;
1007+ BRepBndLib::Add (shape, box0);
1008+ box0.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1009+ std::cout << " Avec Add : box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1010+
1011+ Bnd_Box box4;
1012+ BRepBndLib::Add (shape, box4, false );
1013+ box4.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1014+ std::cout << " Avec Add false : box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1015+
1016+ Bnd_Box box5;
1017+ BRepBndLib::Add (shape, box5);
1018+ box5.SetGap (0.0 );
1019+ box5.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1020+ std::cout << " Avec Add set Gap à 0 : box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1021+
1022+ Bnd_Box box1;
1023+ BRepBndLib::AddClose (shape, box1);
1024+ box1.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1025+ std::cout << " Avec AddClose: box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1026+
1027+ Bnd_Box box2;
1028+ BRepBndLib::AddOptimal (shape, box2);
1029+ box2.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1030+ std::cout << " Avec AddOptimal : box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1031+
1032+ Bnd_Box box3;
1033+ BRepBndLib::AddOptimal (shape, box3, false , false );
1034+ box3.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1035+ std::cout << " Avec AddOptimal false false : box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1036+
1037+ Bnd_Box box6;
1038+ BRepBndLib::AddOptimal (shape, box6, false , false );
1039+ box6.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1040+ box6.SetGap (0.0 );
1041+ std::cout << " Avec AddOptimal false false setGap à 0 : box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1042+
10051043 Bnd_Box box;
1044+ /*
10061045 BRepCheck_Analyzer analyzer(shape);
1007-
10081046 if (analyzer.IsValid()) {
1047+ std::cout << "On utilise AddClose" << std::endl;
10091048 BRepBndLib::AddClose(shape, box);
1049+ box.Get(xmin, ymin, zmin, xmax, ymax, zmax);
1050+ std::cout << "Dans le if: box(["<<xmin<<", "<<ymin<<", "<<zmin<<"],["<<xmax<<", "<<ymax<<", "<<zmax<<"])"<<std::endl;
10101051 } else {
1052+ std::cout << "On utilise AddOptimal" << std::endl;
10111053 BRepBndLib::AddOptimal(shape, box);
10121054 }
10131055
10141056 if (box.IsVoid())
10151057 {
1058+ std::cout << "On utilise Add" << std::endl;
10161059 BRepBndLib::Add(shape, box);
10171060 }
10181061
@@ -1032,11 +1075,19 @@ computeBoundingBox(const TopoDS_Shape& shape, gp_Pnt& pmin, gp_Pnt& pmax)
10321075 // Vérifier si l'une des dimensions est nulle ou quasi-nulle
10331076 double tolerance = 1e-7;
10341077 if (width < tolerance || height < tolerance || depth < tolerance) {
1078+ std::cout << "On utilise Add" << std::endl;
10351079 BRepBndLib::Add(shape, box);
10361080 }
10371081 }
1038- double xmin, ymin, zmin, xmax, ymax, zmax;
1082+ */
1083+ // BRepBndLib::AddOptimal(shape, box);
1084+ BRepBndLib::AddOptimal (shape, box);
1085+ box.SetGap (0.0 );
1086+
1087+ // double xmin, ymin, zmin, xmax, ymax, zmax;
10391088 box.Get (xmin, ymin, zmin, xmax, ymax, zmax);
1089+ std::cout << " Au final: box([" <<xmin<<" , " <<ymin<<" , " <<zmin<<" ],[" <<xmax<<" , " <<ymax<<" , " <<zmax<<" ])" <<std::endl;
1090+
10401091 pmin.SetCoord (xmin, ymin, zmin);
10411092 pmax.SetCoord (xmax, ymax, zmax);
10421093}
0 commit comments