View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0027042 | Community | OCCT:Modeling Algorithms | public | 2015-12-27 19:52 | 2016-01-11 17:11 |
| Reporter | Epy | Assigned To | bugmaster | ||
| Priority | normal | Severity | minor | ||
| Status | closed | Resolution | no change required | ||
| Platform | All | ||||
| Product Version | 6.8.0 | ||||
| Summary | 0027042: Bnd_Box fails to correctly calculate bounding box on scaled sphere | ||||
| Description | Creating a sphere and calculating the bounding box produces the correct results, but then scaling that sphere and calculating bounding box again produces incorrect results. See the attached C++ program. The first results are as expected (10, 10, 10), but after scaling instead of getting (20, 20, 20) you get (30, 34.641, 20) | ||||
| Steps To Reproduce | #include <ostream> #include <Standard_Real.hxx> #include <TopoDS_Shape.hxx> #include <BRepPrimAPI_MakeSphere.hxx> #include <Bnd_Box.hxx> #include <BRepBndLib.hxx> #include <gp_GTrsf.hxx> #include <gp_Mat.hxx> #include <BRepBuilderAPI_GTransform.hxx> int main() { Standard_Real r = 5, xmin, ymin, zmin, xmax, ymax, zmax; TopoDS_Shape sp = BRepPrimAPI_MakeSphere(r).Shape(); Bnd_Box bbox; BRepBndLib::Add(sp, bbox); bbox.Get(xmin, ymin, zmin, xmax, ymax, zmax); std::cout << xmax - xmin << ", " << ymax - ymin << ", " << zmax - zmin << std::endl; gp_GTrsf scale_trsf; gp_Mat t(2, 0, 0, 0, 2, 0, 0, 0, 2); scale_trsf.SetVectorialPart(t); TopoDS_Shape sp2 = BRepBuilderAPI_GTransform(sp, scale_trsf).Shape(); Bnd_Box bbox2; BRepBndLib::Add(sp2, bbox2); bbox2.Get(xmin, ymin, zmin, xmax, ymax, zmax); std::cout << xmax - xmin << ", " << ymax - ymin << ", " << zmax - zmin << std::endl; return 0; } | ||||
| Tags | No tags attached. | ||||
| Test case number | |||||
|
|
|
test.cxx (992 bytes) |
|
|
The same result we can obtain using the following draw script: psphere s 5 puts [bounding s] scalexyz r s 2 2 2 puts [bounding r] The bounding boxes are the following: -5.0000001000000003 -5.0000001000000003 -5.0000001000000003 5.0000001000000003 5.0000001000000003 5.0000001000000003 -20.000000199999995 -17.320508275688777 -10.000000200000001 10.000000200000001 17.320508275688766 10.000000200000001 This result is as expected. It is because the algorithm BRepBuilderAPI_GTransform generates b-spline geometries, and the bounding box on b-splines is constructed using its poles. The poles of this spheric b-spline are shown in the attached picture. In order to keep the geometry form of the original shape you need to use isotropic transformation that is done with the classes gp_Trsf and BRepBuilderAPI_Transform. For that, the piece of transforming code should look like this: gp_Trsf scale_trsf; scale_trsf.SetScale(gp::Origin(), 2); TopoDS_Shape sp2 = BRepBuilderAPI_Transform(sp, scale_trsf).Shape(); Or, using draw script: tscale s 0 0 0 2 After doing this, the bounding box is the following: -10.000000200000001 -10.000000200000001 -10.000000200000001 10.000000200000001 10.000000200000001 10.000000200000001 And the program puts: 10, 10, 10 20, 20, 20 As you expected. |
|
|
Thanks, I understand now. This can be closed. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2015-12-27 19:52 | Epy | New Issue | |
| 2015-12-27 19:52 | Epy | Assigned To | => msv |
| 2015-12-27 19:52 | Epy | File Added: test.cxx | |
| 2015-12-28 11:58 |
|
Note Added: 0049627 | |
| 2015-12-28 11:59 |
|
Assigned To | msv => Epy |
| 2015-12-28 11:59 |
|
Status | new => feedback |
| 2015-12-28 18:50 | Epy | Note Added: 0049656 | |
| 2015-12-28 19:09 |
|
Assigned To | Epy => bugmaster |
| 2016-01-11 17:11 | bugmaster | Status | feedback => closed |
| 2016-01-11 17:11 | bugmaster | Resolution | open => no change required |