Be aware that there is no function to reset the bounds. TBoundsMaker always accumulates bounds. When you want to return the bounds on an MDrawable derived class independent of the last bounds computation, create a new TBoundsMaker instance.
Chapter 13 uses TBoundsMaker in its hit detection example for 3-D graphics. The example gets the drawing port (TView::GetGrafPort) and passes it and the graphic for which the bounds are being found to the TBoundsMaker::AccumulateBounds function. TBoundsMaker::GetBounds returns the enclosing TGRect which is cast to the coordinate system of the view with the TView::GlobalToLocal function. When no TGrafPort instance is provided to AccumulateBounds, TBoundsMaker uses the semantics of TRootGrafPort by default. Figure 28 shows the bounds returned by TBoundsMaker.
NOTE A TBoundsMaker can be created with a TBoundsMakerDevice if you want to make a special device for special-purpose bounds. TBoundsMakerDevice descends from TGrafDevice, which is described in Chapter 19.
The returned bounds is a TGRect that exactly encloses the graphic. You can derive from TBoundsMaker and create your own algorithm for returning the bounds if you want to, for example, exclude the points included in the returned TGRect that are outside the graphic.