[C++] how to respond to Zoom Extents for custom object bounding box

One of the custom objects that we use has a larger “perceived” bounding box than its constituent geometry, due to part of the object being drawn in a mirrored way.
I have tried to override GetBoundingBox(CRhinoView* pView) and that gives good results for clipping (i.e. the virtual, mirrored part is not clipped upon zooming into that part).

I find, however, that the zoom extents all command (ZEA) does not take this larger bounding box into account. It always zooms to the geometry, whereas I want it to zoom to the geometry AND the virtual, mirrored part. How do I tell Rhino that my object should be shown the way I want?

In ASCII art:

[ ] viewport
G only geometry
M|G geometry with mirrored part
M|[G] - current result of zoom extents all, only the G part is in the viewport
[M|G] - desired result of zoom extents all, both geometry and mirrored part are visible

(I hope this is clear?!)

Hi Menno,

On your custom object, override the CRhinoObject::GetTightBoundingBox virtual function and return the correct bounding box.

Does this help?

– Dale

This did not help in the first try, but when I take into account the supplied transformation, it works.

Currently, this is my implementation:

bool CMyObject::GetTightBoundingBox(ON_BoundingBox& tight_bbox, bool bGrowBox, const ON_Xform* x) const
{
    if (CRhinoSurfaceObject::GetTightBoundingBox(tight_bbox, bGrowBox, x))
    {
        ON_Xform mir;
        ON_3dPoint origin(ON_3dPoint::Origin);
        ON_3dVector normal(ON_3dVector::YAxis);
        
        if (x && x->IsValid())
        {
            origin.Transform(*x);
            normal.Transform(*x);
        }        
        mir.Mirror(origin, normal);

        ON_BoundingBox mbb = tight_bbox;
        mbb.Transform(mir);        
        tight_bbox.Union(mbb);
        return true;
    }
    return false;
}

@stevebaer @dale

The use of TightBoundingBox on a custom object gives problems when the constituent geometry is asked for a bounding box in .NET. I filed a bug for this

http://mcneel.myjetbrains.com/youtrack/issue/RH-30605