Hello Author,
When Select3D_Box2d structure was introduced, the idea was to avoid adding any unnecessary fields to it and to make it as memory-efficient as possible. Adding a Standard_Boolean field to it increases its size by sizeof(int), that is, by 4 bytes or 20%.
In fact, "void" property of a 2d bounding box is analyzed only in two places in Select3D package:
- Select3D_SensitiveCircle.cxx line 186
- Select3D_SensitiveFace.cxx line 80
In both cases, Bnd_Box2d instance is created on-the-fly using Select3D_Box2d::operator Bnd_Box2d() method. The latter creates a correct void box in case if all four coordinate values are zero. Thus probably it is enough to correct private Select3D_Box2d::SetField() method and treat a void box in it properly by nullifying the four coordinates. It can look like this:
inline void SetField(const Bnd_Box2d& theBox)
{
if ( theBox.IsVoid() )
SetVoid();
else {
Standard_Real x, y, x1, y1;
theBox.Get(x, y, x1, y1);
xmin = DToF(x);
ymin = DToF(y);
xmax = DToF(x1);
ymax = DToF(y1);
}
}
It should be noted here that Select3D_Box2d is a simplified implementation of a 2D bounding box used by interactive detection algorithm only.
Certainly, if we knew more details about the case that resulted in the proposed patch we would be able to take a more well-grounded decision based not only on the memory efficiency reasons but also on some custom algorithmic requirements, etc.
We are looking forward to your feedback.
On behalf of the team,
Commenter-1