TBoundsMaker

TBoundsMaker computes the bounds in device space for any MDrawable derived class. It takes into account the bundle information, view matrices, and modeling matrices; but never includes extra points beyond the bundle information the way that GetLooseFitBounds can. To use TBoundsMaker, you instantiate it and call the member functions shown in Figure 27.

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.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker